[PATCH 16/28] drm/i915: Ensure gem_contexts selftests work with unbind changes.

Maarten Lankhorst maarten.lankhorst at linux.intel.com
Tue Sep 28 08:34:15 UTC 2021


In the next commit, we don't evict when refcount = 0, so we need to
call drain freed objects, because we want to pin new bo's in the same
place, causing a test failure.

Give read_from_scratch and write_from_scratch their own offset, just to
ensure i915_vma_pin will not try to pin the VMA in the place where
the previous read/write didn't complete yet.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
---
 drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

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 b32f7fed2d9c..cac102459965 100644
--- a/drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c
@@ -1491,7 +1491,7 @@ static int write_to_scratch(struct i915_gem_context *ctx,
 	u32 *cmd;
 	int err;
 
-	GEM_BUG_ON(offset < I915_GTT_PAGE_SIZE);
+	GEM_BUG_ON(offset < 2 * I915_GTT_PAGE_SIZE);
 
 	err = check_scratch(ctx->vm, offset);
 	if (err)
@@ -1571,6 +1571,7 @@ static int write_to_scratch(struct i915_gem_context *ctx,
 	i915_vm_put(vm);
 out:
 	i915_gem_object_put(obj);
+	i915_gem_drain_freed_objects(i915);
 	return err;
 }
 
@@ -1588,7 +1589,7 @@ static int read_from_scratch(struct i915_gem_context *ctx,
 	u32 *cmd;
 	int err;
 
-	GEM_BUG_ON(offset < I915_GTT_PAGE_SIZE);
+	GEM_BUG_ON(offset < 2 * I915_GTT_PAGE_SIZE);
 
 	err = check_scratch(ctx->vm, offset);
 	if (err)
@@ -1608,7 +1609,7 @@ static int read_from_scratch(struct i915_gem_context *ctx,
 			goto out_vm;
 		}
 
-		err = i915_vma_pin(vma, 0, 0, PIN_USER | PIN_OFFSET_FIXED);
+		err = i915_vma_pin(vma, 0, 0, PIN_USER | PIN_OFFSET_FIXED | I915_GTT_PAGE_SIZE);
 		if (err)
 			goto out_vm;
 
@@ -1724,6 +1725,7 @@ static int read_from_scratch(struct i915_gem_context *ctx,
 	i915_vm_put(vm);
 out:
 	i915_gem_object_put(obj);
+	i915_gem_drain_freed_objects(i915);
 	return err;
 }
 
@@ -1829,7 +1831,7 @@ static int igt_vm_isolation(void *arg)
 
 			/* Leave enough space at offset 0 for the batch */
 			offset = igt_random_offset(&prng,
-						   I915_GTT_PAGE_SIZE, vm_total,
+						   2 * I915_GTT_PAGE_SIZE, vm_total,
 						   sizeof(u32), alignof_dword);
 
 			err = write_to_scratch(ctx_a, engine,
-- 
2.33.0



More information about the Intel-gfx-trybot mailing list