* [PATCH v3 1/2] drm: Add DRM_GEM_FOPS
@ 2022-06-09 17:42 Rob Clark
2022-06-09 17:42 ` [PATCH v3 2/2] drm/msm: Expose client engine utilization via fdinfo Rob Clark
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Rob Clark @ 2022-06-09 17:42 UTC (permalink / raw)
To: dri-devel
Cc: freedreno, linux-arm-msm, Tvrtko Ursulin, Thomas Zimmermann,
Chris Healy, Rob Clark, Maarten Lankhorst, Maxime Ripard,
David Airlie, Daniel Vetter, open list
From: Rob Clark <robdclark@chromium.org>
The DEFINE_DRM_GEM_FOPS() helper is a bit limiting if a driver wants to
provide additional file ops, like show_fdinfo().
v2: Split out DRM_GEM_FOPS instead of making DEFINE_DRM_GEM_FOPS
varardic
v3: nits
Signed-off-by: Rob Clark <robdclark@chromium.org>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
---
include/drm/drm_gem.h | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
index 9d7c61a122dc..87cffc9efa85 100644
--- a/include/drm/drm_gem.h
+++ b/include/drm/drm_gem.h
@@ -314,6 +314,23 @@ struct drm_gem_object {
const struct drm_gem_object_funcs *funcs;
};
+/**
+ * DRM_GEM_FOPS - Default drm GEM file operations
+ *
+ * This macro provides a shorthand for setting the GEM file ops in the
+ * &file_operations structure. If all you need are the default ops, use
+ * DEFINE_DRM_GEM_FOPS instead.
+ */
+#define DRM_GEM_FOPS \
+ .open = drm_open,\
+ .release = drm_release,\
+ .unlocked_ioctl = drm_ioctl,\
+ .compat_ioctl = drm_compat_ioctl,\
+ .poll = drm_poll,\
+ .read = drm_read,\
+ .llseek = noop_llseek,\
+ .mmap = drm_gem_mmap
+
/**
* DEFINE_DRM_GEM_FOPS() - macro to generate file operations for GEM drivers
* @name: name for the generated structure
@@ -330,14 +347,7 @@ struct drm_gem_object {
#define DEFINE_DRM_GEM_FOPS(name) \
static const struct file_operations name = {\
.owner = THIS_MODULE,\
- .open = drm_open,\
- .release = drm_release,\
- .unlocked_ioctl = drm_ioctl,\
- .compat_ioctl = drm_compat_ioctl,\
- .poll = drm_poll,\
- .read = drm_read,\
- .llseek = noop_llseek,\
- .mmap = drm_gem_mmap,\
+ DRM_GEM_FOPS,\
}
void drm_gem_object_release(struct drm_gem_object *obj);
--
2.36.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v3 2/2] drm/msm: Expose client engine utilization via fdinfo 2022-06-09 17:42 [PATCH v3 1/2] drm: Add DRM_GEM_FOPS Rob Clark @ 2022-06-09 17:42 ` Rob Clark 2022-06-15 12:44 ` Dmitry Baryshkov 2022-06-15 12:52 ` Tvrtko Ursulin 2022-06-15 12:45 ` [PATCH v3 1/2] drm: Add DRM_GEM_FOPS Dmitry Baryshkov 2022-06-24 20:48 ` Daniel Vetter 2 siblings, 2 replies; 8+ messages in thread From: Rob Clark @ 2022-06-09 17:42 UTC (permalink / raw) To: dri-devel Cc: freedreno, linux-arm-msm, Tvrtko Ursulin, Thomas Zimmermann, Chris Healy, Rob Clark, David Airlie, Daniel Vetter, Maarten Lankhorst, Maxime Ripard, Jonathan Corbet, Rob Clark, Abhinav Kumar, Dmitry Baryshkov, Sean Paul, open list:DOCUMENTATION, open list From: Rob Clark <robdclark@chromium.org> Similar to AMD commit 874442541133 ("drm/amdgpu: Add show_fdinfo() interface"), using the infrastructure added in previous patches, we add basic client info and GPU engine utilisation for msm. Example output: # cat /proc/`pgrep glmark2`/fdinfo/6 pos: 0 flags: 02400002 mnt_id: 21 ino: 162 drm-driver: msm drm-client-id: 7 drm-engine-gpu: 1734371319 ns drm-cycles-gpu: 1153645024 drm-maxfreq-gpu: 800000000 Hz See also: https://patchwork.freedesktop.org/patch/468505/ v2: Add dev-maxfreq-$engine and update drm-usage-stats.rst v3: spelling and compiler warning Signed-off-by: Rob Clark <robdclark@chromium.org> --- Documentation/gpu/drm-usage-stats.rst | 21 +++++++++++++++++++++ drivers/gpu/drm/msm/msm_drv.c | 19 ++++++++++++++++++- drivers/gpu/drm/msm/msm_gpu.c | 21 +++++++++++++++++++-- drivers/gpu/drm/msm/msm_gpu.h | 19 +++++++++++++++++++ 4 files changed, 77 insertions(+), 3 deletions(-) diff --git a/Documentation/gpu/drm-usage-stats.rst b/Documentation/gpu/drm-usage-stats.rst index 6c9f166a8d6f..92c5117368d7 100644 --- a/Documentation/gpu/drm-usage-stats.rst +++ b/Documentation/gpu/drm-usage-stats.rst @@ -105,6 +105,27 @@ object belong to this client, in the respective memory region. Default unit shall be bytes with optional unit specifiers of 'KiB' or 'MiB' indicating kibi- or mebi-bytes. +- drm-cycles-<str> <uint> + +Engine identifier string must be the same as the one specified in the +drm-engine-<str> tag and shall contain the number of busy cycles for the given +engine. + +Values are not required to be constantly monotonic if it makes the driver +implementation easier, but are required to catch up with the previously reported +larger value within a reasonable period. Upon observing a value lower than what +was previously read, userspace is expected to stay with that larger previous +value until a monotonic update is seen. + +- drm-maxfreq-<str> <uint> [Hz|MHz|KHz] + +Engine identifier string must be the same as the one specified in the +drm-engine-<str> tag and shall contain the maximum frequency for the given +engine. Taken together with drm-cycles-<str>, this can be used to calculate +percentage utilization of the engine, whereas drm-engine-<str> only reflects +time active without considering what frequency the engine is operating as a +percentage of it's maximum frequency. + =============================== Driver specific implementations =============================== diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 14ab9a627d8b..57a66093e671 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -948,7 +948,24 @@ static const struct drm_ioctl_desc msm_ioctls[] = { DRM_IOCTL_DEF_DRV(MSM_SUBMITQUEUE_QUERY, msm_ioctl_submitqueue_query, DRM_RENDER_ALLOW), }; -DEFINE_DRM_GEM_FOPS(fops); +static void msm_fop_show_fdinfo(struct seq_file *m, struct file *f) +{ + struct drm_file *file = f->private_data; + struct drm_device *dev = file->minor->dev; + struct msm_drm_private *priv = dev->dev_private; + struct drm_printer p = drm_seq_file_printer(m); + + if (!priv->gpu) + return; + + msm_gpu_show_fdinfo(priv->gpu, file->driver_priv, &p); +} + +static const struct file_operations fops = { + .owner = THIS_MODULE, + DRM_GEM_FOPS, + .show_fdinfo = msm_fop_show_fdinfo, +}; static const struct drm_driver msm_driver = { .driver_features = DRIVER_GEM | diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c index 244511f85044..f99292eaf529 100644 --- a/drivers/gpu/drm/msm/msm_gpu.c +++ b/drivers/gpu/drm/msm/msm_gpu.c @@ -4,6 +4,8 @@ * Author: Rob Clark <robdclark@gmail.com> */ +#include "drm/drm_drv.h" + #include "msm_gpu.h" #include "msm_gem.h" #include "msm_mmu.h" @@ -146,6 +148,16 @@ int msm_gpu_pm_suspend(struct msm_gpu *gpu) return 0; } +void msm_gpu_show_fdinfo(struct msm_gpu *gpu, struct msm_file_private *ctx, + struct drm_printer *p) +{ + drm_printf(p, "drm-driver:\t%s\n", gpu->dev->driver->name); + drm_printf(p, "drm-client-id:\t%u\n", ctx->seqno); + drm_printf(p, "drm-engine-gpu:\t%llu ns\n", ctx->elapsed_ns); + drm_printf(p, "drm-cycles-gpu:\t%llu\n", ctx->cycles); + drm_printf(p, "drm-maxfreq-gpu:\t%u Hz\n", gpu->fast_rate); +} + int msm_gpu_hw_init(struct msm_gpu *gpu) { int ret; @@ -652,7 +664,7 @@ static void retire_submit(struct msm_gpu *gpu, struct msm_ringbuffer *ring, { int index = submit->seqno % MSM_GPU_SUBMIT_STATS_COUNT; volatile struct msm_gpu_submit_stats *stats; - u64 elapsed, clock = 0; + u64 elapsed, clock = 0, cycles; unsigned long flags; stats = &ring->memptrs->stats[index]; @@ -660,12 +672,17 @@ static void retire_submit(struct msm_gpu *gpu, struct msm_ringbuffer *ring, elapsed = (stats->alwayson_end - stats->alwayson_start) * 10000; do_div(elapsed, 192); + cycles = stats->cpcycles_end - stats->cpcycles_start; + /* Calculate the clock frequency from the number of CP cycles */ if (elapsed) { - clock = (stats->cpcycles_end - stats->cpcycles_start) * 1000; + clock = cycles * 1000; do_div(clock, elapsed); } + submit->queue->ctx->elapsed_ns += elapsed; + submit->queue->ctx->cycles += cycles; + trace_msm_gpu_submit_retired(submit, elapsed, clock, stats->alwayson_start, stats->alwayson_end); diff --git a/drivers/gpu/drm/msm/msm_gpu.h b/drivers/gpu/drm/msm/msm_gpu.h index 6def00883046..4911943ba53b 100644 --- a/drivers/gpu/drm/msm/msm_gpu.h +++ b/drivers/gpu/drm/msm/msm_gpu.h @@ -361,6 +361,22 @@ struct msm_file_private { /** cmdline: Overridden task cmdline, see MSM_PARAM_CMDLINE */ char *cmdline; + /** + * elapsed: + * + * The total (cumulative) elapsed time GPU was busy with rendering + * from this context in ns. + */ + uint64_t elapsed_ns; + + /** + * cycles: + * + * The total (cumulative) GPU cycles elapsed attributed to this + * context. + */ + uint64_t cycles; + /** * entities: * @@ -544,6 +560,9 @@ static inline void gpu_write64(struct msm_gpu *gpu, u32 lo, u32 hi, u64 val) int msm_gpu_pm_suspend(struct msm_gpu *gpu); int msm_gpu_pm_resume(struct msm_gpu *gpu); +void msm_gpu_show_fdinfo(struct msm_gpu *gpu, struct msm_file_private *ctx, + struct drm_printer *p); + int msm_submitqueue_init(struct drm_device *drm, struct msm_file_private *ctx); struct msm_gpu_submitqueue *msm_submitqueue_get(struct msm_file_private *ctx, u32 id); -- 2.36.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v3 2/2] drm/msm: Expose client engine utilization via fdinfo 2022-06-09 17:42 ` [PATCH v3 2/2] drm/msm: Expose client engine utilization via fdinfo Rob Clark @ 2022-06-15 12:44 ` Dmitry Baryshkov 2022-06-15 12:52 ` Tvrtko Ursulin 1 sibling, 0 replies; 8+ messages in thread From: Dmitry Baryshkov @ 2022-06-15 12:44 UTC (permalink / raw) To: Rob Clark, dri-devel Cc: freedreno, linux-arm-msm, Tvrtko Ursulin, Thomas Zimmermann, Chris Healy, Rob Clark, David Airlie, Daniel Vetter, Maarten Lankhorst, Maxime Ripard, Jonathan Corbet, Abhinav Kumar, Sean Paul, open list:DOCUMENTATION, open list On 09/06/2022 20:42, Rob Clark wrote: > From: Rob Clark <robdclark@chromium.org> > > Similar to AMD commit > 874442541133 ("drm/amdgpu: Add show_fdinfo() interface"), using the > infrastructure added in previous patches, we add basic client info > and GPU engine utilisation for msm. > > Example output: > > # cat /proc/`pgrep glmark2`/fdinfo/6 > pos: 0 > flags: 02400002 > mnt_id: 21 > ino: 162 > drm-driver: msm > drm-client-id: 7 > drm-engine-gpu: 1734371319 ns > drm-cycles-gpu: 1153645024 > drm-maxfreq-gpu: 800000000 Hz > > See also: https://patchwork.freedesktop.org/patch/468505/ > > v2: Add dev-maxfreq-$engine and update drm-usage-stats.rst > v3: spelling and compiler warning > > Signed-off-by: Rob Clark <robdclark@chromium.org> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> > --- > Documentation/gpu/drm-usage-stats.rst | 21 +++++++++++++++++++++ > drivers/gpu/drm/msm/msm_drv.c | 19 ++++++++++++++++++- > drivers/gpu/drm/msm/msm_gpu.c | 21 +++++++++++++++++++-- > drivers/gpu/drm/msm/msm_gpu.h | 19 +++++++++++++++++++ > 4 files changed, 77 insertions(+), 3 deletions(-) > > diff --git a/Documentation/gpu/drm-usage-stats.rst b/Documentation/gpu/drm-usage-stats.rst > index 6c9f166a8d6f..92c5117368d7 100644 > --- a/Documentation/gpu/drm-usage-stats.rst > +++ b/Documentation/gpu/drm-usage-stats.rst > @@ -105,6 +105,27 @@ object belong to this client, in the respective memory region. > Default unit shall be bytes with optional unit specifiers of 'KiB' or 'MiB' > indicating kibi- or mebi-bytes. > > +- drm-cycles-<str> <uint> > + > +Engine identifier string must be the same as the one specified in the > +drm-engine-<str> tag and shall contain the number of busy cycles for the given > +engine. > + > +Values are not required to be constantly monotonic if it makes the driver > +implementation easier, but are required to catch up with the previously reported > +larger value within a reasonable period. Upon observing a value lower than what > +was previously read, userspace is expected to stay with that larger previous > +value until a monotonic update is seen. > + > +- drm-maxfreq-<str> <uint> [Hz|MHz|KHz] > + > +Engine identifier string must be the same as the one specified in the > +drm-engine-<str> tag and shall contain the maximum frequency for the given > +engine. Taken together with drm-cycles-<str>, this can be used to calculate > +percentage utilization of the engine, whereas drm-engine-<str> only reflects > +time active without considering what frequency the engine is operating as a > +percentage of it's maximum frequency. > + > =============================== > Driver specific implementations > =============================== > diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c > index 14ab9a627d8b..57a66093e671 100644 > --- a/drivers/gpu/drm/msm/msm_drv.c > +++ b/drivers/gpu/drm/msm/msm_drv.c > @@ -948,7 +948,24 @@ static const struct drm_ioctl_desc msm_ioctls[] = { > DRM_IOCTL_DEF_DRV(MSM_SUBMITQUEUE_QUERY, msm_ioctl_submitqueue_query, DRM_RENDER_ALLOW), > }; > > -DEFINE_DRM_GEM_FOPS(fops); > +static void msm_fop_show_fdinfo(struct seq_file *m, struct file *f) > +{ > + struct drm_file *file = f->private_data; > + struct drm_device *dev = file->minor->dev; > + struct msm_drm_private *priv = dev->dev_private; > + struct drm_printer p = drm_seq_file_printer(m); > + > + if (!priv->gpu) > + return; > + > + msm_gpu_show_fdinfo(priv->gpu, file->driver_priv, &p); > +} > + > +static const struct file_operations fops = { > + .owner = THIS_MODULE, > + DRM_GEM_FOPS, > + .show_fdinfo = msm_fop_show_fdinfo, > +}; > > static const struct drm_driver msm_driver = { > .driver_features = DRIVER_GEM | > diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c > index 244511f85044..f99292eaf529 100644 > --- a/drivers/gpu/drm/msm/msm_gpu.c > +++ b/drivers/gpu/drm/msm/msm_gpu.c > @@ -4,6 +4,8 @@ > * Author: Rob Clark <robdclark@gmail.com> > */ > > +#include "drm/drm_drv.h" > + > #include "msm_gpu.h" > #include "msm_gem.h" > #include "msm_mmu.h" > @@ -146,6 +148,16 @@ int msm_gpu_pm_suspend(struct msm_gpu *gpu) > return 0; > } > > +void msm_gpu_show_fdinfo(struct msm_gpu *gpu, struct msm_file_private *ctx, > + struct drm_printer *p) > +{ > + drm_printf(p, "drm-driver:\t%s\n", gpu->dev->driver->name); > + drm_printf(p, "drm-client-id:\t%u\n", ctx->seqno); > + drm_printf(p, "drm-engine-gpu:\t%llu ns\n", ctx->elapsed_ns); > + drm_printf(p, "drm-cycles-gpu:\t%llu\n", ctx->cycles); > + drm_printf(p, "drm-maxfreq-gpu:\t%u Hz\n", gpu->fast_rate); > +} > + > int msm_gpu_hw_init(struct msm_gpu *gpu) > { > int ret; > @@ -652,7 +664,7 @@ static void retire_submit(struct msm_gpu *gpu, struct msm_ringbuffer *ring, > { > int index = submit->seqno % MSM_GPU_SUBMIT_STATS_COUNT; > volatile struct msm_gpu_submit_stats *stats; > - u64 elapsed, clock = 0; > + u64 elapsed, clock = 0, cycles; > unsigned long flags; > > stats = &ring->memptrs->stats[index]; > @@ -660,12 +672,17 @@ static void retire_submit(struct msm_gpu *gpu, struct msm_ringbuffer *ring, > elapsed = (stats->alwayson_end - stats->alwayson_start) * 10000; > do_div(elapsed, 192); > > + cycles = stats->cpcycles_end - stats->cpcycles_start; > + > /* Calculate the clock frequency from the number of CP cycles */ > if (elapsed) { > - clock = (stats->cpcycles_end - stats->cpcycles_start) * 1000; > + clock = cycles * 1000; > do_div(clock, elapsed); > } > > + submit->queue->ctx->elapsed_ns += elapsed; > + submit->queue->ctx->cycles += cycles; > + > trace_msm_gpu_submit_retired(submit, elapsed, clock, > stats->alwayson_start, stats->alwayson_end); > > diff --git a/drivers/gpu/drm/msm/msm_gpu.h b/drivers/gpu/drm/msm/msm_gpu.h > index 6def00883046..4911943ba53b 100644 > --- a/drivers/gpu/drm/msm/msm_gpu.h > +++ b/drivers/gpu/drm/msm/msm_gpu.h > @@ -361,6 +361,22 @@ struct msm_file_private { > /** cmdline: Overridden task cmdline, see MSM_PARAM_CMDLINE */ > char *cmdline; > > + /** > + * elapsed: > + * > + * The total (cumulative) elapsed time GPU was busy with rendering > + * from this context in ns. > + */ > + uint64_t elapsed_ns; > + > + /** > + * cycles: > + * > + * The total (cumulative) GPU cycles elapsed attributed to this > + * context. > + */ > + uint64_t cycles; > + > /** > * entities: > * > @@ -544,6 +560,9 @@ static inline void gpu_write64(struct msm_gpu *gpu, u32 lo, u32 hi, u64 val) > int msm_gpu_pm_suspend(struct msm_gpu *gpu); > int msm_gpu_pm_resume(struct msm_gpu *gpu); > > +void msm_gpu_show_fdinfo(struct msm_gpu *gpu, struct msm_file_private *ctx, > + struct drm_printer *p); > + > int msm_submitqueue_init(struct drm_device *drm, struct msm_file_private *ctx); > struct msm_gpu_submitqueue *msm_submitqueue_get(struct msm_file_private *ctx, > u32 id); -- With best wishes Dmitry ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 2/2] drm/msm: Expose client engine utilization via fdinfo 2022-06-09 17:42 ` [PATCH v3 2/2] drm/msm: Expose client engine utilization via fdinfo Rob Clark 2022-06-15 12:44 ` Dmitry Baryshkov @ 2022-06-15 12:52 ` Tvrtko Ursulin 1 sibling, 0 replies; 8+ messages in thread From: Tvrtko Ursulin @ 2022-06-15 12:52 UTC (permalink / raw) To: Rob Clark, dri-devel Cc: freedreno, linux-arm-msm, Thomas Zimmermann, Chris Healy, Rob Clark, David Airlie, Daniel Vetter, Maarten Lankhorst, Maxime Ripard, Jonathan Corbet, Abhinav Kumar, Dmitry Baryshkov, Sean Paul, open list:DOCUMENTATION, open list On 09/06/2022 18:42, Rob Clark wrote: > From: Rob Clark <robdclark@chromium.org> > > Similar to AMD commit > 874442541133 ("drm/amdgpu: Add show_fdinfo() interface"), using the > infrastructure added in previous patches, we add basic client info > and GPU engine utilisation for msm. > > Example output: > > # cat /proc/`pgrep glmark2`/fdinfo/6 > pos: 0 > flags: 02400002 > mnt_id: 21 > ino: 162 > drm-driver: msm > drm-client-id: 7 > drm-engine-gpu: 1734371319 ns > drm-cycles-gpu: 1153645024 > drm-maxfreq-gpu: 800000000 Hz > > See also: https://patchwork.freedesktop.org/patch/468505/ > > v2: Add dev-maxfreq-$engine and update drm-usage-stats.rst > v3: spelling and compiler warning > > Signed-off-by: Rob Clark <robdclark@chromium.org> > --- > Documentation/gpu/drm-usage-stats.rst | 21 +++++++++++++++++++++ > drivers/gpu/drm/msm/msm_drv.c | 19 ++++++++++++++++++- > drivers/gpu/drm/msm/msm_gpu.c | 21 +++++++++++++++++++-- > drivers/gpu/drm/msm/msm_gpu.h | 19 +++++++++++++++++++ > 4 files changed, 77 insertions(+), 3 deletions(-) > > diff --git a/Documentation/gpu/drm-usage-stats.rst b/Documentation/gpu/drm-usage-stats.rst > index 6c9f166a8d6f..92c5117368d7 100644 > --- a/Documentation/gpu/drm-usage-stats.rst > +++ b/Documentation/gpu/drm-usage-stats.rst > @@ -105,6 +105,27 @@ object belong to this client, in the respective memory region. > Default unit shall be bytes with optional unit specifiers of 'KiB' or 'MiB' > indicating kibi- or mebi-bytes. > > +- drm-cycles-<str> <uint> > + > +Engine identifier string must be the same as the one specified in the > +drm-engine-<str> tag and shall contain the number of busy cycles for the given > +engine. > + > +Values are not required to be constantly monotonic if it makes the driver > +implementation easier, but are required to catch up with the previously reported > +larger value within a reasonable period. Upon observing a value lower than what > +was previously read, userspace is expected to stay with that larger previous > +value until a monotonic update is seen. > + > +- drm-maxfreq-<str> <uint> [Hz|MHz|KHz] Kilo should be lowercase, I *think*. Simplify and only document Hz? > + > +Engine identifier string must be the same as the one specified in the > +drm-engine-<str> tag and shall contain the maximum frequency for the given > +engine. Taken together with drm-cycles-<str>, this can be used to calculate > +percentage utilization of the engine, whereas drm-engine-<str> only reflects > +time active without considering what frequency the engine is operating as a > +percentage of it's maximum frequency. Slipped my mind to reply to v3.. Acked-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Regards, Tvrtko > + > =============================== > Driver specific implementations > =============================== > diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c > index 14ab9a627d8b..57a66093e671 100644 > --- a/drivers/gpu/drm/msm/msm_drv.c > +++ b/drivers/gpu/drm/msm/msm_drv.c > @@ -948,7 +948,24 @@ static const struct drm_ioctl_desc msm_ioctls[] = { > DRM_IOCTL_DEF_DRV(MSM_SUBMITQUEUE_QUERY, msm_ioctl_submitqueue_query, DRM_RENDER_ALLOW), > }; > > -DEFINE_DRM_GEM_FOPS(fops); > +static void msm_fop_show_fdinfo(struct seq_file *m, struct file *f) > +{ > + struct drm_file *file = f->private_data; > + struct drm_device *dev = file->minor->dev; > + struct msm_drm_private *priv = dev->dev_private; > + struct drm_printer p = drm_seq_file_printer(m); > + > + if (!priv->gpu) > + return; > + > + msm_gpu_show_fdinfo(priv->gpu, file->driver_priv, &p); > +} > + > +static const struct file_operations fops = { > + .owner = THIS_MODULE, > + DRM_GEM_FOPS, > + .show_fdinfo = msm_fop_show_fdinfo, > +}; > > static const struct drm_driver msm_driver = { > .driver_features = DRIVER_GEM | > diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c > index 244511f85044..f99292eaf529 100644 > --- a/drivers/gpu/drm/msm/msm_gpu.c > +++ b/drivers/gpu/drm/msm/msm_gpu.c > @@ -4,6 +4,8 @@ > * Author: Rob Clark <robdclark@gmail.com> > */ > > +#include "drm/drm_drv.h" > + > #include "msm_gpu.h" > #include "msm_gem.h" > #include "msm_mmu.h" > @@ -146,6 +148,16 @@ int msm_gpu_pm_suspend(struct msm_gpu *gpu) > return 0; > } > > +void msm_gpu_show_fdinfo(struct msm_gpu *gpu, struct msm_file_private *ctx, > + struct drm_printer *p) > +{ > + drm_printf(p, "drm-driver:\t%s\n", gpu->dev->driver->name); > + drm_printf(p, "drm-client-id:\t%u\n", ctx->seqno); > + drm_printf(p, "drm-engine-gpu:\t%llu ns\n", ctx->elapsed_ns); > + drm_printf(p, "drm-cycles-gpu:\t%llu\n", ctx->cycles); > + drm_printf(p, "drm-maxfreq-gpu:\t%u Hz\n", gpu->fast_rate); > +} > + > int msm_gpu_hw_init(struct msm_gpu *gpu) > { > int ret; > @@ -652,7 +664,7 @@ static void retire_submit(struct msm_gpu *gpu, struct msm_ringbuffer *ring, > { > int index = submit->seqno % MSM_GPU_SUBMIT_STATS_COUNT; > volatile struct msm_gpu_submit_stats *stats; > - u64 elapsed, clock = 0; > + u64 elapsed, clock = 0, cycles; > unsigned long flags; > > stats = &ring->memptrs->stats[index]; > @@ -660,12 +672,17 @@ static void retire_submit(struct msm_gpu *gpu, struct msm_ringbuffer *ring, > elapsed = (stats->alwayson_end - stats->alwayson_start) * 10000; > do_div(elapsed, 192); > > + cycles = stats->cpcycles_end - stats->cpcycles_start; > + > /* Calculate the clock frequency from the number of CP cycles */ > if (elapsed) { > - clock = (stats->cpcycles_end - stats->cpcycles_start) * 1000; > + clock = cycles * 1000; > do_div(clock, elapsed); > } > > + submit->queue->ctx->elapsed_ns += elapsed; > + submit->queue->ctx->cycles += cycles; > + > trace_msm_gpu_submit_retired(submit, elapsed, clock, > stats->alwayson_start, stats->alwayson_end); > > diff --git a/drivers/gpu/drm/msm/msm_gpu.h b/drivers/gpu/drm/msm/msm_gpu.h > index 6def00883046..4911943ba53b 100644 > --- a/drivers/gpu/drm/msm/msm_gpu.h > +++ b/drivers/gpu/drm/msm/msm_gpu.h > @@ -361,6 +361,22 @@ struct msm_file_private { > /** cmdline: Overridden task cmdline, see MSM_PARAM_CMDLINE */ > char *cmdline; > > + /** > + * elapsed: > + * > + * The total (cumulative) elapsed time GPU was busy with rendering > + * from this context in ns. > + */ > + uint64_t elapsed_ns; > + > + /** > + * cycles: > + * > + * The total (cumulative) GPU cycles elapsed attributed to this > + * context. > + */ > + uint64_t cycles; > + > /** > * entities: > * > @@ -544,6 +560,9 @@ static inline void gpu_write64(struct msm_gpu *gpu, u32 lo, u32 hi, u64 val) > int msm_gpu_pm_suspend(struct msm_gpu *gpu); > int msm_gpu_pm_resume(struct msm_gpu *gpu); > > +void msm_gpu_show_fdinfo(struct msm_gpu *gpu, struct msm_file_private *ctx, > + struct drm_printer *p); > + > int msm_submitqueue_init(struct drm_device *drm, struct msm_file_private *ctx); > struct msm_gpu_submitqueue *msm_submitqueue_get(struct msm_file_private *ctx, > u32 id); ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 1/2] drm: Add DRM_GEM_FOPS 2022-06-09 17:42 [PATCH v3 1/2] drm: Add DRM_GEM_FOPS Rob Clark 2022-06-09 17:42 ` [PATCH v3 2/2] drm/msm: Expose client engine utilization via fdinfo Rob Clark @ 2022-06-15 12:45 ` Dmitry Baryshkov 2022-06-15 13:46 ` Thomas Zimmermann 2022-06-24 20:48 ` Daniel Vetter 2 siblings, 1 reply; 8+ messages in thread From: Dmitry Baryshkov @ 2022-06-15 12:45 UTC (permalink / raw) To: Rob Clark, dri-devel Cc: freedreno, linux-arm-msm, Tvrtko Ursulin, Thomas Zimmermann, Chris Healy, Rob Clark, Maarten Lankhorst, Maxime Ripard, David Airlie, Daniel Vetter, open list On 09/06/2022 20:42, Rob Clark wrote: > From: Rob Clark <robdclark@chromium.org> > > The DEFINE_DRM_GEM_FOPS() helper is a bit limiting if a driver wants to > provide additional file ops, like show_fdinfo(). > > v2: Split out DRM_GEM_FOPS instead of making DEFINE_DRM_GEM_FOPS > varardic > v3: nits > > Signed-off-by: Rob Clark <robdclark@chromium.org> > Acked-by: Thomas Zimmermann <tzimmermann@suse.de> I suspect that with Tomas's ack we can pick this through the drm/msm. Is this correct? (I'll then pick it for the msm-lumag). > --- > include/drm/drm_gem.h | 26 ++++++++++++++++++-------- > 1 file changed, 18 insertions(+), 8 deletions(-) > > diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h > index 9d7c61a122dc..87cffc9efa85 100644 > --- a/include/drm/drm_gem.h > +++ b/include/drm/drm_gem.h > @@ -314,6 +314,23 @@ struct drm_gem_object { > const struct drm_gem_object_funcs *funcs; > }; > > +/** > + * DRM_GEM_FOPS - Default drm GEM file operations > + * > + * This macro provides a shorthand for setting the GEM file ops in the > + * &file_operations structure. If all you need are the default ops, use > + * DEFINE_DRM_GEM_FOPS instead. > + */ > +#define DRM_GEM_FOPS \ > + .open = drm_open,\ > + .release = drm_release,\ > + .unlocked_ioctl = drm_ioctl,\ > + .compat_ioctl = drm_compat_ioctl,\ > + .poll = drm_poll,\ > + .read = drm_read,\ > + .llseek = noop_llseek,\ > + .mmap = drm_gem_mmap > + > /** > * DEFINE_DRM_GEM_FOPS() - macro to generate file operations for GEM drivers > * @name: name for the generated structure > @@ -330,14 +347,7 @@ struct drm_gem_object { > #define DEFINE_DRM_GEM_FOPS(name) \ > static const struct file_operations name = {\ > .owner = THIS_MODULE,\ > - .open = drm_open,\ > - .release = drm_release,\ > - .unlocked_ioctl = drm_ioctl,\ > - .compat_ioctl = drm_compat_ioctl,\ > - .poll = drm_poll,\ > - .read = drm_read,\ > - .llseek = noop_llseek,\ > - .mmap = drm_gem_mmap,\ > + DRM_GEM_FOPS,\ > } > > void drm_gem_object_release(struct drm_gem_object *obj); -- With best wishes Dmitry ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 1/2] drm: Add DRM_GEM_FOPS 2022-06-15 12:45 ` [PATCH v3 1/2] drm: Add DRM_GEM_FOPS Dmitry Baryshkov @ 2022-06-15 13:46 ` Thomas Zimmermann 0 siblings, 0 replies; 8+ messages in thread From: Thomas Zimmermann @ 2022-06-15 13:46 UTC (permalink / raw) To: Dmitry Baryshkov, Rob Clark, dri-devel Cc: Rob Clark, Tvrtko Ursulin, David Airlie, linux-arm-msm, open list, freedreno, Chris Healy [-- Attachment #1.1: Type: text/plain, Size: 2872 bytes --] Am 15.06.22 um 14:45 schrieb Dmitry Baryshkov: > On 09/06/2022 20:42, Rob Clark wrote: >> From: Rob Clark <robdclark@chromium.org> >> >> The DEFINE_DRM_GEM_FOPS() helper is a bit limiting if a driver wants to >> provide additional file ops, like show_fdinfo(). >> >> v2: Split out DRM_GEM_FOPS instead of making DEFINE_DRM_GEM_FOPS >> varardic >> v3: nits >> >> Signed-off-by: Rob Clark <robdclark@chromium.org> >> Acked-by: Thomas Zimmermann <tzimmermann@suse.de> > > I suspect that with Tomas's ack we can pick this through the drm/msm. Is > this correct? (I'll then pick it for the msm-lumag). Sure, go ahead. > >> --- >> include/drm/drm_gem.h | 26 ++++++++++++++++++-------- >> 1 file changed, 18 insertions(+), 8 deletions(-) >> >> diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h >> index 9d7c61a122dc..87cffc9efa85 100644 >> --- a/include/drm/drm_gem.h >> +++ b/include/drm/drm_gem.h >> @@ -314,6 +314,23 @@ struct drm_gem_object { >> const struct drm_gem_object_funcs *funcs; >> }; >> +/** >> + * DRM_GEM_FOPS - Default drm GEM file operations >> + * >> + * This macro provides a shorthand for setting the GEM file ops in the >> + * &file_operations structure. If all you need are the default ops, use >> + * DEFINE_DRM_GEM_FOPS instead. >> + */ >> +#define DRM_GEM_FOPS \ >> + .open = drm_open,\ >> + .release = drm_release,\ >> + .unlocked_ioctl = drm_ioctl,\ >> + .compat_ioctl = drm_compat_ioctl,\ >> + .poll = drm_poll,\ >> + .read = drm_read,\ >> + .llseek = noop_llseek,\ >> + .mmap = drm_gem_mmap >> + >> /** >> * DEFINE_DRM_GEM_FOPS() - macro to generate file operations for GEM >> drivers >> * @name: name for the generated structure >> @@ -330,14 +347,7 @@ struct drm_gem_object { >> #define DEFINE_DRM_GEM_FOPS(name) \ >> static const struct file_operations name = {\ >> .owner = THIS_MODULE,\ >> - .open = drm_open,\ >> - .release = drm_release,\ >> - .unlocked_ioctl = drm_ioctl,\ >> - .compat_ioctl = drm_compat_ioctl,\ >> - .poll = drm_poll,\ >> - .read = drm_read,\ >> - .llseek = noop_llseek,\ >> - .mmap = drm_gem_mmap,\ >> + DRM_GEM_FOPS,\ >> } >> void drm_gem_object_release(struct drm_gem_object *obj); > > -- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Ivo Totev [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 840 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 1/2] drm: Add DRM_GEM_FOPS 2022-06-09 17:42 [PATCH v3 1/2] drm: Add DRM_GEM_FOPS Rob Clark 2022-06-09 17:42 ` [PATCH v3 2/2] drm/msm: Expose client engine utilization via fdinfo Rob Clark 2022-06-15 12:45 ` [PATCH v3 1/2] drm: Add DRM_GEM_FOPS Dmitry Baryshkov @ 2022-06-24 20:48 ` Daniel Vetter 2022-06-25 3:32 ` Rob Clark 2 siblings, 1 reply; 8+ messages in thread From: Daniel Vetter @ 2022-06-24 20:48 UTC (permalink / raw) To: Rob Clark Cc: dri-devel, freedreno, linux-arm-msm, Tvrtko Ursulin, Thomas Zimmermann, Chris Healy, Rob Clark, Maarten Lankhorst, Maxime Ripard, David Airlie, Daniel Vetter, open list On Thu, Jun 09, 2022 at 10:42:11AM -0700, Rob Clark wrote: > From: Rob Clark <robdclark@chromium.org> > > The DEFINE_DRM_GEM_FOPS() helper is a bit limiting if a driver wants to > provide additional file ops, like show_fdinfo(). > > v2: Split out DRM_GEM_FOPS instead of making DEFINE_DRM_GEM_FOPS > varardic > v3: nits > > Signed-off-by: Rob Clark <robdclark@chromium.org> > Acked-by: Thomas Zimmermann <tzimmermann@suse.de> We're at three drivers, maybe it'd be better if this is more standardized? I feel like we're opening a bit a can of worms here where everyone just has some good odl fashioned fun. It's at least much better documented than the old property proliferation :-) -Daniel > --- > include/drm/drm_gem.h | 26 ++++++++++++++++++-------- > 1 file changed, 18 insertions(+), 8 deletions(-) > > diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h > index 9d7c61a122dc..87cffc9efa85 100644 > --- a/include/drm/drm_gem.h > +++ b/include/drm/drm_gem.h > @@ -314,6 +314,23 @@ struct drm_gem_object { > const struct drm_gem_object_funcs *funcs; > }; > > +/** > + * DRM_GEM_FOPS - Default drm GEM file operations > + * > + * This macro provides a shorthand for setting the GEM file ops in the > + * &file_operations structure. If all you need are the default ops, use > + * DEFINE_DRM_GEM_FOPS instead. > + */ > +#define DRM_GEM_FOPS \ > + .open = drm_open,\ > + .release = drm_release,\ > + .unlocked_ioctl = drm_ioctl,\ > + .compat_ioctl = drm_compat_ioctl,\ > + .poll = drm_poll,\ > + .read = drm_read,\ > + .llseek = noop_llseek,\ > + .mmap = drm_gem_mmap > + > /** > * DEFINE_DRM_GEM_FOPS() - macro to generate file operations for GEM drivers > * @name: name for the generated structure > @@ -330,14 +347,7 @@ struct drm_gem_object { > #define DEFINE_DRM_GEM_FOPS(name) \ > static const struct file_operations name = {\ > .owner = THIS_MODULE,\ > - .open = drm_open,\ > - .release = drm_release,\ > - .unlocked_ioctl = drm_ioctl,\ > - .compat_ioctl = drm_compat_ioctl,\ > - .poll = drm_poll,\ > - .read = drm_read,\ > - .llseek = noop_llseek,\ > - .mmap = drm_gem_mmap,\ > + DRM_GEM_FOPS,\ > } > > void drm_gem_object_release(struct drm_gem_object *obj); > -- > 2.36.1 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 1/2] drm: Add DRM_GEM_FOPS 2022-06-24 20:48 ` Daniel Vetter @ 2022-06-25 3:32 ` Rob Clark 0 siblings, 0 replies; 8+ messages in thread From: Rob Clark @ 2022-06-25 3:32 UTC (permalink / raw) To: Rob Clark, dri-devel, freedreno, linux-arm-msm, Tvrtko Ursulin, Thomas Zimmermann, Chris Healy, Rob Clark, Maarten Lankhorst, Maxime Ripard, David Airlie, open list Cc: Daniel Vetter On Fri, Jun 24, 2022 at 1:49 PM Daniel Vetter <daniel@ffwll.ch> wrote: > > On Thu, Jun 09, 2022 at 10:42:11AM -0700, Rob Clark wrote: > > From: Rob Clark <robdclark@chromium.org> > > > > The DEFINE_DRM_GEM_FOPS() helper is a bit limiting if a driver wants to > > provide additional file ops, like show_fdinfo(). > > > > v2: Split out DRM_GEM_FOPS instead of making DEFINE_DRM_GEM_FOPS > > varardic > > v3: nits > > > > Signed-off-by: Rob Clark <robdclark@chromium.org> > > Acked-by: Thomas Zimmermann <tzimmermann@suse.de> > > We're at three drivers, maybe it'd be better if this is more standardized? > I feel like we're opening a bit a can of worms here where everyone just > has some good odl fashioned fun. It's at least much better documented than > the old property proliferation :-) yeah, we could have a standardized drm_show_fdinfo() fop plus drm_driver callback.. at this point the drm core fxn would be rather boring, ie. only printing dev->driver->name, so I didn't pursue that approach (yet?).. but perhaps that changes over time. I think we chose the right approach here, focusing on the documentation first so that userspace has a standardized experience. The kernel side of things, we are free to refactor at any time ;-) BR, -R > -Daniel > > > --- > > include/drm/drm_gem.h | 26 ++++++++++++++++++-------- > > 1 file changed, 18 insertions(+), 8 deletions(-) > > > > diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h > > index 9d7c61a122dc..87cffc9efa85 100644 > > --- a/include/drm/drm_gem.h > > +++ b/include/drm/drm_gem.h > > @@ -314,6 +314,23 @@ struct drm_gem_object { > > const struct drm_gem_object_funcs *funcs; > > }; > > > > +/** > > + * DRM_GEM_FOPS - Default drm GEM file operations > > + * > > + * This macro provides a shorthand for setting the GEM file ops in the > > + * &file_operations structure. If all you need are the default ops, use > > + * DEFINE_DRM_GEM_FOPS instead. > > + */ > > +#define DRM_GEM_FOPS \ > > + .open = drm_open,\ > > + .release = drm_release,\ > > + .unlocked_ioctl = drm_ioctl,\ > > + .compat_ioctl = drm_compat_ioctl,\ > > + .poll = drm_poll,\ > > + .read = drm_read,\ > > + .llseek = noop_llseek,\ > > + .mmap = drm_gem_mmap > > + > > /** > > * DEFINE_DRM_GEM_FOPS() - macro to generate file operations for GEM drivers > > * @name: name for the generated structure > > @@ -330,14 +347,7 @@ struct drm_gem_object { > > #define DEFINE_DRM_GEM_FOPS(name) \ > > static const struct file_operations name = {\ > > .owner = THIS_MODULE,\ > > - .open = drm_open,\ > > - .release = drm_release,\ > > - .unlocked_ioctl = drm_ioctl,\ > > - .compat_ioctl = drm_compat_ioctl,\ > > - .poll = drm_poll,\ > > - .read = drm_read,\ > > - .llseek = noop_llseek,\ > > - .mmap = drm_gem_mmap,\ > > + DRM_GEM_FOPS,\ > > } > > > > void drm_gem_object_release(struct drm_gem_object *obj); > > -- > > 2.36.1 > > > > -- > Daniel Vetter > Software Engineer, Intel Corporation > http://blog.ffwll.ch ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-06-25 3:32 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-06-09 17:42 [PATCH v3 1/2] drm: Add DRM_GEM_FOPS Rob Clark 2022-06-09 17:42 ` [PATCH v3 2/2] drm/msm: Expose client engine utilization via fdinfo Rob Clark 2022-06-15 12:44 ` Dmitry Baryshkov 2022-06-15 12:52 ` Tvrtko Ursulin 2022-06-15 12:45 ` [PATCH v3 1/2] drm: Add DRM_GEM_FOPS Dmitry Baryshkov 2022-06-15 13:46 ` Thomas Zimmermann 2022-06-24 20:48 ` Daniel Vetter 2022-06-25 3:32 ` Rob Clark
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox