1717#include "i915_gem.h"
1818#include "i915_utils.h"
1919
20- void i915_drm_clients_init (struct i915_drm_clients * clients ,
21- struct drm_i915_private * i915 )
22- {
23- clients -> i915 = i915 ;
24- clients -> next_id = 0 ;
25-
26- xa_init_flags (& clients -> xarray , XA_FLAGS_ALLOC | XA_FLAGS_LOCK_IRQ );
27- }
28-
29- struct i915_drm_client * i915_drm_client_add (struct i915_drm_clients * clients )
20+ struct i915_drm_client * i915_drm_client_alloc (void )
3021{
3122 struct i915_drm_client * client ;
32- struct xarray * xa = & clients -> xarray ;
33- int ret ;
3423
3524 client = kzalloc (sizeof (* client ), GFP_KERNEL );
3625 if (!client )
37- return ERR_PTR (- ENOMEM );
38-
39- xa_lock_irq (xa );
40- ret = __xa_alloc_cyclic (xa , & client -> id , client , xa_limit_32b ,
41- & clients -> next_id , GFP_KERNEL );
42- xa_unlock_irq (xa );
43- if (ret < 0 )
44- goto err ;
26+ return NULL ;
4527
4628 kref_init (& client -> kref );
4729 spin_lock_init (& client -> ctx_lock );
4830 INIT_LIST_HEAD (& client -> ctx_list );
49- client -> clients = clients ;
5031
5132 return client ;
52-
53- err :
54- kfree (client );
55-
56- return ERR_PTR (ret );
5733}
5834
5935void __i915_drm_client_free (struct kref * kref )
6036{
6137 struct i915_drm_client * client =
6238 container_of (kref , typeof (* client ), kref );
63- struct xarray * xa = & client -> clients -> xarray ;
64- unsigned long flags ;
6539
66- xa_lock_irqsave (xa , flags );
67- __xa_erase (xa , client -> id );
68- xa_unlock_irqrestore (xa , flags );
6940 kfree (client );
7041}
7142
72- void i915_drm_clients_fini (struct i915_drm_clients * clients )
73- {
74- GEM_BUG_ON (!xa_empty (& clients -> xarray ));
75- xa_destroy (& clients -> xarray );
76- }
77-
7843#ifdef CONFIG_PROC_FS
7944static const char * const uabi_class_names [] = {
8045 [I915_ENGINE_CLASS_RENDER ] = "render" ,
@@ -101,38 +66,34 @@ static u64 busy_add(struct i915_gem_context *ctx, unsigned int class)
10166}
10267
10368static void
104- show_client_class (struct seq_file * m ,
69+ show_client_class (struct drm_printer * p ,
70+ struct drm_i915_private * i915 ,
10571 struct i915_drm_client * client ,
10672 unsigned int class )
10773{
108- const struct list_head * list = & client -> ctx_list ;
74+ const unsigned int capacity = i915 -> engine_uabi_class_count [ class ] ;
10975 u64 total = atomic64_read (& client -> past_runtime [class ]);
110- const unsigned int capacity =
111- client -> clients -> i915 -> engine_uabi_class_count [class ];
11276 struct i915_gem_context * ctx ;
11377
11478 rcu_read_lock ();
115- list_for_each_entry_rcu (ctx , list , client_link )
79+ list_for_each_entry_rcu (ctx , & client -> ctx_list , client_link )
11680 total += busy_add (ctx , class );
11781 rcu_read_unlock ();
11882
11983 if (capacity )
120- seq_printf ( m , "drm-engine-%s:\t%llu ns\n" ,
84+ drm_printf ( p , "drm-engine-%s:\t%llu ns\n" ,
12185 uabi_class_names [class ], total );
12286
12387 if (capacity > 1 )
124- seq_printf ( m , "drm-engine-capacity-%s:\t%u\n" ,
88+ drm_printf ( p , "drm-engine-capacity-%s:\t%u\n" ,
12589 uabi_class_names [class ],
12690 capacity );
12791}
12892
129- void i915_drm_client_fdinfo (struct seq_file * m , struct file * f )
93+ void i915_drm_client_fdinfo (struct drm_printer * p , struct drm_file * file )
13094{
131- struct drm_file * file = f -> private_data ;
13295 struct drm_i915_file_private * file_priv = file -> driver_priv ;
13396 struct drm_i915_private * i915 = file_priv -> i915 ;
134- struct i915_drm_client * client = file_priv -> client ;
135- struct pci_dev * pdev = to_pci_dev (i915 -> drm .dev );
13697 unsigned int i ;
13798
13899 /*
@@ -141,16 +102,10 @@ void i915_drm_client_fdinfo(struct seq_file *m, struct file *f)
141102 * ******************************************************************
142103 */
143104
144- seq_printf (m , "drm-driver:\t%s\n" , i915 -> drm .driver -> name );
145- seq_printf (m , "drm-pdev:\t%04x:%02x:%02x.%d\n" ,
146- pci_domain_nr (pdev -> bus ), pdev -> bus -> number ,
147- PCI_SLOT (pdev -> devfn ), PCI_FUNC (pdev -> devfn ));
148- seq_printf (m , "drm-client-id:\t%u\n" , client -> id );
149-
150105 if (GRAPHICS_VER (i915 ) < 8 )
151106 return ;
152107
153108 for (i = 0 ; i < ARRAY_SIZE (uabi_class_names ); i ++ )
154- show_client_class (m , client , i );
109+ show_client_class (p , i915 , file_priv -> client , i );
155110}
156111#endif
0 commit comments