Skip to content

Commit 3ab7c08

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
locking/drm: Kill mutex trickery
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 <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Chris Wilson <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Paul E. McKenney <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Rob Clark <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 9fe68ca commit 3ab7c08

File tree

2 files changed

+4
-39
lines changed

2 files changed

+4
-39
lines changed

drivers/gpu/drm/i915/i915_gem_shrinker.c

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,6 @@
3535
#include "i915_drv.h"
3636
#include "i915_trace.h"
3737

38-
static bool mutex_is_locked_by(struct mutex *mutex, struct task_struct *task)
39-
{
40-
if (!mutex_is_locked(mutex))
41-
return false;
42-
43-
#if defined(CONFIG_DEBUG_MUTEXES) || defined(CONFIG_MUTEX_SPIN_ON_OWNER)
44-
return mutex->owner == task;
45-
#else
46-
/* Since UP may be pre-empted, we cannot assume that we own the lock */
47-
return false;
48-
#endif
49-
}
50-
5138
static bool any_vma_pinned(struct drm_i915_gem_object *obj)
5239
{
5340
struct i915_vma *vma;
@@ -240,13 +227,8 @@ unsigned long i915_gem_shrink_all(struct drm_i915_private *dev_priv)
240227

241228
static bool i915_gem_shrinker_lock(struct drm_device *dev, bool *unlock)
242229
{
243-
if (!mutex_trylock(&dev->struct_mutex)) {
244-
if (!mutex_is_locked_by(&dev->struct_mutex, current))
245-
return false;
246-
230+
if (!mutex_trylock(&dev->struct_mutex))
247231
*unlock = false;
248-
} else
249-
*unlock = true;
250232

251233
return true;
252234
}

drivers/gpu/drm/msm/msm_gem_shrinker.c

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,12 @@
1818
#include "msm_drv.h"
1919
#include "msm_gem.h"
2020

21-
static bool mutex_is_locked_by(struct mutex *mutex, struct task_struct *task)
22-
{
23-
if (!mutex_is_locked(mutex))
24-
return false;
25-
26-
#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_MUTEXES)
27-
return mutex->owner == task;
28-
#else
29-
/* Since UP may be pre-empted, we cannot assume that we own the lock */
30-
return false;
31-
#endif
32-
}
33-
3421
static bool msm_gem_shrinker_lock(struct drm_device *dev, bool *unlock)
3522
{
36-
if (!mutex_trylock(&dev->struct_mutex)) {
37-
if (!mutex_is_locked_by(&dev->struct_mutex, current))
38-
return false;
39-
*unlock = false;
40-
} else {
41-
*unlock = true;
42-
}
23+
if (!mutex_trylock(&dev->struct_mutex))
24+
return false;
4325

26+
*unlock = true;
4427
return true;
4528
}
4629

0 commit comments

Comments
 (0)