Skip to content

Commit e894b72

Browse files
committed
drm/i915: Use the fdinfo helper
Use the common fdinfo helper for printing the basics. Remove now unused client id allocation code. Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Cc: Rob Clark <robdclark@chromium.org> Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20230605123224.373633-1-tvrtko.ursulin@linux.intel.com
1 parent 744bbf2 commit e894b72

5 files changed

Lines changed: 18 additions & 83 deletions

File tree

drivers/gpu/drm/i915/i915_driver.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,6 @@ static int i915_driver_early_probe(struct drm_i915_private *dev_priv)
243243
if (ret < 0)
244244
goto err_rootgt;
245245

246-
i915_drm_clients_init(&dev_priv->clients, dev_priv);
247-
248246
i915_gem_init_early(dev_priv);
249247

250248
/* This must be called before any calls to HAS_PCH_* */
@@ -278,7 +276,6 @@ static void i915_driver_late_release(struct drm_i915_private *dev_priv)
278276
intel_power_domains_cleanup(dev_priv);
279277
i915_gem_cleanup_early(dev_priv);
280278
intel_gt_driver_late_release_all(dev_priv);
281-
i915_drm_clients_fini(&dev_priv->clients);
282279
intel_region_ttm_device_fini(dev_priv);
283280
vlv_suspend_cleanup(dev_priv);
284281
i915_workqueues_cleanup(dev_priv);
@@ -1706,7 +1703,7 @@ static const struct file_operations i915_driver_fops = {
17061703
.compat_ioctl = i915_ioc32_compat_ioctl,
17071704
.llseek = noop_llseek,
17081705
#ifdef CONFIG_PROC_FS
1709-
.show_fdinfo = i915_drm_client_fdinfo,
1706+
.show_fdinfo = drm_show_fdinfo,
17101707
#endif
17111708
};
17121709

@@ -1806,6 +1803,7 @@ static const struct drm_driver i915_drm_driver = {
18061803
.open = i915_driver_open,
18071804
.lastclose = i915_driver_lastclose,
18081805
.postclose = i915_driver_postclose,
1806+
.show_fdinfo = i915_drm_client_fdinfo,
18091807

18101808
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
18111809
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,

drivers/gpu/drm/i915/i915_drm_client.c

Lines changed: 10 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -17,64 +17,29 @@
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

5935
void __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
7944
static 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

10368
static 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

drivers/gpu/drm/i915/i915_drm_client.h

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,13 @@
99
#include <linux/kref.h>
1010
#include <linux/list.h>
1111
#include <linux/spinlock.h>
12-
#include <linux/xarray.h>
1312

1413
#include <uapi/drm/i915_drm.h>
1514

1615
#define I915_LAST_UABI_ENGINE_CLASS I915_ENGINE_CLASS_COMPUTE
1716

18-
struct drm_i915_private;
19-
20-
struct i915_drm_clients {
21-
struct drm_i915_private *i915;
22-
23-
struct xarray xarray;
24-
u32 next_id;
25-
};
17+
struct drm_file;
18+
struct drm_printer;
2619

2720
struct i915_drm_client {
2821
struct kref kref;
@@ -32,17 +25,12 @@ struct i915_drm_client {
3225
spinlock_t ctx_lock; /* For add/remove from ctx_list. */
3326
struct list_head ctx_list; /* List of contexts belonging to client. */
3427

35-
struct i915_drm_clients *clients;
36-
3728
/**
3829
* @past_runtime: Accumulation of pphwsp runtimes from closed contexts.
3930
*/
4031
atomic64_t past_runtime[I915_LAST_UABI_ENGINE_CLASS + 1];
4132
};
4233

43-
void i915_drm_clients_init(struct i915_drm_clients *clients,
44-
struct drm_i915_private *i915);
45-
4634
static inline struct i915_drm_client *
4735
i915_drm_client_get(struct i915_drm_client *client)
4836
{
@@ -57,12 +45,10 @@ static inline void i915_drm_client_put(struct i915_drm_client *client)
5745
kref_put(&client->kref, __i915_drm_client_free);
5846
}
5947

60-
struct i915_drm_client *i915_drm_client_add(struct i915_drm_clients *clients);
48+
struct i915_drm_client *i915_drm_client_alloc(void);
6149

6250
#ifdef CONFIG_PROC_FS
63-
void i915_drm_client_fdinfo(struct seq_file *m, struct file *f);
51+
void i915_drm_client_fdinfo(struct drm_printer *p, struct drm_file *file);
6452
#endif
6553

66-
void i915_drm_clients_fini(struct i915_drm_clients *clients);
67-
6854
#endif /* !__I915_DRM_CLIENT_H__ */

drivers/gpu/drm/i915/i915_drv.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,6 @@ struct drm_i915_private {
347347

348348
struct i915_pmu pmu;
349349

350-
struct i915_drm_clients clients;
351-
352350
/* The TTM device structure. */
353351
struct ttm_device bdev;
354352

drivers/gpu/drm/i915/i915_gem.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,11 +1325,9 @@ int i915_gem_open(struct drm_i915_private *i915, struct drm_file *file)
13251325
if (!file_priv)
13261326
goto err_alloc;
13271327

1328-
client = i915_drm_client_add(&i915->clients);
1329-
if (IS_ERR(client)) {
1330-
ret = PTR_ERR(client);
1328+
client = i915_drm_client_alloc();
1329+
if (!client)
13311330
goto err_client;
1332-
}
13331331

13341332
file->driver_priv = file_priv;
13351333
file_priv->i915 = i915;

0 commit comments

Comments
 (0)