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

Umesh Nerlige Ramappa umesh.nerlige.ramappa at intel.com
Wed May 14 22:35:09 UTC 2025


On Mon, May 12, 2025 at 12:35:47PM +0530, Riana Tauro wrote:
>Add a helper function to check if cork is active and
>end cork
>
>v2: use single function (Umesh)
>
>Signed-off-by: Riana Tauro <riana.tauro at intel.com>
>---
> tests/intel/xe_pmu.c | 18 ++++++++++++------
> 1 file changed, 12 insertions(+), 6 deletions(-)
>
>diff --git a/tests/intel/xe_pmu.c b/tests/intel/xe_pmu.c
>index 2e29a4056..9b57b5bfc 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 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
>@@ -169,11 +175,11 @@ static void engine_activity(int fd, struct drm_xe_engine_class_instance *eci, un
> 	pmu_read_multi(pmu_fd[0], 2, before);
> 	usleep(SLEEP_DURATION * USEC_PER_SEC);
> 	if (flags & TEST_TRAILING_IDLE)
>-		xe_cork_sync_end(fd, cork);
>+		end_cork(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)
>+		end_cork(fd, cork);

I think, you could just call end_cork unconditionally here ^.

Rest looks good,

Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa at intel.com>

Thanks,
Umesh

>
> 	engine_active_ticks = after[0] - before[0];
> 	engine_total_ticks = after[1] - before[1];
>@@ -244,7 +250,7 @@ static void engine_activity_all_fn(int fd, struct drm_xe_engine_class_instance *
> 		int idx = i * 2;
>
> 		f = &fn[i];
>-		xe_cork_sync_end(f->fd, f->cork);
>+		end_cork(f->fd, f->cork);
> 		engine_active_ticks = after[idx] - before[idx];
> 		engine_total_ticks = after[idx + 1] - before[idx + 1];
>
>@@ -305,7 +311,7 @@ static void engine_activity_fn(int fd, struct drm_xe_engine_class_instance *eci,
> 	usleep(SLEEP_DURATION * USEC_PER_SEC);
> 	pmu_read_multi(pmu_fd[0], 2, after);
>
>-	xe_cork_sync_end(fn_fd, cork);
>+	end_cork(fn_fd, cork);
>
> 	engine_active_ticks = after[0] - before[0];
> 	engine_total_ticks = after[1] - before[1];
>@@ -433,7 +439,7 @@ static void test_gt_frequency(int fd, struct drm_xe_engine_class_instance *eci)
> 	max[0] = (end[0] - start[0]);
> 	max[1] = (end[1] - start[1]);
>
>-	xe_cork_sync_end(fd, cork);
>+	end_cork(fd, cork);
>
> 	/*
> 	 * Restore min/max.
>-- 
>2.47.1
>


More information about the igt-dev mailing list