[PATCH i-g-t v5 3/8] benchmarks/kms_fb_stress: Separate the benchmark in a subtest

Arthur Grillo arthurgrillo at riseup.net
Mon Apr 22 22:18:18 UTC 2024


In the future, we want to add more tests to this. So move the stress
procedure to its own subtest.

Signed-off-by: Arthur Grillo <arthurgrillo at riseup.net>
---
 benchmarks/kms_fb_stress.c | 138 +++++++++++++++++++++++++--------------------
 1 file changed, 78 insertions(+), 60 deletions(-)

diff --git a/benchmarks/kms_fb_stress.c b/benchmarks/kms_fb_stress.c
index 8d4707f5a8c0..d2d7bd12ca86 100644
--- a/benchmarks/kms_fb_stress.c
+++ b/benchmarks/kms_fb_stress.c
@@ -128,6 +128,51 @@ static void set_crtc_size(struct data_t *data)
 	igt_assert_f(0, "CRTC size %dx%d not supported\n", crtc->width, crtc->height);
 }
 
+static void stress_driver(struct data_t *data)
+{
+	struct timespec then, now;
+	double elapsed;
+
+	igt_info("KMS structure:\n");
+	igt_info("\tCRTC:\n");
+	igt_info("\t\trectangle: " RECT_FMT "\n", RECT_ARG(&data->kms.crtc));
+	igt_info("\tprimary:\n");
+	igt_info("\t\tformat: %s\n", igt_format_str(data->kms.primary.format));
+	igt_info("\t\trectangle: " RECT_FMT "\n", RECT_ARG(&data->kms.primary.rect));
+	igt_info("\toverlay A:\n");
+	igt_info("\t\tformat: %s\n", igt_format_str(data->kms.overlay_a.format));
+	igt_info("\t\trectangle: " RECT_FMT "\n", RECT_ARG(&data->kms.overlay_a.rect));
+	igt_info("\toverlay B:\n");
+	igt_info("\t\tformat: %s\n", igt_format_str(data->kms.overlay_b.format));
+	igt_info("\t\trectangle: " RECT_FMT "\n", RECT_ARG(&data->kms.overlay_b.rect));
+	igt_info("\twriteback:\n");
+	igt_info("\t\tformat: %s\n", igt_format_str(data->kms.writeback.format));
+	igt_info("\t\trectangle: " RECT_FMT "\n", RECT_ARG(&data->kms.writeback.rect));
+
+	gen_fbs(data);
+
+	igt_assert_eq(igt_gettime(&then), 0);
+
+	for (int i = 0; i < FRAME_COUNT; i++) {
+		int fb_index = i % NUM_FBS;
+
+		plane_setup(&data->kms.primary, fb_index);
+
+		plane_setup(&data->kms.overlay_a, fb_index);
+
+		plane_setup(&data->kms.overlay_b, fb_index);
+
+		igt_output_set_writeback_fb(data->wb_output, &data->kms.writeback.fbs[fb_index]);
+
+		igt_display_commit2(&data->display, COMMIT_ATOMIC);
+	}
+
+	igt_assert_eq(igt_gettime(&now), 0);
+	elapsed = igt_time_elapsed(&then, &now);
+
+	igt_info("Time spent in the loop with %d frames: %lfs.\n", FRAME_COUNT, elapsed);
+}
+
 static struct kms_t default_kms = {
 	.crtc = {
 		.width = 4096, .height = 2160,
@@ -162,82 +207,55 @@ static struct kms_t default_kms = {
 	},
 };
 
-
-igt_simple_main
+igt_main
 {
-	struct data_t data = {0};
-	struct timespec then, now;
-	double elapsed;
-
-	data.kms = default_kms;
-
-	data.fd = drm_open_driver_master(DRIVER_ANY);
+	struct data_t data;
 
-	kmstest_set_vt_graphics_mode();
+	igt_fixture {
+		data.kms = default_kms;
 
-	igt_display_require(&data.display, data.fd);
-	igt_require(data.display.is_atomic);
+		data.fd = drm_open_driver_master(DRIVER_ANY);
 
-	igt_display_require_output(&data.display);
+		igt_display_require(&data.display, data.fd);
 
-	igt_display_reset(&data.display);
-
-	data.wb_output = find_wb_output(&data);
-	igt_require(data.wb_output);
-	set_wb_pipe(&data);
-
-	set_crtc_size(&data);
-
-	gen_fbs(&data);
-
-	igt_info("KMS structure:\n");
-	igt_info("\tCRTC:\n");
-	igt_info("\t\trectangle: " RECT_FMT "\n", RECT_ARG(&data.kms.crtc));
-	igt_info("\tprimary:\n");
-	igt_info("\t\tformat: %s\n", igt_format_str(data.kms.primary.format));
-	igt_info("\t\trectangle: " RECT_FMT "\n", RECT_ARG(&data.kms.primary.rect));
-	igt_info("\toverlay A:\n");
-	igt_info("\t\tformat: %s\n", igt_format_str(data.kms.overlay_a.format));
-	igt_info("\t\trectangle: " RECT_FMT "\n", RECT_ARG(&data.kms.overlay_a.rect));
-	igt_info("\toverlay B:\n");
-	igt_info("\t\tformat: %s\n", igt_format_str(data.kms.overlay_b.format));
-	igt_info("\t\trectangle: " RECT_FMT "\n", RECT_ARG(&data.kms.overlay_b.rect));
-	igt_info("\twriteback:\n");
-	igt_info("\t\tformat: %s\n", igt_format_str(data.kms.writeback.format));
-	igt_info("\t\trectangle: " RECT_FMT "\n", RECT_ARG(&data.kms.writeback.rect));
+		kmstest_set_vt_graphics_mode();
 
-	data.kms.primary.base = igt_output_get_plane_type(data.wb_output, DRM_PLANE_TYPE_PRIMARY);
-	igt_assert(data.kms.primary.base != NULL);
+		igt_display_require(&data.display, data.fd);
+		igt_require(data.display.is_atomic);
 
-	data.kms.overlay_a.base = igt_output_get_plane_type_index(data.wb_output,
-								  DRM_PLANE_TYPE_OVERLAY, 0);
-	igt_assert(data.kms.overlay_a.base != NULL);
+		igt_display_require_output(&data.display);
 
-	data.kms.overlay_b.base = igt_output_get_plane_type_index(data.wb_output,
-								  DRM_PLANE_TYPE_OVERLAY, 1);
-	igt_assert(data.kms.overlay_b.base != NULL);
+		igt_display_reset(&data.display);
 
-	igt_assert_eq(igt_gettime(&then), 0);
+		data.wb_output = find_wb_output(&data);
+		igt_require(data.wb_output);
+		set_wb_pipe(&data);
 
-	for (int i = 0; i < FRAME_COUNT; i++) {
-		int fb_index = i % NUM_FBS;
+		set_crtc_size(&data);
 
-		plane_setup(&data.kms.primary, fb_index);
+		data.kms.primary.base = igt_output_get_plane_type(data.wb_output,
+								  DRM_PLANE_TYPE_PRIMARY);
+		igt_assert(data.kms.primary.base != NULL);
 
-		plane_setup(&data.kms.overlay_a, fb_index);
+		data.kms.overlay_a.base = igt_output_get_plane_type_index(data.wb_output,
+									  DRM_PLANE_TYPE_OVERLAY,
+									  0);
+		igt_assert(data.kms.overlay_a.base != NULL);
 
-		plane_setup(&data.kms.overlay_b, fb_index);
+		data.kms.overlay_b.base = igt_output_get_plane_type_index(data.wb_output,
+									  DRM_PLANE_TYPE_OVERLAY,
+									  1);
+		igt_assert(data.kms.overlay_b.base != NULL);
+	}
 
-		igt_output_set_writeback_fb(data.wb_output, &data.kms.writeback.fbs[fb_index]);
+	igt_subtest("default-stress") {
+		stress_driver(&data);
 
-		igt_display_commit2(&data.display, COMMIT_ATOMIC);
 	}
 
-	igt_assert_eq(igt_gettime(&now), 0);
-	elapsed = igt_time_elapsed(&then, &now);
-
-	igt_info("Time spent in the loop with %d frames: %lfs.\n", FRAME_COUNT, elapsed);
 
-	igt_display_fini(&data.display);
-	drm_close_driver(data.fd);
+	igt_fixture {
+		igt_display_fini(&data.display);
+		drm_close_driver(data.fd);
+	}
 }

-- 
2.44.0



More information about the igt-dev mailing list