[Intel-gfx] [PATCH] drm: Release filp before global lock
Chris Wilson
chris at chris-wilson.co.uk
Wed Jan 22 22:00:33 UTC 2020
Quoting Thomas Hellström (VMware) (2020-01-22 21:52:23)
> Hi, Chris,
>
> On 1/22/20 4:56 PM, Chris Wilson wrote:
> > The file is not part of the global drm resource and can be released
> > prior to take the global mutex to drop the open_count (and potentially
> > close) the drm device.
> >
> > However, inside drm_close_helper() there are a number of dev->driver
> > callbacks that take the drm_device as the first parameter... Worryingly
> > some of those callbacks may be (implicitly) depending on the global
> > mutex.
>
> I read this as you suspect that there are driver callbacks inside
> drm_close_helper() that might need the global mutex held? But then it
> wouldn't be safe to move the lock? Is there a strong motivation for
> moving the locking in the first place? Also a minor nit below:
The number of processes stuck on 'D' due to mutex_lock(&global) caught my
attention while they were cleaning up files. I think everyone else will
be less impressed if their driver was stuck because i915 was freeing a
user's filp.
> > Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> > ---
> > drivers/gpu/drm/drm_file.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
> > index 92d16724f949..84ed313ee2e9 100644
> > --- a/drivers/gpu/drm/drm_file.c
> > +++ b/drivers/gpu/drm/drm_file.c
> > @@ -438,12 +438,12 @@ int drm_release(struct inode *inode, struct file *filp)
> > struct drm_minor *minor = file_priv->minor;
> > struct drm_device *dev = minor->dev;
> >
> > - mutex_lock(&drm_global_mutex);
> > -
> > DRM_DEBUG("open_count = %d\n", dev->open_count);
>
> The read of dev->open_count should still be inside the lock to be
> consistent with the value that is decremented below. Perhaps move the
> DRM_DEBUG()?
Sure. Is it even worth a debug?
-Chris
More information about the Intel-gfx
mailing list