aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2014-07-24 08:28:44 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2014-07-25 03:39:03 -0400
commit487777673e355ab9f0b7cac4ad1207be9d36156f (patch)
treeb2c01d7ddc8a9ad5bf9b560ea962f38782b83b62
parentec8b0dd51c50e33c3831bbf57ee4ca3e9f35460d (diff)
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>
-rw-r--r--drivers/gpu/drm/i915/i915_gem_userptr.c17
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 74c45da8a1ba..fe69fc837d9e 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)
91 return end; 91 return end;
92} 92}
93 93
94static void invalidate_range__linear(struct i915_mmu_notifier *mn, 94static void *invalidate_range__linear(struct i915_mmu_notifier *mn,
95 struct mm_struct *mm, 95 struct mm_struct *mm,
96 unsigned long start, 96 unsigned long start,
97 unsigned long end) 97 unsigned long end)
98{ 98{
99 struct i915_mmu_object *mmu; 99 struct i915_mmu_object *mmu;
100 unsigned long serial; 100 unsigned long serial;
@@ -118,7 +118,7 @@ restart:
118 goto restart; 118 goto restart;
119 } 119 }
120 120
121 spin_unlock(&mn->lock); 121 return NULL;
122} 122}
123 123
124static void i915_gem_userptr_mn_invalidate_range_start(struct mmu_notifier *_mn, 124static 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 133
134 end--; /* interval ranges are inclusive, but invalidate range is exclusive */ 134 end--; /* interval ranges are inclusive, but invalidate range is exclusive */
135 while (next < end) { 135 while (next < end) {
136 struct drm_i915_gem_object *obj; 136 struct drm_i915_gem_object *obj = NULL;
137 137
138 obj = NULL;
139 spin_lock(&mn->lock); 138 spin_lock(&mn->lock);
140 if (mn->has_linear) 139 if (mn->has_linear)
141 return invalidate_range__linear(mn, mm, start, end); 140 it = invalidate_range__linear(mn, mm, start, end);
142 if (serial == mn->serial) 141 else if (serial == mn->serial)
143 it = interval_tree_iter_next(it, next, end); 142 it = interval_tree_iter_next(it, next, end);
144 else 143 else
145 it = interval_tree_iter_first(&mn->objects, start, end); 144 it = interval_tree_iter_first(&mn->objects, start, end);