Skip to contentSkip to conversation

lib/xe/xe_legacy: Cleanups in xe_legacy_test_mode()

PATCH Superseded Shuicheng Lin 2 participants 2 messages Jan 15

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/xe/xe_legacy: Cleanups in xe_legacy_test_mode()

This commit performs a set of small cleanups in xe_legacy_test_mode():
1. Remove a duplicate comment for BATCH_DW_COUNT.
2. Move LONG_SPIN ctx_ticks initialization to after the fd is opened.
3. Add an assertion for CLOSE_FD to prevent fd leaks.
4. Replace space with tab in syncobj_create() line.
5. Unmap data before returning to avoid a VM leak.
6. As i start from n_execs, which always will be non-zero, base_addr always will be assgined with addr.

Except for item 5, these changes should have no functional impact.

---
 lib/xe/xe_legacy.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
lib/xe/xe_legacy.c +10 -8
index 4a6244657..5eacbb75a 100644
@@ -22,7 +22,6 @@
 #define CAT_ERROR			(0x1 << 5)
 #define CLOSE_EXEC_QUEUES		(0x1 << 2)
 #define CLOSE_FD			(0x1 << 1)
-/* Batch buffer element count, in number of dwords(u32) */
 #define GT_RESET			(0x1 << 0)
 #define MAX_N_EXECQUEUES		16
 
@@ -71,9 +70,6 @@ xe_legacy_test_mode(int fd, struct drm_xe_engine_class_instance *eci,
 	} *data;
 	struct xe_spin_opts spin_opts = {
 		.preempt = flags & PREEMPT,
-#define THREE_SEC	(3 * 1000000000ull)
-		.ctx_ticks = flags & LONG_SPIN ?
-			xe_spin_nsec_to_ticks(fd, 0, THREE_SEC) : 0,
 	};
 	int i, b, hang_exec_queue = n_exec_queues / 2;
 	int fault_position = 0;
@@ -90,8 +86,14 @@ xe_legacy_test_mode(int fd, struct drm_xe_engine_class_instance *eci,
 	if (flags & COMPRESSION)
 		igt_require(intel_gen(intel_get_drm_devid(fd)) >= 20);
 
-	if (flags & CLOSE_FD)
+	if (flags & CLOSE_FD) {
+		igt_assert_eq(fd, -1);
 		fd = drm_open_driver(DRIVER_XE);
+	}
+
+#define THREE_SEC	(3 * 1000000000ull)
+	if (flags & LONG_SPIN)
+		spin_opts.ctx_ticks = xe_spin_nsec_to_ticks(fd, 0, THREE_SEC);
 
 	vm = xe_vm_create(fd, 0, 0);
 	bo_size = sizeof(*data) * (n_execs + extra_execs);
@@ -128,7 +130,7 @@ xe_legacy_test_mode(int fd, struct drm_xe_engine_class_instance *eci,
 		} else {
 			exec_queues[i] = xe_exec_queue_create(fd, vm, eci, 0);
 		}
- 		syncobjs[i] = syncobj_create(fd, 0);
+		syncobjs[i] = syncobj_create(fd, 0);
 	}
 
 	sync[0].handle = syncobj_create(fd, 0);
@@ -202,6 +204,7 @@ xe_legacy_test_mode(int fd, struct drm_xe_engine_class_instance *eci,
 			for (i = 0; i < n_exec_queues; i++)
 				xe_exec_queue_destroy(fd, exec_queues[i]);
 		}
+		munmap(data, bo_size);
 		drm_close_driver(fd);
 		/* FIXME: wait for idle */
 		usleep(150000);
@@ -214,8 +217,7 @@ xe_legacy_test_mode(int fd, struct drm_xe_engine_class_instance *eci,
 	igt_assert(syncobj_wait(fd, &sync[0].handle, 1, INT64_MAX, 0, NULL));
 
 	for (i = n_execs; i < n_execs + extra_execs; i++) {
-		u64 base_addr = (!use_capture_mode && (flags & CAT_ERROR) && !i)
-			? (addr + bo_size * 128) : addr;
+		u64 base_addr = addr;
 		u64 batch_offset = (char *)&data[i].batch - (char *)data;
 		u64 batch_addr = base_addr + batch_offset;
 		u64 sdi_offset = (char *)&data[i].data - (char *)data;
Signature · 1 line
2.43.0
#1 lore raw

✗ Fi.CI.BUILD: failure for lib/xe/xe_legacy: Cleanups in xe_legacy_test_mode()

== Series Details ==

== Series Details ==

Series: lib/xe/xe_legacy: Cleanups in xe_legacy_test_mode()
URL : https://patchwork.freedesktop.org/series/160162/
State : failure

== Summary ==

Applying: lib/xe/xe_legacy: Cleanups in xe_legacy_test_mode() Patch failed at 0001 lib/xe/xe_legacy: Cleanups in xe_legacy_test_mode() When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".