Commit 48777767 authored by Chris Wilson's avatar Chris Wilson Committed by Daniel Vetter

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: default avatarJulia Lawall <julia.lawall@lip6.fr>
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent ec8b0dd5
...@@ -91,10 +91,10 @@ static unsigned long cancel_userptr(struct drm_i915_gem_object *obj) ...@@ -91,10 +91,10 @@ static unsigned long cancel_userptr(struct drm_i915_gem_object *obj)
return end; return end;
} }
static void invalidate_range__linear(struct i915_mmu_notifier *mn, static void *invalidate_range__linear(struct i915_mmu_notifier *mn,
struct mm_struct *mm, struct mm_struct *mm,
unsigned long start, unsigned long start,
unsigned long end) unsigned long end)
{ {
struct i915_mmu_object *mmu; struct i915_mmu_object *mmu;
unsigned long serial; unsigned long serial;
...@@ -118,7 +118,7 @@ static void invalidate_range__linear(struct i915_mmu_notifier *mn, ...@@ -118,7 +118,7 @@ static void invalidate_range__linear(struct i915_mmu_notifier *mn,
goto restart; goto restart;
} }
spin_unlock(&mn->lock); return NULL;
} }
static void i915_gem_userptr_mn_invalidate_range_start(struct mmu_notifier *_mn, 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, ...@@ -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 */ end--; /* interval ranges are inclusive, but invalidate range is exclusive */
while (next < end) { while (next < end) {
struct drm_i915_gem_object *obj; struct drm_i915_gem_object *obj = NULL;
obj = NULL;
spin_lock(&mn->lock); spin_lock(&mn->lock);
if (mn->has_linear) if (mn->has_linear)
return invalidate_range__linear(mn, mm, start, end); it = invalidate_range__linear(mn, mm, start, end);
if (serial == mn->serial) else if (serial == mn->serial)
it = interval_tree_iter_next(it, next, end); it = interval_tree_iter_next(it, next, end);
else else
it = interval_tree_iter_first(&mn->objects, start, end); it = interval_tree_iter_first(&mn->objects, start, end);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment