locking/drm: Fix i915_gem_shrinker_lock() locking
authorIngo Molnar <mingo@kernel.org>
Thu, 3 Nov 2016 06:16:43 +0000 (07:16 +0100)
committerIngo Molnar <mingo@kernel.org>
Thu, 3 Nov 2016 06:21:12 +0000 (07:21 +0100)
Mike Krinkin reported hangs in the DRM code and bisected it to:

  3ab7c086d5ec72585ef0 ("locking/drm: Kill mutex trickery")

Hugh Dickins observed:

 "i915_gem_shrinker_lock() is broken: but copy the pattern from
  msm_gem_shrinker_lock() and it's okay - patch below."

Pick up the fix in isolation to make sure the bug is fixed, cleanup
patch will follow up.

Originally-From: Hugh Dickins <hughd@google.com>
Reported-by: Hugh Dickins <hughd@google.com>
Reported-by: Mike Krinkin <krinkin.m.u@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: chris@chris-wilson.co.uk
Cc: jason.low2@hpe.com
Link: http://lkml.kernel.org/r/alpine.LSU.2.11.1610301645180.28429@eggly.anvils
Signed-off-by: Ingo Molnar <mingo@kernel.org>
drivers/gpu/drm/i915/i915_gem_shrinker.c

index 36953757687e72debb3dbb21609ced15e5252921..e9bd2a81d03aaef9aba398479c5d1f38a0d6c502 100644 (file)
@@ -228,8 +228,9 @@ unsigned long i915_gem_shrink_all(struct drm_i915_private *dev_priv)
 static bool i915_gem_shrinker_lock(struct drm_device *dev, bool *unlock)
 {
        if (!mutex_trylock(&dev->struct_mutex))
-               *unlock = false;
+               return false;
 
+       *unlock = true;
        return true;
 }