[Intel-xe] [PATCH v4 19/22] drm/managed: Add drmm_release_action
Michał Winiarski
michal.winiarski at intel.com
Wed Nov 29 22:17:49 UTC 2023
On Wed, Nov 29, 2023 at 12:52:55PM -0500, Rodrigo Vivi wrote:
> On Wed, Nov 29, 2023 at 10:43:24AM +0100, Michal Wajdeczko wrote:
> >
> >
> > On 29.11.2023 02:16, Michał Winiarski wrote:
> > > Similar to devres equivalent, it allows to call the "release" action
> > > directly and remove the resource from the managed resources list.
> > >
> > > Signed-off-by: Michał Winiarski <michal.winiarski at intel.com>
> > > ---
> > > drivers/gpu/drm/drm_managed.c | 28 ++++++++++++++++++++++++++++
> > > include/drm/drm_managed.h | 4 ++++
> > > 2 files changed, 32 insertions(+)
> >
> > shouldn't this go to the dri-devel first ?
>
> yes, please. Let's send there and try to get that quickly through drm-misc,
> or the proper reviews and acks there before getting to drm-xe-next or this
> might block our initial pull request.
Posted this (+kerneldoc +kunit) to dri-devel:
https://lore.kernel.org/dri-devel/20231129221412.1180549-1-michal.winiarski@intel.com/
-Michał
>
> >
> > >
> > > diff --git a/drivers/gpu/drm/drm_managed.c b/drivers/gpu/drm/drm_managed.c
> > > index bcd111404b128..f819940b8a959 100644
> > > --- a/drivers/gpu/drm/drm_managed.c
> > > +++ b/drivers/gpu/drm/drm_managed.c
> > > @@ -176,6 +176,34 @@ int __drmm_add_action_or_reset(struct drm_device *dev,
> > > }
> > > EXPORT_SYMBOL(__drmm_add_action_or_reset);
> > >
> > > +void drmm_release_action(struct drm_device *dev,
> > > + drmres_release_t action,
> > > + void *data)
> > > +{
> > > + struct drmres *dr_match = NULL, *dr;
> > > + unsigned long flags;
> > > +
> > > + spin_lock_irqsave(&dev->managed.lock, flags);
> > > + list_for_each_entry_reverse(dr, &dev->managed.resources, node.entry) {
> > > + if (dr->node.release == action) {
> > > + if (!data || (data && *(void **)dr->data == data)) {
> > > + dr_match = dr;
> > > + del_dr(dev, dr_match);
> > > + break;
> > > + }
> > > + }
> > > + }
> > > + spin_unlock_irqrestore(&dev->managed.lock, flags);
> > > +
> > > + if (WARN_ON(!dr_match))
> > > + return;
> > > +
> > > + action(dev, data);
> > > +
> > > + free_dr(dr_match);
> > > +}
> > > +EXPORT_SYMBOL(drmm_release_action);
> > > +
> > > /**
> > > * drmm_kmalloc - &drm_device managed kmalloc()
> > > * @dev: DRM device
> > > diff --git a/include/drm/drm_managed.h b/include/drm/drm_managed.h
> > > index ad08f834af408..f547b09ca0239 100644
> > > --- a/include/drm/drm_managed.h
> > > +++ b/include/drm/drm_managed.h
> > > @@ -45,6 +45,10 @@ int __must_check __drmm_add_action_or_reset(struct drm_device *dev,
> > > drmres_release_t action,
> > > void *data, const char *name);
> > >
> > > +void drmm_release_action(struct drm_device *dev,
> > > + drmres_release_t action,
> > > + void *data);
> > > +
> > > void *drmm_kmalloc(struct drm_device *dev, size_t size, gfp_t gfp) __malloc;
> > >
> > > /**
More information about the Intel-xe
mailing list