Skip to contentSkip to conversation

drm/lima: expose usage statistics via fdinfo

PATCH Applied Erico Nunes 4 participants 10 messages Mar 12, 2023 – Apr 3, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover drm/lima: expose usage statistics via fdinfo

Expose lima gp and pp usage stats through fdinfo, following Documentation/gpu/drm-usage-stats.rst.
Borrowed from these previous implementations:

"df622729ddbf drm/scheduler: track GPU active time per entity" added usage time accounting to drm scheduler, which is where the data used here comes from.

Then the main implementation is based on these etnaviv commits:
"d306788b6e1b drm/etnaviv: allocate unique ID per drm_file" and "97804a133c68 drm/etnaviv: export client GPU usage statistics via fdinfo"

Also "874442541133 drm/amdgpu: Add show_fdinfo() interface" since lima has a context manager very similar to amdgpu and all contexts created (and released) at the ctx_mgr level need to be accounted for.

Tested with the generic "gputop" tool currently available as patches to igt, a sample run with this patchset looks like this:

DRM minor 128

    PID               NAME             gp                        pp
    4322   glmark2-es2-way |█████▊                  ||██████████████████      |
    3561            weston |▎                       ||███▌                    |
    4159          Xwayland |▏                       ||▉                       |
    4154          glxgears |▏                       ||▎                       |
    3661           firefox |▏                       ||▏                       |

Erico Nunes (3):
drm/lima: add usage counting method to ctx_mgr
drm/lima: allocate unique id per drm_file
drm/lima: add show_fdinfo for drm usage stats

 drivers/gpu/drm/lima/lima_ctx.c    | 30 ++++++++++++++++++++-
 drivers/gpu/drm/lima/lima_ctx.h    |  3 +++
 drivers/gpu/drm/lima/lima_device.h |  3 +++
 drivers/gpu/drm/lima/lima_drv.c    | 43 +++++++++++++++++++++++++++++-
 drivers/gpu/drm/lima/lima_drv.h    |  1 +
 5 files changed, 78 insertions(+), 2 deletions(-)
Signature · 1 line
2.39.2
#1 lore raw

PATCH 1/3 drm/lima: add usage counting method to ctx_mgr

lima maintains a context manager per drm_file, similar to amdgpu. In order to account for the complete usage per drm_file, all of the associated contexts need to be considered.
Previously released contexts also need to be accounted for but their drm_sched_entity info is gone once they get released, so account for it in the ctx_mgr.

---
 drivers/gpu/drm/lima/lima_ctx.c | 30 +++++++++++++++++++++++++++++-
 drivers/gpu/drm/lima/lima_ctx.h |  3 +++
 2 files changed, 32 insertions(+), 1 deletion(-)
drivers/gpu/drm/lima/lima_ctx.c +29 -1
index 891d5cd5019a..e008e586fad0 100644
@@ -15,6 +15,7 @@ int lima_ctx_create(struct lima_device *dev, struct lima_ctx_mgr *mgr, u32 *id)
 	if (!ctx)
 		return -ENOMEM;
 	ctx->dev = dev;
+	ctx->mgr = mgr;
 	kref_init(&ctx->refcnt);
 
 	for (i = 0; i < lima_pipe_num; i++) {
@@ -42,10 +43,17 @@ int lima_ctx_create(struct lima_device *dev, struct lima_ctx_mgr *mgr, u32 *id)
 static void lima_ctx_do_release(struct kref *ref)
 {
 	struct lima_ctx *ctx = container_of(ref, struct lima_ctx, refcnt);
+	struct lima_ctx_mgr *mgr = ctx->mgr;
 	int i;
 
-	for (i = 0; i < lima_pipe_num; i++)
+	for (i = 0; i < lima_pipe_num; i++) {
+		struct lima_sched_context *context = &ctx->context[i];
+		struct drm_sched_entity *entity = &context->base;
+
+		mgr->elapsed_ns[i] += entity->elapsed_ns;
+
 		lima_sched_context_fini(ctx->dev->pipe + i, ctx->context + i);
+	}
 	kfree(ctx);
 }
 
@@ -99,3 +107,23 @@ void lima_ctx_mgr_fini(struct lima_ctx_mgr *mgr)
 	xa_destroy(&mgr->handles);
 	mutex_destroy(&mgr->lock);
 }
+
+void lima_ctx_mgr_usage(struct lima_ctx_mgr *mgr, u64 usage[lima_pipe_num])
+{
+	struct lima_ctx *ctx;
+	unsigned long id;
+
+	for (int i = 0; i < lima_pipe_num; i++)
+		usage[i] = mgr->elapsed_ns[i];
+
+	mutex_lock(&mgr->lock);
+	xa_for_each(&mgr->handles, id, ctx) {
+		for (int i = 0; i < lima_pipe_num; i++) {
+			struct lima_sched_context *context = &ctx->context[i];
+			struct drm_sched_entity *entity = &context->base;
+
+			usage[i] += entity->elapsed_ns;
+		}
+	}
+	mutex_unlock(&mgr->lock);
+}
drivers/gpu/drm/lima/lima_ctx.h +3 -0
index 74e2be09090f..6068863880eb 100644
@@ -12,6 +12,7 @@
 struct lima_ctx {
 	struct kref refcnt;
 	struct lima_device *dev;
+	struct lima_ctx_mgr *mgr;
 	struct lima_sched_context context[lima_pipe_num];
 	atomic_t guilty;
 
@@ -23,6 +24,7 @@ struct lima_ctx {
 struct lima_ctx_mgr {
 	struct mutex lock;
 	struct xarray handles;
+	u64 elapsed_ns[lima_pipe_num];
 };
 
 int lima_ctx_create(struct lima_device *dev, struct lima_ctx_mgr *mgr, u32 *id);
@@ -31,5 +33,6 @@ struct lima_ctx *lima_ctx_get(struct lima_ctx_mgr *mgr, u32 id);
 void lima_ctx_put(struct lima_ctx *ctx);
 void lima_ctx_mgr_init(struct lima_ctx_mgr *mgr);
 void lima_ctx_mgr_fini(struct lima_ctx_mgr *mgr);
+void lima_ctx_mgr_usage(struct lima_ctx_mgr *mgr, u64 usage[lima_pipe_num]);
 
 #endif
Signature · 1 line
2.39.2
#2 lore raw

Re: [PATCH 1/3] drm/lima: add usage counting method to ctx_mgr

Quoted 28 lines · Erico Nunes

lima maintains a context manager per drm_file, similar to amdgpu. In order to account for the complete usage per drm_file, all of the associated contexts need to be considered.
Previously released contexts also need to be accounted for but their drm_sched_entity info is gone once they get released, so account for it in the ctx_mgr.

---
 drivers/gpu/drm/lima/lima_ctx.c | 30 +++++++++++++++++++++++++++++-
 drivers/gpu/drm/lima/lima_ctx.h |  3 +++
 2 files changed, 32 insertions(+), 1 deletion(-)
drivers/gpu/drm/lima/lima_ctx.c +1 -0
index 891d5cd5019a..e008e586fad0 100644
@@ -15,6 +15,7 @@ int lima_ctx_create(struct lima_device *dev, struct lima_ctx_mgr *mgr, u32 *id)
 	if (!ctx)
 		return -ENOMEM;
 	ctx->dev = dev;
+	ctx->mgr = mgr;
 	kref_init(&ctx->refcnt);
 
 	for (i = 0; i < lima_pipe_num; i++) {
@@ -42,10 +43,17 @@ int lima_ctx_create(struct lima_device *dev, struct lima_ctx_mgr *mgr, u32 *id)
 static void lima_ctx_do_release(struct kref *ref)
 {

drivers/gpu/drm/lima/lima_ctx.c int lima_ctx_create(struct lima_device *dev, struct lima_ctx_mgr *mgr, u32 *id) · line 53

Quoted 10 lines
drivers/gpu/drm/lima/lima_ctx.c +6 -1
 	struct lima_ctx *ctx = container_of(ref, struct lima_ctx, refcnt);
+	struct lima_ctx_mgr *mgr = ctx->mgr;
 	int i;
 
-	for (i = 0; i < lima_pipe_num; i++)
+	for (i = 0; i < lima_pipe_num; i++) {
+		struct lima_sched_context *context = &ctx->context[i];
+		struct drm_sched_entity *entity = &context->base;
+
+		mgr->elapsed_ns[i] += entity->elapsed_ns;

drm-tip build is now broken because of this vs.
commit baad10973fdb ("Revert "drm/scheduler: track GPU active time per entity"")

../drivers/gpu/drm/lima/lima_ctx.c: In function ‘lima_ctx_do_release’:
../drivers/gpu/drm/lima/lima_ctx.c:53:45: error: ‘struct drm_sched_entity’ has no member named ‘elapsed_ns’
53 | mgr->elapsed_ns[i] += entity->elapsed_ns;

Signature · 2 lines
Ville Syrjälä
Intel
#3 lore raw

PATCH 2/3 drm/lima: allocate unique id per drm_file

In reply to Erico Nunes

To track if fds are pointing to the same execution context and export the expected information to fdinfo, similar to what is done in other drivers.

---
 drivers/gpu/drm/lima/lima_device.h |  3 +++
 drivers/gpu/drm/lima/lima_drv.c    | 12 ++++++++++++
 drivers/gpu/drm/lima/lima_drv.h    |  1 +
 3 files changed, 16 insertions(+)
drivers/gpu/drm/lima/lima_device.h +3 -0
index 41b9d7b4bcc7..71b2db60d161 100644
@@ -106,6 +106,9 @@ struct lima_device {
 	struct lima_dump_head dump;
 	struct list_head error_task_list;
 	struct mutex error_task_list_lock;
+
+	struct xarray active_contexts;
+	u32 next_context_id;
 };
 
 static inline struct lima_device *
drivers/gpu/drm/lima/lima_drv.c +12 -0
index 7b8d7178d09a..d23c0b77a252 100644
@@ -218,6 +218,11 @@ static int lima_drm_driver_open(struct drm_device *dev, struct drm_file *file)
 	if (!priv)
 		return -ENOMEM;
 
+	err = xa_alloc_cyclic(&ldev->active_contexts, &priv->id, priv,
+			      xa_limit_32b, &ldev->next_context_id, GFP_KERNEL);
+	if (err < 0)
+		goto err_out0;
+
 	priv->vm = lima_vm_create(ldev);
 	if (!priv->vm) {
 		err = -ENOMEM;
@@ -237,6 +242,9 @@ static int lima_drm_driver_open(struct drm_device *dev, struct drm_file *file)
 static void lima_drm_driver_postclose(struct drm_device *dev, struct drm_file *file)
 {
 	struct lima_drm_priv *priv = file->driver_priv;
+	struct lima_device *ldev = to_lima_dev(dev);
+
+	xa_erase(&ldev->active_contexts, priv->id);
 
 	lima_ctx_mgr_fini(&priv->ctx_mgr);
 	lima_vm_put(priv->vm);
@@ -388,6 +396,8 @@ static int lima_pdev_probe(struct platform_device *pdev)
 	ldev->dev = &pdev->dev;
 	ldev->id = (enum lima_gpu_id)of_device_get_match_data(&pdev->dev);
 
+	xa_init_flags(&ldev->active_contexts, XA_FLAGS_ALLOC);
+
 	platform_set_drvdata(pdev, ldev);
 
 	/* Allocate and initialize the DRM device. */
@@ -444,6 +454,8 @@ static int lima_pdev_remove(struct platform_device *pdev)
 	struct lima_device *ldev = platform_get_drvdata(pdev);
 	struct drm_device *ddev = ldev->ddev;
 
+	xa_destroy(&ldev->active_contexts);
+
 	sysfs_remove_bin_file(&ldev->dev->kobj, &lima_error_state_attr);
 
 	drm_dev_unregister(ddev);
drivers/gpu/drm/lima/lima_drv.h +1 -0
index c738d288547b..e49b7ab651d0 100644
@@ -20,6 +20,7 @@ struct lima_sched_task;
 struct drm_lima_gem_submit_bo;
 
 struct lima_drm_priv {
+	int id;
 	struct lima_vm *vm;
 	struct lima_ctx_mgr ctx_mgr;
 };
Signature · 1 line
2.39.2
#4 lore raw

PATCH 3/3 drm/lima: add show_fdinfo for drm usage stats

In reply to Erico Nunes

This exposes an accumulated active time per client via the fdinfo infrastructure per execution engine, following Documentation/gpu/drm-usage-stats.rst.
In lima, the exposed execution engines are gp and pp.

---
 drivers/gpu/drm/lima/lima_drv.c | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)
drivers/gpu/drm/lima/lima_drv.c +30 -1
index d23c0b77a252..c044a31493a4 100644
@@ -261,7 +261,36 @@ static const struct drm_ioctl_desc lima_drm_driver_ioctls[] = {
 	DRM_IOCTL_DEF_DRV(LIMA_CTX_FREE, lima_ioctl_ctx_free, DRM_RENDER_ALLOW),
 };
 
-DEFINE_DRM_GEM_FOPS(lima_drm_driver_fops);
+static void lima_drm_driver_show_fdinfo(struct seq_file *m, struct file *filp)
+{
+	struct drm_file *file = filp->private_data;
+	struct drm_device *dev = file->minor->dev;
+	struct lima_device *ldev = dev->dev_private;
+	struct lima_drm_priv *priv = file->driver_priv;
+	struct lima_ctx_mgr *ctx_mgr = &priv->ctx_mgr;
+	u64 usage[lima_pipe_num];
+
+	lima_ctx_mgr_usage(ctx_mgr, usage);
+
+	/*
+	 * For a description of the text output format used here, see
+	 * Documentation/gpu/drm-usage-stats.rst.
+	 */
+	seq_printf(m, "drm-driver:\t%s\n", dev->driver->name);
+	seq_printf(m, "drm-client-id:\t%u\n", priv->id);
+	for (int i = 0; i < lima_pipe_num; i++) {
+		struct lima_sched_pipe *pipe = &ldev->pipe[i];
+		struct drm_gpu_scheduler *sched = &pipe->base;
+
+		seq_printf(m, "drm-engine-%s:\t%llu ns\n", sched->name, usage[i]);
+	}
+}
+
+static const struct file_operations lima_drm_driver_fops = {
+	.owner = THIS_MODULE,
+	DRM_GEM_FOPS,
+	.show_fdinfo = lima_drm_driver_show_fdinfo,
+};
 
 /*
  * Changelog:
Signature · 1 line
2.39.2
maintainer
#5 lore raw

Re: [PATCH 3/3] drm/lima: add show_fdinfo for drm usage stats

Quoted 16 lines · Erico Nunes

This exposes an accumulated active time per client via the fdinfo infrastructure per execution engine, following Documentation/gpu/drm-usage-stats.rst.
In lima, the exposed execution engines are gp and pp.

---
 drivers/gpu/drm/lima/lima_drv.c | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)
drivers/gpu/drm/lima/lima_drv.c +0 -0
index d23c0b77a252..c044a31493a4 100644

drivers/gpu/drm/lima/lima_drv.c static const struct drm_ioctl_desc lima_drm_driver_ioctls[] = { · line 268

Quoted 9 lines
drivers/gpu/drm/lima/lima_drv.c +5 -1
@@ -261,7 +261,36 @@ static const struct drm_ioctl_desc lima_drm_driver_ioctls[] = {
        DRM_IOCTL_DEF_DRV(LIMA_CTX_FREE, lima_ioctl_ctx_free, DRM_RENDER_ALLOW),
 };
 
-DEFINE_DRM_GEM_FOPS(lima_drm_driver_fops);
+static void lima_drm_driver_show_fdinfo(struct seq_file *m, struct file *filp)
+{
+       struct drm_file *file = filp->private_data;
+       struct drm_device *dev = file->minor->dev;
+       struct lima_device *ldev = dev->dev_private;

Can use to_lima_dev().

Quoted 31 lines
drivers/gpu/drm/lima/lima_drv.c +25 -1
+       struct lima_drm_priv *priv = file->driver_priv;
+       struct lima_ctx_mgr *ctx_mgr = &priv->ctx_mgr;
+       u64 usage[lima_pipe_num];
+
+       lima_ctx_mgr_usage(ctx_mgr, usage);
+
+       /*
+        * For a description of the text output format used here, see
+        * Documentation/gpu/drm-usage-stats.rst.
+        */
+       seq_printf(m, "drm-driver:\t%s\n", dev->driver->name);
+       seq_printf(m, "drm-client-id:\t%u\n", priv->id);
+       for (int i = 0; i < lima_pipe_num; i++) {
+               struct lima_sched_pipe *pipe = &ldev->pipe[i];
+               struct drm_gpu_scheduler *sched = &pipe->base;
+
+               seq_printf(m, "drm-engine-%s:\t%llu ns\n", sched->name, usage[i]);
+       }
+}
+
+static const struct file_operations lima_drm_driver_fops = {
+       .owner = THIS_MODULE,
+       DRM_GEM_FOPS,
+       .show_fdinfo = lima_drm_driver_show_fdinfo,
+};
 
 /*
  * Changelog:
--

2.39.2

maintainer Reviewed-by on the v1 series
#6 lore raw
In reply to Erico Nunes

Patch set is:

Looks like drm-misc-next does not contain "df622729ddbf drm/scheduler:
track GPU active time per entity" yet.
Will apply later.

Regards,
Qiang

Quoted 45 lines · Erico Nunes

Expose lima gp and pp usage stats through fdinfo, following Documentation/gpu/drm-usage-stats.rst.
Borrowed from these previous implementations:

"df622729ddbf drm/scheduler: track GPU active time per entity" added usage time accounting to drm scheduler, which is where the data used here comes from.

Then the main implementation is based on these etnaviv commits:
"d306788b6e1b drm/etnaviv: allocate unique ID per drm_file" and "97804a133c68 drm/etnaviv: export client GPU usage statistics via fdinfo"

Also "874442541133 drm/amdgpu: Add show_fdinfo() interface" since lima has a context manager very similar to amdgpu and all contexts created (and released) at the ctx_mgr level need to be accounted for.

Tested with the generic "gputop" tool currently available as patches to igt, a sample run with this patchset looks like this:

DRM minor 128

    PID               NAME             gp                        pp
    4322   glmark2-es2-way |█████▊                  ||██████████████████      |
    3561            weston |▎                       ||███▌                    |
    4159          Xwayland |▏                       ||▉                       |
    4154          glxgears |▏                       ||▎                       |
    3661           firefox |▏                       ||▏                       |

Erico Nunes (3):
drm/lima: add usage counting method to ctx_mgr
drm/lima: allocate unique id per drm_file
drm/lima: add show_fdinfo for drm usage stats

 drivers/gpu/drm/lima/lima_ctx.c    | 30 ++++++++++++++++++++-
 drivers/gpu/drm/lima/lima_ctx.h    |  3 +++
 drivers/gpu/drm/lima/lima_device.h |  3 +++
 drivers/gpu/drm/lima/lima_drv.c    | 43 +++++++++++++++++++++++++++++-
 drivers/gpu/drm/lima/lima_drv.h    |  1 +
 5 files changed, 78 insertions(+), 2 deletions(-)

--
2.39.2

maintainer Applied
#7 lore raw

Applied to drm-misc-next.

Quoted 57 lines · Qiang Yu

Patch set is:

Looks like drm-misc-next does not contain "df622729ddbf drm/scheduler:
track GPU active time per entity" yet.
Will apply later.

Regards,
Qiang

Quoted 45 lines · Erico Nunes

Expose lima gp and pp usage stats through fdinfo, following Documentation/gpu/drm-usage-stats.rst.
Borrowed from these previous implementations:

"df622729ddbf drm/scheduler: track GPU active time per entity" added usage time accounting to drm scheduler, which is where the data used here comes from.

Then the main implementation is based on these etnaviv commits:
"d306788b6e1b drm/etnaviv: allocate unique ID per drm_file" and "97804a133c68 drm/etnaviv: export client GPU usage statistics via fdinfo"

Also "874442541133 drm/amdgpu: Add show_fdinfo() interface" since lima has a context manager very similar to amdgpu and all contexts created (and released) at the ctx_mgr level need to be accounted for.

Tested with the generic "gputop" tool currently available as patches to igt, a sample run with this patchset looks like this:

DRM minor 128

    PID               NAME             gp                        pp
    4322   glmark2-es2-way |█████▊                  ||██████████████████      |
    3561            weston |▎                       ||███▌                    |
    4159          Xwayland |▏                       ||▉                       |
    4154          glxgears |▏                       ||▎                       |
    3661           firefox |▏                       ||▏                       |

Erico Nunes (3):
drm/lima: add usage counting method to ctx_mgr
drm/lima: allocate unique id per drm_file
drm/lima: add show_fdinfo for drm usage stats

 drivers/gpu/drm/lima/lima_ctx.c    | 30 ++++++++++++++++++++-
 drivers/gpu/drm/lima/lima_ctx.h    |  3 +++
 drivers/gpu/drm/lima/lima_device.h |  3 +++
 drivers/gpu/drm/lima/lima_drv.c    | 43 +++++++++++++++++++++++++++++-
 drivers/gpu/drm/lima/lima_drv.h    |  1 +
 5 files changed, 78 insertions(+), 2 deletions(-)

--
2.39.2

#8 lore raw

Am Sonntag, dem 02.04.2023 um 18:22 +0800 schrieb Qiang Yu:

Quoted 2 lines

Applied to drm-misc-next.

"df622729ddbf drm/scheduler: track GPU active time per entity" had to be reverted due to it introducing a use after free. I guess this patchset now conflicts with the revert.

Regards,
Lucas

Quoted 58 lines · Qiang Yu
Quoted 57 lines

Patch set is:

Looks like drm-misc-next does not contain "df622729ddbf drm/scheduler:
track GPU active time per entity" yet.
Will apply later.

Regards,
Qiang

Quoted 45 lines · Erico Nunes

Expose lima gp and pp usage stats through fdinfo, following Documentation/gpu/drm-usage-stats.rst.
Borrowed from these previous implementations:

"df622729ddbf drm/scheduler: track GPU active time per entity" added usage time accounting to drm scheduler, which is where the data used here comes from.

Then the main implementation is based on these etnaviv commits:
"d306788b6e1b drm/etnaviv: allocate unique ID per drm_file" and "97804a133c68 drm/etnaviv: export client GPU usage statistics via fdinfo"

Also "874442541133 drm/amdgpu: Add show_fdinfo() interface" since lima has a context manager very similar to amdgpu and all contexts created (and released) at the ctx_mgr level need to be accounted for.

Tested with the generic "gputop" tool currently available as patches to igt, a sample run with this patchset looks like this:

DRM minor 128

    PID               NAME             gp                        pp
    4322   glmark2-es2-way |█████▊                  ||██████████████████      |
    3561            weston |▎                       ||███▌                    |
    4159          Xwayland |▏                       ||▉                       |
    4154          glxgears |▏                       ||▎                       |
    3661           firefox |▏                       ||▏                       |

Erico Nunes (3):
drm/lima: add usage counting method to ctx_mgr
drm/lima: allocate unique id per drm_file
drm/lima: add show_fdinfo for drm usage stats

 drivers/gpu/drm/lima/lima_ctx.c    | 30 ++++++++++++++++++++-
 drivers/gpu/drm/lima/lima_ctx.h    |  3 +++
 drivers/gpu/drm/lima/lima_device.h |  3 +++
 drivers/gpu/drm/lima/lima_drv.c    | 43 +++++++++++++++++++++++++++++-
 drivers/gpu/drm/lima/lima_drv.h    |  1 +
 5 files changed, 78 insertions(+), 2 deletions(-)

--
2.39.2

maintainer
#9 lore raw
Quoted 4 lines

"df622729ddbf drm/scheduler: track GPU active time per entity" had to be reverted due to it introducing a use after free. I guess this patchset now conflicts with the revert.

I do get some build fail message on other branch. Do I need to revert this patchset on drm-misc-next or left to branch maintainer to decide whether to pick this patchset upstream?

Regards,
Qiang

Quoted 60 lines
Quoted 59 lines · Qiang Yu
Quoted 57 lines

Patch set is:

Looks like drm-misc-next does not contain "df622729ddbf drm/scheduler:
track GPU active time per entity" yet.
Will apply later.

Regards,
Qiang

Quoted 45 lines · Erico Nunes

Expose lima gp and pp usage stats through fdinfo, following Documentation/gpu/drm-usage-stats.rst.
Borrowed from these previous implementations:

"df622729ddbf drm/scheduler: track GPU active time per entity" added usage time accounting to drm scheduler, which is where the data used here comes from.

Then the main implementation is based on these etnaviv commits:
"d306788b6e1b drm/etnaviv: allocate unique ID per drm_file" and "97804a133c68 drm/etnaviv: export client GPU usage statistics via fdinfo"

Also "874442541133 drm/amdgpu: Add show_fdinfo() interface" since lima has a context manager very similar to amdgpu and all contexts created (and released) at the ctx_mgr level need to be accounted for.

Tested with the generic "gputop" tool currently available as patches to igt, a sample run with this patchset looks like this:

DRM minor 128

    PID               NAME             gp                        pp
    4322   glmark2-es2-way |█████▊                  ||██████████████████      |
    3561            weston |▎                       ||███▌                    |
    4159          Xwayland |▏                       ||▉                       |
    4154          glxgears |▏                       ||▎                       |
    3661           firefox |▏                       ||▏                       |

Erico Nunes (3):
drm/lima: add usage counting method to ctx_mgr
drm/lima: allocate unique id per drm_file
drm/lima: add show_fdinfo for drm usage stats

 drivers/gpu/drm/lima/lima_ctx.c    | 30 ++++++++++++++++++++-
 drivers/gpu/drm/lima/lima_ctx.h    |  3 +++
 drivers/gpu/drm/lima/lima_device.h |  3 +++
 drivers/gpu/drm/lima/lima_drv.c    | 43 +++++++++++++++++++++++++++++-
 drivers/gpu/drm/lima/lima_drv.h    |  1 +
 5 files changed, 78 insertions(+), 2 deletions(-)

--
2.39.2