[PATCH v2] drm/v3d: Add DRM_IOCTL_V3D_PERFMON_SET_GLOBAL
Christian Gmeiner
christian.gmeiner at gmail.com
Mon Nov 4 13:24:44 UTC 2024
Hi Maíra,
> On 31/10/24 17:51, Christian Gmeiner wrote:
> > From: Christian Gmeiner <cgmeiner at igalia.com>
> >
> > Add a new ioctl, DRM_IOCTL_V3D_PERFMON_SET_GLOBAL, to allow
> > configuration of a global performance monitor (perfmon).
> > Use the global perfmon for all jobs to ensure consistent
> > performance tracking across submissions.
> >
> > Signed-off-by: Christian Gmeiner <cgmeiner at igalia.com>
> >
> > ---
> > Changes in v2:
> > - Reworked commit message.
> > - Removed num_perfmon counter for tracking perfmon allocations.
> > - Allowing allocation of perfmons when the global perfmon is active.
> > - Return -EAGAIN for submissions with a per job perfmon if the global perfmon is active.
> > ---
> > drivers/gpu/drm/v3d/v3d_drv.c | 1 +
> > drivers/gpu/drm/v3d/v3d_drv.h | 8 ++++++++
> > drivers/gpu/drm/v3d/v3d_perfmon.c | 34 +++++++++++++++++++++++++++++++
> > drivers/gpu/drm/v3d/v3d_sched.c | 14 ++++++++++---
> > drivers/gpu/drm/v3d/v3d_submit.c | 10 +++++++++
> > include/uapi/drm/v3d_drm.h | 15 ++++++++++++++
> > 6 files changed, 79 insertions(+), 3 deletions(-)
> >
>
> [...]
>
> > diff --git a/drivers/gpu/drm/v3d/v3d_perfmon.c b/drivers/gpu/drm/v3d/v3d_perfmon.c
> > index 156be13ab2ef..bf42303c292b 100644
> > --- a/drivers/gpu/drm/v3d/v3d_perfmon.c
> > +++ b/drivers/gpu/drm/v3d/v3d_perfmon.c
> > @@ -312,6 +312,9 @@ static int v3d_perfmon_idr_del(int id, void *elem, void *data)
> > if (perfmon == v3d->active_perfmon)
> > v3d_perfmon_stop(v3d, perfmon, false);
> >
> > + /* If the global perfmon is being destroyed, set it to NULL */
> > + cmpxchg(&v3d->global_perfmon, perfmon, NULL);
> > +
> > v3d_perfmon_put(perfmon);
> >
> > return 0;
> > @@ -451,3 +454,34 @@ int v3d_perfmon_get_counter_ioctl(struct drm_device *dev, void *data,
> >
> > return 0;
> > }
> > +
> > +int v3d_perfmon_set_global_ioctl(struct drm_device *dev, void *data,
> > + struct drm_file *file_priv)
> > +{
> > + struct v3d_file_priv *v3d_priv = file_priv->driver_priv;
> > + struct drm_v3d_perfmon_set_global *req = data;
> > + struct v3d_dev *v3d = to_v3d_dev(dev);
> > + struct v3d_perfmon *perfmon;
> > +
> > + if (req->flags & ~DRM_V3D_PERFMON_CLEAR_GLOBAL)
> > + return -EINVAL;
> > +
> > + perfmon = v3d_perfmon_find(v3d_priv, req->id);
> > + if (!perfmon)
> > + return -EINVAL;
> > +
> > + /* If the request is to clear the global performance monitor */
> > + if (req->flags & DRM_V3D_PERFMON_CLEAR_GLOBAL) {
> > + if (!v3d->global_perfmon)
> > + return -EINVAL;
> > +
> > + xchg(&v3d->global_perfmon, NULL);
>
> I'm reading the userspace code now and I think you need to call
> `v3d_perfmon_stop` here to make sure that the active perfmon is no
> longer the global perfmon.
>
I will add a `v3d_perfmon_stop` call to `v3d_perfmon_destroy_ioctl` as it
seems a much better place.
--
greets
--
Christian Gmeiner, MSc
https://christian-gmeiner.info/privacypolicy
More information about the dri-devel
mailing list