]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
locking/drm: Kill mutex trickery
authorPeter Zijlstra <peterz@infradead.org>
Thu, 25 Aug 2016 16:02:41 +0000 (18:02 +0200)
committerIngo Molnar <mingo@kernel.org>
Tue, 25 Oct 2016 09:31:50 +0000 (11:31 +0200)
Poking at lock internals is not cool. Since I'm going to change the
implementation this will break, take it out.

Tested-by: Jason Low <jason.low2@hpe.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
drivers/gpu/drm/i915/i915_gem_shrinker.c
drivers/gpu/drm/msm/msm_gem_shrinker.c

index 1c237d02f30b1307deef2938f4a54e50629b68f6..36953757687e72debb3dbb21609ced15e5252921 100644 (file)
 #include "i915_drv.h"
 #include "i915_trace.h"
 
-static bool mutex_is_locked_by(struct mutex *mutex, struct task_struct *task)
-{
-       if (!mutex_is_locked(mutex))
-               return false;
-
-#if defined(CONFIG_DEBUG_MUTEXES) || defined(CONFIG_MUTEX_SPIN_ON_OWNER)
-       return mutex->owner == task;
-#else
-       /* Since UP may be pre-empted, we cannot assume that we own the lock */
-       return false;
-#endif
-}
-
 static bool any_vma_pinned(struct drm_i915_gem_object *obj)
 {
        struct i915_vma *vma;
@@ -240,13 +227,8 @@ 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)) {
-               if (!mutex_is_locked_by(&dev->struct_mutex, current))
-                       return false;
-
+       if (!mutex_trylock(&dev->struct_mutex))
                *unlock = false;
-       } else
-               *unlock = true;
 
        return true;
 }
index 283d2841ba58137efa28ea4c2cef3872b4cb5202..6d2e885bd58efd4a0b3554abcd1963990091150e 100644 (file)
 #include "msm_drv.h"
 #include "msm_gem.h"
 
-static bool mutex_is_locked_by(struct mutex *mutex, struct task_struct *task)
-{
-       if (!mutex_is_locked(mutex))
-               return false;
-
-#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_MUTEXES)
-       return mutex->owner == task;
-#else
-       /* Since UP may be pre-empted, we cannot assume that we own the lock */
-       return false;
-#endif
-}
-
 static bool msm_gem_shrinker_lock(struct drm_device *dev, bool *unlock)
 {
-       if (!mutex_trylock(&dev->struct_mutex)) {
-               if (!mutex_is_locked_by(&dev->struct_mutex, current))
-                       return false;
-               *unlock = false;
-       } else {
-               *unlock = true;
-       }
+       if (!mutex_trylock(&dev->struct_mutex))
+               return false;
 
+       *unlock = true;
        return true;
 }