[PATCH] tests/intel/xe_drm_fdinfo: Do not destroy NULL xe_cork

Jonathan Cavitt jonathan.cavitt at intel.com
Wed Dec 18 16:08:08 UTC 2024


Several xe_cork functionalities were recently unified into the xe_spin
library.  During this process, it was asserted that we always pass a
valid cork to the various xe_cork helper functions (namely,
xe_cork_sync_start, xe_cork_sync_end, and xe_cork_destroy).

While this assertion should normally hold, in xe_drm_fdinfo
specifically, some subtests declare the existence of an xe_cork but
bypass its initialization through xe_cork_create because the cork is
otherwise unused.  However, the cork itself is unconditionally destroyed
at the end of the tests, as prior to the unification under xe_spin,
passing a NULL pointer to the destroy function (previously
spin_ctx_destroy) would simply exit the function early.  Unfortunately,
passing a NULL pointer to the destroy function now (xe_cork_destory)
hits the new assertion, resulting in an error.

Do not run xe_cork_destroy on a NULL pointer if a NULL pointer is
expected in the subtest.

Fixes: 2feb1d6718a ("lib/xe/xe_spin: move the spinner related functions to lib")
Closes: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/3869
Signed-off-by: Jonathan Cavitt <jonathan.cavitt at intel.com>
CC: Pravalika Gurram <pravalika.gurram at intel.com>
CC: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
---
 tests/intel/xe_drm_fdinfo.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tests/intel/xe_drm_fdinfo.c b/tests/intel/xe_drm_fdinfo.c
index 66a181d5ba..e83c55c646 100644
--- a/tests/intel/xe_drm_fdinfo.c
+++ b/tests/intel/xe_drm_fdinfo.c
@@ -447,7 +447,9 @@ utilization_single(int fd, struct drm_xe_engine_class_instance *hwe, unsigned in
 		close(new_fd);
 	}
 
-	xe_cork_destroy(fd, ctx);
+	if (flags & TEST_BUSY)
+		xe_cork_destroy(fd, ctx);
+
 	xe_vm_destroy(fd, vm);
 }
 
@@ -663,7 +665,8 @@ utilization_multi(int fd, int gt, int class, unsigned int flags)
 		close(fd_spill);
 	}
 
-	xe_cork_destroy(fd, ctx);
+	if (flags & TEST_BUSY)
+		xe_cork_destroy(fd, ctx);
 
 	xe_vm_destroy(fd, vm);
 }
-- 
2.43.0



More information about the igt-dev mailing list