[PATCH i-g-t 1/5] tests/intel/xe_pmu: Add a helper function to check and end cork

Riana Tauro riana.tauro at intel.com
Mon May 5 10:29:42 UTC 2025


Add a helper function to check if cork is active and
end cork

Signed-off-by: Riana Tauro <riana.tauro at intel.com>
---
 tests/intel/xe_pmu.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tests/intel/xe_pmu.c b/tests/intel/xe_pmu.c
index 094dc0c6c..03a966708 100644
--- a/tests/intel/xe_pmu.c
+++ b/tests/intel/xe_pmu.c
@@ -134,6 +134,12 @@ static uint64_t get_event_config_fn(unsigned int gt, int function,
 	return get_event_config(gt, eci, event) | add_format_config("function", function);
 }
 
+static void check_and_end_cork(int fd, struct xe_cork *cork)
+{
+	if (cork && !cork->ended)
+		xe_cork_sync_end(fd, cork);
+}
+
 /**
  * SUBTEST: engine-activity-idle
  * Description: Test to validate engine activity shows no load when idle
@@ -172,8 +178,8 @@ static void engine_activity(int fd, struct drm_xe_engine_class_instance *eci, un
 		xe_cork_sync_end(fd, cork);
 	pmu_read_multi(pmu_fd[0], 2, after);
 
-	if ((flags & TEST_LOAD) && !cork->ended)
-		xe_cork_sync_end(fd, cork);
+	if (flags & TEST_LOAD)
+		check_and_end_cork(fd, cork);
 
 	engine_active_ticks = after[0] - before[0];
 	engine_total_ticks = after[1] - before[1];
-- 
2.47.1



More information about the igt-dev mailing list