diff mbox

drm: Fixup locking WARN_ON mistake around gem_object_free_unlocked

Message ID 1462364980-9973-1-git-send-email-daniel.vetter@ffwll.ch (mailing list archive)
State New, archived
Headers show

Commit Message

Daniel Vetter May 4, 2016, 12:29 p.m. UTC
Embarrassingly while fixing up the old paths for i915 I managed to
misplace a locking check for the new _unlocked paths. That's what I
get for not retesting on radeon.

Fixes: 9f0ba539d13a ("drm/gem: support BO freeing without dev->struct_mutex")
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Alex Deucher <alexdeucher@gmail.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Tested-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/drm_gem.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Alex Deucher May 4, 2016, 12:59 p.m. UTC | #1
On Wed, May 4, 2016 at 8:29 AM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> Embarrassingly while fixing up the old paths for i915 I managed to
> misplace a locking check for the new _unlocked paths. That's what I
> get for not retesting on radeon.
>
> Fixes: 9f0ba539d13a ("drm/gem: support BO freeing without dev->struct_mutex")
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Alex Deucher <alexdeucher@gmail.com>
> Cc: Lucas Stach <l.stach@pengutronix.de>
> Tested-by: Chris Wilson <chris@chris-wilson.co.uk>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  drivers/gpu/drm/drm_gem.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
> index 973eb8805ce0..f716308fb48c 100644
> --- a/drivers/gpu/drm/drm_gem.c
> +++ b/drivers/gpu/drm/drm_gem.c
> @@ -804,12 +804,13 @@ drm_gem_object_free(struct kref *kref)
>                 container_of(kref, struct drm_gem_object, refcount);
>         struct drm_device *dev = obj->dev;
>
> -       WARN_ON(!mutex_is_locked(&dev->struct_mutex));
> -
> -       if (dev->driver->gem_free_object_unlocked)
> +       if (dev->driver->gem_free_object_unlocked) {
>                 dev->driver->gem_free_object_unlocked(obj);
> -       else if (dev->driver->gem_free_object)
> +       } else if (dev->driver->gem_free_object) {
> +               WARN_ON(!mutex_is_locked(&dev->struct_mutex));
> +
>                 dev->driver->gem_free_object(obj);
> +       }
>  }
>  EXPORT_SYMBOL(drm_gem_object_free);
>
> --
> 2.8.1
>
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 973eb8805ce0..f716308fb48c 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -804,12 +804,13 @@  drm_gem_object_free(struct kref *kref)
 		container_of(kref, struct drm_gem_object, refcount);
 	struct drm_device *dev = obj->dev;
 
-	WARN_ON(!mutex_is_locked(&dev->struct_mutex));
-
-	if (dev->driver->gem_free_object_unlocked)
+	if (dev->driver->gem_free_object_unlocked) {
 		dev->driver->gem_free_object_unlocked(obj);
-	else if (dev->driver->gem_free_object)
+	} else if (dev->driver->gem_free_object) {
+		WARN_ON(!mutex_is_locked(&dev->struct_mutex));
+
 		dev->driver->gem_free_object(obj);
+	}
 }
 EXPORT_SYMBOL(drm_gem_object_free);