diff mbox

drm: Take mode_config.mutex in setcrtc ioctl

Message ID 20170406190654.6733-1-daniel.vetter@ffwll.ch (mailing list archive)
State New, archived
Headers show

Commit Message

Daniel Vetter April 6, 2017, 7:06 p.m. UTC
Legacy drivers insist that we really take all the locks in this path,
and the harm in doing so is minimal.

v2: Like git add, it exists :(

Fixes: 2ceb585a956c ("drm: Add explicit acquire ctx handling around ->set_config")
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: David Airlie <airlied@linux.ie>
Cc: dri-devel@lists.freedesktop.org
Cc: Alex Deucher <alexdeucher@gmail.com>
Reported-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/drm_crtc.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Alex Deucher April 6, 2017, 7:09 p.m. UTC | #1
On Thu, Apr 6, 2017 at 3:06 PM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> Legacy drivers insist that we really take all the locks in this path,
> and the harm in doing so is minimal.
>
> v2: Like git add, it exists :(
>
> Fixes: 2ceb585a956c ("drm: Add explicit acquire ctx handling around ->set_config")
> Cc: Harry Wentland <harry.wentland@amd.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Sean Paul <seanpaul@chromium.org>
> Cc: David Airlie <airlied@linux.ie>
> Cc: dri-devel@lists.freedesktop.org
> Cc: Alex Deucher <alexdeucher@gmail.com>
> Reported-by: Alex Deucher <alexdeucher@gmail.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>

This actually matches what I tested locally.

Acked-and-tested-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  drivers/gpu/drm/drm_crtc.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index d69e180fc563..5af25ce5bf7c 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -576,6 +576,7 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
>         }
>         DRM_DEBUG_KMS("[CRTC:%d:%s]\n", crtc->base.id, crtc->name);
>
> +       mutex_lock(&crtc->dev->mode_config.mutex);
>         drm_modeset_acquire_init(&ctx, 0);
>  retry:
>         ret = drm_modeset_lock_all_ctx(crtc->dev, &ctx);
> @@ -721,6 +722,7 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
>         }
>         drm_modeset_drop_locks(&ctx);
>         drm_modeset_acquire_fini(&ctx);
> +       mutex_unlock(&crtc->dev->mode_config.mutex);
>
>         return ret;
>  }
> --
> 2.11.0
>
Daniel Vetter April 6, 2017, 8:49 p.m. UTC | #2
On Thu, Apr 06, 2017 at 03:09:04PM -0400, Alex Deucher wrote:
> On Thu, Apr 6, 2017 at 3:06 PM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> > Legacy drivers insist that we really take all the locks in this path,
> > and the harm in doing so is minimal.
> >
> > v2: Like git add, it exists :(
> >
> > Fixes: 2ceb585a956c ("drm: Add explicit acquire ctx handling around ->set_config")
> > Cc: Harry Wentland <harry.wentland@amd.com>
> > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > Cc: Daniel Vetter <daniel.vetter@intel.com>
> > Cc: Jani Nikula <jani.nikula@linux.intel.com>
> > Cc: Sean Paul <seanpaul@chromium.org>
> > Cc: David Airlie <airlied@linux.ie>
> > Cc: dri-devel@lists.freedesktop.org
> > Cc: Alex Deucher <alexdeucher@gmail.com>
> > Reported-by: Alex Deucher <alexdeucher@gmail.com>
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> 
> This actually matches what I tested locally.
> 
> Acked-and-tested-by: Alex Deucher <alexander.deucher@amd.com>

Thanks for quickly testing this, applied.
-Daniel

> 
> > ---
> >  drivers/gpu/drm/drm_crtc.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> > index d69e180fc563..5af25ce5bf7c 100644
> > --- a/drivers/gpu/drm/drm_crtc.c
> > +++ b/drivers/gpu/drm/drm_crtc.c
> > @@ -576,6 +576,7 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
> >         }
> >         DRM_DEBUG_KMS("[CRTC:%d:%s]\n", crtc->base.id, crtc->name);
> >
> > +       mutex_lock(&crtc->dev->mode_config.mutex);
> >         drm_modeset_acquire_init(&ctx, 0);
> >  retry:
> >         ret = drm_modeset_lock_all_ctx(crtc->dev, &ctx);
> > @@ -721,6 +722,7 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
> >         }
> >         drm_modeset_drop_locks(&ctx);
> >         drm_modeset_acquire_fini(&ctx);
> > +       mutex_unlock(&crtc->dev->mode_config.mutex);
> >
> >         return ret;
> >  }
> > --
> > 2.11.0
> >
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index d69e180fc563..5af25ce5bf7c 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -576,6 +576,7 @@  int drm_mode_setcrtc(struct drm_device *dev, void *data,
 	}
 	DRM_DEBUG_KMS("[CRTC:%d:%s]\n", crtc->base.id, crtc->name);
 
+	mutex_lock(&crtc->dev->mode_config.mutex);
 	drm_modeset_acquire_init(&ctx, 0);
 retry:
 	ret = drm_modeset_lock_all_ctx(crtc->dev, &ctx);
@@ -721,6 +722,7 @@  int drm_mode_setcrtc(struct drm_device *dev, void *data,
 	}
 	drm_modeset_drop_locks(&ctx);
 	drm_modeset_acquire_fini(&ctx);
+	mutex_unlock(&crtc->dev->mode_config.mutex);
 
 	return ret;
 }