[RFC 3/9] drm/i915: Clarify colour choices in eviction mock test

Tvrtko Ursulin tvrtko.ursulin at linux.intel.com
Tue Aug 1 13:34:55 UTC 2023


From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>

Clarify that the colours used in the mock test do not have to have any
connection to real values from a working driver and simplify the code by
doing so.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
---
 drivers/gpu/drm/i915/selftests/i915_gem_evict.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_evict.c b/drivers/gpu/drm/i915/selftests/i915_gem_evict.c
index f8fe3681c3dc..bfde7aff3b6f 100644
--- a/drivers/gpu/drm/i915/selftests/i915_gem_evict.c
+++ b/drivers/gpu/drm/i915/selftests/i915_gem_evict.c
@@ -243,10 +243,11 @@ static int igt_evict_for_cache_color(void *arg)
 	struct intel_gt *gt = arg;
 	struct i915_ggtt *ggtt = gt->ggtt;
 	const unsigned long flags = PIN_OFFSET_FIXED;
+	const unsigned int pat_index = 0;
 	struct drm_mm_node target = {
 		.start = I915_GTT_PAGE_SIZE * 2,
 		.size = I915_GTT_PAGE_SIZE,
-		.color = i915_gem_get_pat_index(gt->i915, I915_CACHE_LLC),
+		.color = pat_index,
 	};
 	struct drm_i915_gem_object *obj;
 	struct i915_vma *vma;
@@ -267,7 +268,7 @@ static int igt_evict_for_cache_color(void *arg)
 		err = PTR_ERR(obj);
 		goto cleanup;
 	}
-	i915_gem_object_set_cache_coherency(obj, I915_CACHE_LLC);
+	i915_gem_object_set_pat_index(obj, pat_index);
 	quirk_add(obj, &objects);
 
 	vma = i915_gem_object_ggtt_pin(obj, NULL, 0, 0,
@@ -283,7 +284,7 @@ static int igt_evict_for_cache_color(void *arg)
 		err = PTR_ERR(obj);
 		goto cleanup;
 	}
-	i915_gem_object_set_cache_coherency(obj, I915_CACHE_LLC);
+	i915_gem_object_set_pat_index(obj, pat_index);
 	quirk_add(obj, &objects);
 
 	/* Neighbouring; same colour - should fit */
@@ -306,10 +307,14 @@ static int igt_evict_for_cache_color(void *arg)
 		goto cleanup;
 	}
 
-	/* Attempt to remove the first *pinned* vma, by removing the (empty)
+	/*
+	 * Attempt to remove the first *pinned* vma, by removing the (empty)
 	 * neighbour -- this should fail.
+	 *
+	 * We can use made up cache color since everything that we need is that
+	 * it differs from the color used for the pinned objects.
 	 */
-	target.color = i915_gem_get_pat_index(gt->i915, I915_CACHE_L3_LLC);
+	target.color = pat_index + 1;
 
 	mutex_lock(&ggtt->vm.mutex);
 	err = i915_gem_evict_for_node(&ggtt->vm, NULL, &target, 0);
-- 
2.39.2



More information about the Intel-gfx-trybot mailing list