[PATCH i-g-t v6 03/12] benchmarks/kms_fb_stress: Separate the benchmark in a subtest
Arthur Grillo
arthurgrillo at riseup.net
Fri Sep 13 00:39:27 UTC 2024
In the future, we want to add more tests to this. So move the stress
procedure to its own subtest.
Reviewed-by: Louis Chauvet <louis.chauvet at bootlin.com>
Tested-by: Louis Chauvet <louis.chauvet at bootlin.com>
Signed-off-by: Arthur Grillo <arthurgrillo at riseup.net>
---
benchmarks/kms_fb_stress.c | 111 ++++++++++++++++++++++++++-------------------
1 file changed, 65 insertions(+), 46 deletions(-)
diff --git a/benchmarks/kms_fb_stress.c b/benchmarks/kms_fb_stress.c
index 9c6d2b52caad..32d65e5085e0 100644
--- a/benchmarks/kms_fb_stress.c
+++ b/benchmarks/kms_fb_stress.c
@@ -125,6 +125,35 @@ 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;
+
+ 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,
@@ -159,71 +188,61 @@ static struct kms_t default_kms = {
},
};
-
-igt_simple_main
+igt_main
{
- struct data_t data = {0};
- struct timespec then, now;
- double elapsed;
- int ret;
-
- data.kms = default_kms;
+ struct data_t data;
- data.fd = drm_open_driver_master(DRIVER_ANY);
+ igt_fixture {
+ int ret;
- kmstest_set_vt_graphics_mode();
+ data.kms = default_kms;
- ret = drmSetClientCap(data.display.drm_fd, DRM_CLIENT_CAP_WRITEBACK_CONNECTORS, 1);
+ data.fd = drm_open_driver_master(DRIVER_ANY);
- igt_require_f(!ret, "error setting DRM_CLIENT_CAP_WRITEBACK_CONNECTORS\n");
+ igt_display_require(&data.display, data.fd);
- igt_display_require(&data.display, data.fd);
- igt_require(data.display.is_atomic);
+ kmstest_set_vt_graphics_mode();
- igt_display_require_output(&data.display);
+ ret = drmSetClientCap(data.display.drm_fd, DRM_CLIENT_CAP_WRITEBACK_CONNECTORS, 1);
- igt_display_reset(&data.display);
+ igt_require_f(!ret, "error setting DRM_CLIENT_CAP_WRITEBACK_CONNECTORS\n");
- data.wb_output = find_wb_output(&data);
- igt_require(data.wb_output);
- set_wb_pipe(&data);
+ igt_display_require(&data.display, data.fd);
+ igt_require(data.display.is_atomic);
- set_crtc_size(&data);
+ igt_display_require_output(&data.display);
- gen_fbs(&data);
+ igt_display_reset(&data.display);
- data.kms.primary.base = igt_output_get_plane_type(data.wb_output, DRM_PLANE_TYPE_PRIMARY);
- igt_assert(data.kms.primary.base != NULL);
+ data.wb_output = find_wb_output(&data);
+ igt_require(data.wb_output);
+ set_wb_pipe(&data);
- 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);
+ set_crtc_size(&data);
- 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);
+ data.kms.primary.base = igt_output_get_plane_type(data.wb_output,
+ DRM_PLANE_TYPE_PRIMARY);
+ igt_assert(data.kms.primary.base != NULL);
- igt_assert_eq(igt_gettime(&then), 0);
+ 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);
- 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);
+ 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.46.0
More information about the igt-dev
mailing list