diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2014-07-24 12:28:44 (GMT) |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2014-07-25 07:39:03 (GMT) |
commit | 487777673e355ab9f0b7cac4ad1207be9d36156f (patch) | |
tree | b2c01d7ddc8a9ad5bf9b560ea962f38782b83b62 /drivers/gpu/drm/i915/i915_gem_userptr.c | |
parent | ec8b0dd51c50e33c3831bbf57ee4ca3e9f35460d (diff) | |
download | linux-487777673e355ab9f0b7cac4ad1207be9d36156f.tar.xz |
drm/i915/userptr: Keep spin_lock/unlock in the same block
Move the code around in order to acquire and release the spinlock in the
same function and in the same block. This keeps static analysers happy
and the reader sane.
Suggested-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915/i915_gem_userptr.c')
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem_userptr.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem_userptr.c b/drivers/gpu/drm/i915/i915_gem_userptr.c index 74c45da..fe69fc8 100644 --- a/drivers/gpu/drm/i915/i915_gem_userptr.c +++ b/drivers/gpu/drm/i915/i915_gem_userptr.c @@ -91,10 +91,10 @@ static unsigned long cancel_userptr(struct drm_i915_gem_object *obj) return end; } -static void invalidate_range__linear(struct i915_mmu_notifier *mn, - struct mm_struct *mm, - unsigned long start, - unsigned long end) +static void *invalidate_range__linear(struct i915_mmu_notifier *mn, + struct mm_struct *mm, + unsigned long start, + unsigned long end) { struct i915_mmu_object *mmu; unsigned long serial; @@ -118,7 +118,7 @@ restart: goto restart; } - spin_unlock(&mn->lock); + return NULL; } static void i915_gem_userptr_mn_invalidate_range_start(struct mmu_notifier *_mn, @@ -133,13 +133,12 @@ static void i915_gem_userptr_mn_invalidate_range_start(struct mmu_notifier *_mn, end--; /* interval ranges are inclusive, but invalidate range is exclusive */ while (next < end) { - struct drm_i915_gem_object *obj; + struct drm_i915_gem_object *obj = NULL; - obj = NULL; spin_lock(&mn->lock); if (mn->has_linear) - return invalidate_range__linear(mn, mm, start, end); - if (serial == mn->serial) + it = invalidate_range__linear(mn, mm, start, end); + else if (serial == mn->serial) it = interval_tree_iter_next(it, next, end); else it = interval_tree_iter_first(&mn->objects, start, end); |