[igt-dev] [PATCH i-g-t] i915/i915_pm_rps: Don't use gem_write in batch_create

Karolina Drobnik karolina.drobnik at intel.com
Thu Aug 4 13:26:17 UTC 2022


From: Chris Wilson <chris at chris-wilson.co.uk>

In fence_order and engine_order we are repeatedly creating big mmaps
that are very slow when done via gem_write, causing test timeouts.
Rewrite batch_create to mmap the buffer directly instead of using
gem_write.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Signed-off-by: Karolina Drobnik <karolina.drobnik at intel.com>
---
 tests/i915/i915_pm_rps.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/tests/i915/i915_pm_rps.c b/tests/i915/i915_pm_rps.c
index a45a6905..d06ade27 100644
--- a/tests/i915/i915_pm_rps.c
+++ b/tests/i915/i915_pm_rps.c
@@ -621,11 +621,15 @@ static uint32_t batch_create(int i915, uint64_t sz)
 	const uint32_t bbe = MI_BATCH_BUFFER_END;
 	const uint32_t chk = 0x5 << 23;
 	uint32_t handle = gem_create(i915, sz);
+	uint32_t *map;
 
-	for (uint64_t pg = 4096; pg + 4096 < sz; pg += 4096)
-		gem_write(i915, handle, pg, &chk, sizeof(chk));
+	map = gem_mmap__device_coherent(i915, handle, 0, sz, PROT_WRITE);
 
-	gem_write(i915, handle, sz - sizeof(bbe), &bbe, sizeof(bbe));
+	for (uint64_t pg = 1; pg * 4096 < sz; pg++)
+		map[(pg * 4096) / sizeof(*map)] = chk;
+
+	map[sz / sizeof(*map) - 1] = bbe;
+	munmap(map, sz);
 
 	return handle;
 }
-- 
2.25.1



More information about the igt-dev mailing list