On Thu, Aug 29, 2019 at 02:05:18AM -0400, Kenny Ho wrote: > To allow other subsystems to iterate through all stored DRM minors and > act upon them. > > Also exposes drm_minor_acquire and drm_minor_release for other subsystem > to handle drm_minor. DRM cgroup controller is the initial consumer of > this new features. > > Change-Id: I7c4b67ce6b31f06d1037b03435386ff5b8144ca5 > Signed-off-by: Kenny Ho <Kenny.Ho@xxxxxxx> Iterating over minors for cgroups sounds very, very wrong. Why do we care whether a buffer was allocated through kms dumb vs render nodes? I'd expect all the cgroup stuff to only work on drm_device, if it does care about devices. (I didn't look through the patch series to find out where exactly you're using this, so maybe I'm off the rails here). -Daniel > --- > drivers/gpu/drm/drm_drv.c | 19 +++++++++++++++++++ > drivers/gpu/drm/drm_internal.h | 4 ---- > include/drm/drm_drv.h | 4 ++++ > 3 files changed, 23 insertions(+), 4 deletions(-) > > diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c > index 862621494a93..000cddabd970 100644 > --- a/drivers/gpu/drm/drm_drv.c > +++ b/drivers/gpu/drm/drm_drv.c > @@ -254,11 +254,13 @@ struct drm_minor *drm_minor_acquire(unsigned int minor_id) > > return minor; > } > +EXPORT_SYMBOL(drm_minor_acquire); > > void drm_minor_release(struct drm_minor *minor) > { > drm_dev_put(minor->dev); > } > +EXPORT_SYMBOL(drm_minor_release); > > /** > * DOC: driver instance overview > @@ -1078,6 +1080,23 @@ int drm_dev_set_unique(struct drm_device *dev, const char *name) > } > EXPORT_SYMBOL(drm_dev_set_unique); > > +/** > + * drm_minor_for_each - Iterate through all stored DRM minors > + * @fn: Function to be called for each pointer. > + * @data: Data passed to callback function. > + * > + * The callback function will be called for each @drm_minor entry, passing > + * the minor, the entry and @data. > + * > + * If @fn returns anything other than %0, the iteration stops and that > + * value is returned from this function. > + */ > +int drm_minor_for_each(int (*fn)(int id, void *p, void *data), void *data) > +{ > + return idr_for_each(&drm_minors_idr, fn, data); > +} > +EXPORT_SYMBOL(drm_minor_for_each); > + > /* > * DRM Core > * The DRM core module initializes all global DRM objects and makes them > diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h > index e19ac7ca602d..6bfad76f8e78 100644 > --- a/drivers/gpu/drm/drm_internal.h > +++ b/drivers/gpu/drm/drm_internal.h > @@ -54,10 +54,6 @@ void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv); > void drm_prime_remove_buf_handle_locked(struct drm_prime_file_private *prime_fpriv, > struct dma_buf *dma_buf); > > -/* drm_drv.c */ > -struct drm_minor *drm_minor_acquire(unsigned int minor_id); > -void drm_minor_release(struct drm_minor *minor); > - > /* drm_vblank.c */ > void drm_vblank_disable_and_save(struct drm_device *dev, unsigned int pipe); > void drm_vblank_cleanup(struct drm_device *dev); > diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h > index 68ca736c548d..24f8d054c570 100644 > --- a/include/drm/drm_drv.h > +++ b/include/drm/drm_drv.h > @@ -799,5 +799,9 @@ static inline bool drm_drv_uses_atomic_modeset(struct drm_device *dev) > > int drm_dev_set_unique(struct drm_device *dev, const char *name); > > +int drm_minor_for_each(int (*fn)(int id, void *p, void *data), void *data); > + > +struct drm_minor *drm_minor_acquire(unsigned int minor_id); > +void drm_minor_release(struct drm_minor *minor); > > #endif > -- > 2.22.0 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch