2023-04-11 22:59:24

by Rob Clark

[permalink] [raw]
Subject: [PATCH v3 5/7] drm/etnaviv: Switch to fdinfo helper

From: Rob Clark <[email protected]>

Signed-off-by: Rob Clark <[email protected]>
---
drivers/gpu/drm/etnaviv/etnaviv_drv.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
index 44ca803237a5..170000d6af94 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
@@ -476,9 +476,8 @@ static const struct drm_ioctl_desc etnaviv_ioctls[] = {
ETNA_IOCTL(PM_QUERY_SIG, pm_query_sig, DRM_RENDER_ALLOW),
};

-static void etnaviv_fop_show_fdinfo(struct seq_file *m, struct file *f)
+static void etnaviv_fop_show_fdinfo(struct drm_printer *p, struct drm_file *file)
{
- struct drm_file *file = f->private_data;
struct drm_device *dev = file->minor->dev;
struct etnaviv_drm_private *priv = dev->dev_private;
struct etnaviv_file_private *ctx = file->driver_priv;
@@ -487,8 +486,6 @@ static void etnaviv_fop_show_fdinfo(struct seq_file *m, struct file *f)
* 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", ctx->id);

for (int i = 0; i < ETNA_MAX_PIPES; i++) {
struct etnaviv_gpu *gpu = priv->gpu[i];
@@ -507,7 +504,7 @@ static void etnaviv_fop_show_fdinfo(struct seq_file *m, struct file *f)
cur = snprintf(engine + cur, sizeof(engine) - cur,
"%sNN", cur ? "/" : "");

- seq_printf(m, "drm-engine-%s:\t%llu ns\n", engine,
+ drm_printf(p, "drm-engine-%s:\t%llu ns\n", engine,
ctx->sched_entity[i].elapsed_ns);
}
}
@@ -515,7 +512,7 @@ static void etnaviv_fop_show_fdinfo(struct seq_file *m, struct file *f)
static const struct file_operations fops = {
.owner = THIS_MODULE,
DRM_GEM_FOPS,
- .show_fdinfo = etnaviv_fop_show_fdinfo,
+ .show_fdinfo = drm_fop_show_fdinfo,
};

static const struct drm_driver etnaviv_drm_driver = {
@@ -529,6 +526,7 @@ static const struct drm_driver etnaviv_drm_driver = {
#ifdef CONFIG_DEBUG_FS
.debugfs_init = etnaviv_debugfs_init,
#endif
+ .show_fdinfo = etnaviv_fop_show_fdinfo,
.ioctls = etnaviv_ioctls,
.num_ioctls = DRM_ETNAVIV_NUM_IOCTLS,
.fops = &fops,
--
2.39.2


2023-04-12 08:07:46

by Daniel Vetter

[permalink] [raw]
Subject: Re: [PATCH v3 5/7] drm/etnaviv: Switch to fdinfo helper

On Tue, Apr 11, 2023 at 03:56:10PM -0700, Rob Clark wrote:
> From: Rob Clark <[email protected]>
>
> Signed-off-by: Rob Clark <[email protected]>

You're on an old tree, this got reverted. But I'm kinda wondering whether
another patch on top shouldn't just includ the drm_show_fdinfo in
DRM_GEM_FOPS macro ... There's really no good reasons for drivers to not
have this I think?
-Daniel

> ---
> drivers/gpu/drm/etnaviv/etnaviv_drv.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> index 44ca803237a5..170000d6af94 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> @@ -476,9 +476,8 @@ static const struct drm_ioctl_desc etnaviv_ioctls[] = {
> ETNA_IOCTL(PM_QUERY_SIG, pm_query_sig, DRM_RENDER_ALLOW),
> };
>
> -static void etnaviv_fop_show_fdinfo(struct seq_file *m, struct file *f)
> +static void etnaviv_fop_show_fdinfo(struct drm_printer *p, struct drm_file *file)
> {
> - struct drm_file *file = f->private_data;
> struct drm_device *dev = file->minor->dev;
> struct etnaviv_drm_private *priv = dev->dev_private;
> struct etnaviv_file_private *ctx = file->driver_priv;
> @@ -487,8 +486,6 @@ static void etnaviv_fop_show_fdinfo(struct seq_file *m, struct file *f)
> * 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", ctx->id);
>
> for (int i = 0; i < ETNA_MAX_PIPES; i++) {
> struct etnaviv_gpu *gpu = priv->gpu[i];
> @@ -507,7 +504,7 @@ static void etnaviv_fop_show_fdinfo(struct seq_file *m, struct file *f)
> cur = snprintf(engine + cur, sizeof(engine) - cur,
> "%sNN", cur ? "/" : "");
>
> - seq_printf(m, "drm-engine-%s:\t%llu ns\n", engine,
> + drm_printf(p, "drm-engine-%s:\t%llu ns\n", engine,
> ctx->sched_entity[i].elapsed_ns);
> }
> }
> @@ -515,7 +512,7 @@ static void etnaviv_fop_show_fdinfo(struct seq_file *m, struct file *f)
> static const struct file_operations fops = {
> .owner = THIS_MODULE,
> DRM_GEM_FOPS,
> - .show_fdinfo = etnaviv_fop_show_fdinfo,
> + .show_fdinfo = drm_fop_show_fdinfo,
> };
>
> static const struct drm_driver etnaviv_drm_driver = {
> @@ -529,6 +526,7 @@ static const struct drm_driver etnaviv_drm_driver = {
> #ifdef CONFIG_DEBUG_FS
> .debugfs_init = etnaviv_debugfs_init,
> #endif
> + .show_fdinfo = etnaviv_fop_show_fdinfo,
> .ioctls = etnaviv_ioctls,
> .num_ioctls = DRM_ETNAVIV_NUM_IOCTLS,
> .fops = &fops,
> --
> 2.39.2
>

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

2023-04-12 22:26:46

by Rob Clark

[permalink] [raw]
Subject: Re: [PATCH v3 5/7] drm/etnaviv: Switch to fdinfo helper

On Wed, Apr 12, 2023 at 12:59 AM Daniel Vetter <[email protected]> wrote:
>
> On Tue, Apr 11, 2023 at 03:56:10PM -0700, Rob Clark wrote:
> > From: Rob Clark <[email protected]>
> >
> > Signed-off-by: Rob Clark <[email protected]>
>
> You're on an old tree, this got reverted. But I'm kinda wondering whether
> another patch on top shouldn't just includ the drm_show_fdinfo in
> DRM_GEM_FOPS macro ... There's really no good reasons for drivers to not
> have this I think?

oh, I'm roughly on msm-next, so didn't see the revert.. I'll drop this
one. But with things in flux, this is why I decided against adding it
to DRM_GEM_FOPS. Ie. we should do that as a followup cleanup step
once everyone is moved over to the new helpers to avoid conflicts or
build breaks when merging things via different driver trees

BR,
-R

> -Daniel
>
> > ---
> > drivers/gpu/drm/etnaviv/etnaviv_drv.c | 10 ++++------
> > 1 file changed, 4 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> > index 44ca803237a5..170000d6af94 100644
> > --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> > +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> > @@ -476,9 +476,8 @@ static const struct drm_ioctl_desc etnaviv_ioctls[] = {
> > ETNA_IOCTL(PM_QUERY_SIG, pm_query_sig, DRM_RENDER_ALLOW),
> > };
> >
> > -static void etnaviv_fop_show_fdinfo(struct seq_file *m, struct file *f)
> > +static void etnaviv_fop_show_fdinfo(struct drm_printer *p, struct drm_file *file)
> > {
> > - struct drm_file *file = f->private_data;
> > struct drm_device *dev = file->minor->dev;
> > struct etnaviv_drm_private *priv = dev->dev_private;
> > struct etnaviv_file_private *ctx = file->driver_priv;
> > @@ -487,8 +486,6 @@ static void etnaviv_fop_show_fdinfo(struct seq_file *m, struct file *f)
> > * 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", ctx->id);
> >
> > for (int i = 0; i < ETNA_MAX_PIPES; i++) {
> > struct etnaviv_gpu *gpu = priv->gpu[i];
> > @@ -507,7 +504,7 @@ static void etnaviv_fop_show_fdinfo(struct seq_file *m, struct file *f)
> > cur = snprintf(engine + cur, sizeof(engine) - cur,
> > "%sNN", cur ? "/" : "");
> >
> > - seq_printf(m, "drm-engine-%s:\t%llu ns\n", engine,
> > + drm_printf(p, "drm-engine-%s:\t%llu ns\n", engine,
> > ctx->sched_entity[i].elapsed_ns);
> > }
> > }
> > @@ -515,7 +512,7 @@ static void etnaviv_fop_show_fdinfo(struct seq_file *m, struct file *f)
> > static const struct file_operations fops = {
> > .owner = THIS_MODULE,
> > DRM_GEM_FOPS,
> > - .show_fdinfo = etnaviv_fop_show_fdinfo,
> > + .show_fdinfo = drm_fop_show_fdinfo,
> > };
> >
> > static const struct drm_driver etnaviv_drm_driver = {
> > @@ -529,6 +526,7 @@ static const struct drm_driver etnaviv_drm_driver = {
> > #ifdef CONFIG_DEBUG_FS
> > .debugfs_init = etnaviv_debugfs_init,
> > #endif
> > + .show_fdinfo = etnaviv_fop_show_fdinfo,
> > .ioctls = etnaviv_ioctls,
> > .num_ioctls = DRM_ETNAVIV_NUM_IOCTLS,
> > .fops = &fops,
> > --
> > 2.39.2
> >
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch