[PATCH] HAX: Check gem_exec_alignment test behavior

Nitin Gote nitin.r.gote at intel.com
Fri Sep 13 09:39:07 UTC 2024


Serialise fresh binding/eviction for multi-threaded execbuf

With multiple threads trying to bind different objects to the same
address, they will fail to evict due to another thread pinning that
address for its object as it runs execbuf. In order to let each thread
use the same address, we have to serialise those threads, and so we
elect to use the vm lock for serialisation.

Testcase: igt/gem_softpin/single-evict-offset
Signed-off-by: Chris Wilson <chris.p.wilson at linux.intel.com>
Signed-off-by: Nitin Gote <nitin.r.gote at intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
index 01b7587dd1f8..e26a70dce77f 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
@@ -1054,10 +1054,14 @@ static int eb_validate_vmas(struct i915_execbuffer *eb)
 			   eb_vma_misplaced(&eb->exec[i], vma, ev->flags));
 	}
 
-	if (!list_empty(&eb->unbound))
-		return eb_reserve(eb);
+	err = 0;
+	if (!list_empty(&eb->unbound)) {
+		err = i915_gem_object_lock(eb->context->vm->root_obj, &eb->ww);
+		if (err == 0)
+			err = eb_reserve(eb);
+	}
 
-	return 0;
+	return err;
 }
 
 static struct eb_vma *
@@ -1904,10 +1908,9 @@ static noinline int eb_relocate_parse_slow(struct i915_execbuffer *eb)
 static int eb_relocate_parse(struct i915_execbuffer *eb)
 {
 	int err;
-	bool throttle = true;
 
 retry:
-	err = eb_pin_engine(eb, throttle);
+	err = eb_pin_engine(eb, true);
 	if (err) {
 		if (err != -EDEADLK)
 			return err;
@@ -1915,9 +1918,6 @@ static int eb_relocate_parse(struct i915_execbuffer *eb)
 		goto err;
 	}
 
-	/* only throttle once, even if we didn't need to throttle */
-	throttle = false;
-
 	err = eb_validate_vmas(eb);
 	if (err == -EAGAIN)
 		goto slow;
-- 
2.25.1



More information about the Intel-gfx-trybot mailing list