diff mbox series

drm/i915/selftests: Lock the drm_mm as we search

Message ID 20200128183458.3860022-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series drm/i915/selftests: Lock the drm_mm as we search | expand

Commit Message

Chris Wilson Jan. 28, 2020, 6:34 p.m. UTC
Hold onto the vm->mutex (to lock the drm_mm) to ensure that the rbtree
is table as we search it for our scratch node.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Matthew Auld Jan. 28, 2020, 6:45 p.m. UTC | #1
On Tue, 28 Jan 2020 at 18:35, Chris Wilson <chris@chris-wilson.co.uk> wrote:
>
> Hold onto the vm->mutex (to lock the drm_mm) to ensure that the rbtree
> is table as we search it for our scratch node.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c b/drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c
index 130c4c522686..375d864736f3 100644
--- a/drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c
@@ -1465,9 +1465,12 @@  static int igt_ctx_readonly(void *arg)
 
 static int check_scratch(struct i915_address_space *vm, u64 offset)
 {
-	struct drm_mm_node *node =
-		__drm_mm_interval_first(&vm->mm,
-					offset, offset + sizeof(u32) - 1);
+	struct drm_mm_node *node;
+
+	mutex_lock(&vm->mutex);
+	node = __drm_mm_interval_first(&vm->mm,
+				       offset, offset + sizeof(u32) - 1);
+	mutex_unlock(&vm->mutex);
 	if (!node || node->start > offset)
 		return 0;