Skip to contentSkip to conversation

Avoid SET_CACHING ioctl during fork

PATCH New Vikas Srivastava 1 participant 1 message Oct 21, 2022

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 Avoid SET_CACHING ioctl during fork

Some subtests for gem_ctx_engines require the SET_CACHING ioctl to run. However, the function that calls it is wrapped by an igt_require and thus causes a skip when the ioctl fails. Unfortunately, MTL currently fails this check with -EOPNOTSUPP.

While the ioctl failing and resulting in a skip wouldn't normally be a problem, the failing call is occasionally made within a forked child process, which causes an error. Fortunately, use of the ioctl can be avoided by using wc instead of cpu for mmapping and domain operations.

v2: Use gem_mmap__device_coherent instead of gem_mmap__wc

---
 tests/i915/gem_ctx_engines.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
tests/i915/gem_ctx_engines.c +4 -7
index b0646516..e9cc25d6 100644
@@ -492,12 +492,10 @@ static void independent(int i915, const intel_ctx_t *base_ctx,
 	}
 	param.ctx_id = gem_context_create(i915);
 	gem_context_set_param(i915, &param);
-
-	if (!gem_has_lmem(i915))
-		gem_set_caching(i915, results.handle, I915_CACHING_CACHED);
-	map = gem_mmap__cpu(i915, results.handle, 0, 4096, PROT_READ);
+	
+	map = gem_mmap__device_coherent(i915, results.handle, 0, 4096, PROT_READ);
 	gem_set_domain(i915, results.handle,
-		       I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU);
+		       I915_GEM_DOMAIN_WC, I915_GEM_DOMAIN_WC);
 
 	for (int i = 0; i < I915_EXEC_RING_MASK + 1; i++) {
 		struct drm_i915_gem_exec_object2 obj[2] = {
@@ -515,8 +513,7 @@ static void independent(int i915, const intel_ctx_t *base_ctx,
 		uint32_t *cs;
 		int j = 0;
 
-		cs = gem_mmap__cpu(i915, obj[1].handle, 0, 4096, PROT_WRITE);
-
+		cs = gem_mmap__device_coherent(i915, obj[1].handle, 0, 4096, PROT_WRITE);
 		cs[j] = 0x24 << 23 | 1; /* SRM */
 		if (has_64bit_reloc)
 			cs[j]++;
Signature · 1 line
2.25.1