Skip to contentSkip to conversation

tests/kms_async_flips: Test Cleanup

PATCH In review Karthik B S 3 participants 7 messages Apr 25, 2022 – May 16, 2022

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 tests/kms_async_flips: Test Cleanup

-Convert tests to dynamic
-Replace drm function call with existing library functions -igt_display_reset() before all subtests

v2: -Move conversion to dynamic subtest to a separate patch (Bhanu)
-Use igt_output_get_mode to get default mode (Bhanu) -Add 'is_atomic' check before igt_display_commit2 (Bhanu)

v3: -Move test_init after the checks to skip subtest (Bhanu)
-Update the logic to call make_fb() in test_init()

---
 tests/kms_async_flips.c | 221 +++++++++++++++++++++++++++-------------
 1 file changed, 151 insertions(+), 70 deletions(-)
tests/kms_async_flips.c +151 -70
index 5e11cd43..1b5af111 100644
@@ -50,7 +50,7 @@ typedef struct {
 	uint32_t refresh_rate;
 	struct igt_fb bufs[4];
 	igt_display_t display;
-	drmModeConnectorPtr connector;
+	igt_output_t *output;
 	unsigned long flip_timestamp_us;
 	double flip_interval;
 	igt_pipe_crc_t *pipe_crc;
@@ -58,24 +58,9 @@ typedef struct {
 	int flip_count;
 	int frame_count;
 	bool flip_pending;
+	bool extended;
 } data_t;
 
-static drmModeConnectorPtr find_connector_for_modeset(data_t *data)
-{
-	igt_output_t *output;
-	drmModeConnectorPtr ret = NULL;
-
-	for_each_connected_output(&data->display, output) {
-		if (output->config.connector->count_modes > 0) {
-			ret = output->config.connector;
-			break;
-		}
-	}
-
-	igt_assert_f(ret, "Connector NOT found\n");
-	return ret;
-}
-
 static void flip_handler(int fd_, unsigned int sequence, unsigned int tv_sec,
 			 unsigned int tv_usec, void *_data)
 {
@@ -129,14 +114,10 @@ static void wait_flip_event(data_t *data)
 }
 
 static void make_fb(data_t *data, struct igt_fb *fb,
-		    drmModeConnectorPtr connector, int index)
+		    uint32_t width, uint32_t height, int index)
 {
-	uint32_t width, height;
 	int rec_width;
 
-	width = connector->modes[0].hdisplay;
-	height = connector->modes[0].vdisplay;
-
 	rec_width = width / (ARRAY_SIZE(data->bufs) * 2);
 
 	igt_create_fb(data->drm_fd, width, height, DRM_FORMAT_XRGB8888,
@@ -154,6 +135,61 @@ static void require_monotonic_timestamp(int fd)
 		      "Monotonic timestamps not supported\n");
 }
 
+static enum pipe get_pipe_for_output(igt_display_t *display, igt_output_t *output)
+{
+	enum pipe pipe;
+
+	for_each_pipe(display, pipe) {
+		if (igt_pipe_connector_valid(pipe, output))
+			return pipe;
+	}
+
+	igt_assert_f(false, "No pipe found for output %s\n",
+		     igt_output_name(output));
+}
+
+static void test_init(data_t *data)
+{
+	int i;
+	uint32_t width, height;
+	enum pipe pipe;
+	igt_plane_t *plane;
+	static uint32_t prev_output_id;
+	drmModeModeInfo *mode;
+
+	igt_display_reset(&data->display);
+	igt_display_commit(&data->display);
+
+	pipe = get_pipe_for_output(&data->display, data->output);
+
+	mode = igt_output_get_mode(data->output);
+	width = mode->hdisplay;
+	height = mode->vdisplay;
+
+	data->crtc_id = data->display.pipes[pipe].crtc_id;
+	data->refresh_rate = mode->vrefresh;
+
+	igt_output_set_pipe(data->output, pipe);
+	plane = igt_output_get_plane_type(data->output, DRM_PLANE_TYPE_PRIMARY);
+
+	if (prev_output_id != data->output->id) {
+		prev_output_id = data->output->id;
+
+		if (data->bufs[0].fb_id) {
+			for (i = 0; i < ARRAY_SIZE(data->bufs); i++)
+				igt_remove_fb(data->drm_fd, &data->bufs[i]);
+	}
+
+		for (i = 0; i < ARRAY_SIZE(data->bufs); i++)
+			make_fb(data, &data->bufs[i], width, height, i);
+	}
+
+	igt_plane_set_fb(plane, &data->bufs[0]);
+	igt_plane_set_size(plane, width, height);
+
+	igt_display_commit2(&data->display, data->display.is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
+}
+
 static void test_async_flip(data_t *data, bool alternate_sync_async)
 {
 	int ret, frame;
@@ -161,6 +197,7 @@ static void test_async_flip(data_t *data, bool alternate_sync_async)
 	struct timeval start, end, diff;
 
 	require_monotonic_timestamp(data->drm_fd);
+	test_init(data);
 
 	gettimeofday(&start, NULL);
 	frame = 1;
@@ -254,6 +291,7 @@ static void test_timestamp(data_t *data)
 	int ret;
 
 	require_monotonic_timestamp(data->drm_fd);
+	test_init(data);
 
 	/*
 	 * In older platforms(<= gen10), async address update bit is double buffered.
@@ -312,6 +350,8 @@ static void test_cursor(data_t *data)
 	do_or_die(drmGetCap(data->drm_fd, DRM_CAP_CURSOR_WIDTH, &width));
 	do_or_die(drmGetCap(data->drm_fd, DRM_CAP_CURSOR_WIDTH, &height));
 
+	test_init(data);
+
 	igt_create_color_fb(data->drm_fd, width, height, DRM_FORMAT_ARGB8888,
 			    DRM_FORMAT_MOD_LINEAR, 1., 1., 1., &cursor_fb);
 
@@ -346,13 +386,17 @@ static void test_invalid(data_t *data)
 	int ret;
 	uint32_t width, height;
 	struct igt_fb fb;
+	drmModeModeInfo *mode;
 
-	width = data->connector->modes[0].hdisplay;
-	height = data->connector->modes[0].vdisplay;
+	mode = igt_output_get_mode(data->output);
+	width = mode->hdisplay;
+	height = mode->vdisplay;
 
 	igt_require(igt_display_has_format_mod(&data->display, DRM_FORMAT_XRGB8888,
 					       I915_FORMAT_MOD_Y_TILED));
 
+	test_init(data);
+
 	igt_create_fb(data->drm_fd, width, height, DRM_FORMAT_XRGB8888,
 		      I915_FORMAT_MOD_Y_TILED, &fb);
 
@@ -367,33 +411,6 @@ static void test_invalid(data_t *data)
 	igt_remove_fb(data->drm_fd, &fb);
 }
 
-static void test_init(data_t *data)
-{
-	drmModeResPtr res;
-	int i, ret;
-
-	res = drmModeGetResources(data->drm_fd);
-	igt_assert(res);
-
-	kmstest_unset_all_crtcs(data->drm_fd, res);
-
-	data->connector = find_connector_for_modeset(data);
-	data->crtc_id = kmstest_find_crtc_for_connector(data->drm_fd,
-							res, data->connector, 0);
-
-	data->refresh_rate = data->connector->modes[0].vrefresh;
-
-	for (i = 0; i < ARRAY_SIZE(data->bufs); i++)
-		make_fb(data, &data->bufs[i], data->connector, i);
-
-	ret = drmModeSetCrtc(data->drm_fd, data->crtc_id, data->bufs[0].fb_id, 0, 0,
-			     &data->connector->connector_id, 1, &data->connector->modes[0]);
-
-	igt_assert(ret == 0);
-
-	drmModeFreeResources(res);
-}
-
 static void queue_vblank(data_t *data)
 {
 	int pipe = kmstest_get_pipe_from_crtc_id(data->drm_fd, data->crtc_id);
@@ -490,11 +507,14 @@ static void test_crc(data_t *data)
 	data->frame_count = 0;
 	data->flip_pending = false;
 
+	test_init(data);
+
 	igt_draw_fill_fb(data->drm_fd, &data->bufs[frame], 0xff0000ff);
 	igt_draw_fill_fb(data->drm_fd, &data->bufs[!frame], 0xff0000ff);
 
 	ret = drmModeSetCrtc(data->drm_fd, data->crtc_id, data->bufs[frame].fb_id, 0, 0,
-			     &data->connector->connector_id, 1, &data->connector->modes[0]);
+			     &data->output->config.connector->connector_id, 1,
+			     &data->output->config.connector->modes[0]);
 	igt_assert_eq(ret, 0);
 
 	data->pipe_crc = igt_pipe_crc_new(data->drm_fd,
@@ -531,10 +551,28 @@ static void test_crc(data_t *data)
 	igt_assert_lt(data->frame_count * 2, data->flip_count);
 }
 
-igt_main
+static int opt_handler(int opt, int opt_index, void *_data)
+{
+	data_t *data = _data;
+
+	switch (opt) {
+	case 'e':
+		data->extended = true;
+		break;
+	}
+
+	return IGT_OPT_HANDLER_SUCCESS;
+}
+
+static const char help_str[] =
+	"  --e \t\tRun the extended tests\n";
+
+static data_t data;
+
+igt_main_args("e", NULL, help_str, opt_handler, &data)
 {
-	static data_t data;
 	int i;
+	igt_output_t *output;
 
 	igt_fixture {
 		data.drm_fd = drm_open_driver_master(DRIVER_ANY);
@@ -548,32 +586,72 @@ igt_main
 
 	igt_describe("Verify the async flip functionality and the fps during async flips");
 	igt_subtest_group {
-		igt_fixture
-			test_init(&data);
-
 		igt_describe("Wait for page flip events in between successive asynchronous flips");
-		igt_subtest("async-flip-with-page-flip-events")
-			test_async_flip(&data, false);
+		igt_subtest("async-flip-with-page-flip-events") {
+			for_each_connected_output(&data.display, output) {
+				data.output = output;
+				test_async_flip(&data, false);
+
+				if (!data.extended)
+					break;
+			}
+		}
 
 		igt_describe("Alternate between sync and async flips");
-		igt_subtest("alternate-sync-async-flip")
-			test_async_flip(&data, true);
+		igt_subtest("alternate-sync-async-flip") {
+			for_each_connected_output(&data.display, output) {
+				data.output = output;
+				test_async_flip(&data, true);
+
+				if (!data.extended)
+					break;
+			}
+		}
+
 
 		igt_describe("Verify that the async flip timestamp does not coincide with either previous or next vblank");
-		igt_subtest("test-time-stamp")
-			test_timestamp(&data);
+		igt_subtest("test-time-stamp") {
+			for_each_connected_output(&data.display, output) {
+				data.output = output;
+				test_timestamp(&data);
+
+				if (!data.extended)
+					break;
+			}
+		}
 
 		igt_describe("Verify that the DRM_IOCTL_MODE_CURSOR passes after async flip");
-		igt_subtest("test-cursor")
-			test_cursor(&data);
+		igt_subtest("test-cursor") {
+			for_each_connected_output(&data.display, output) {
+				data.output = output;
+				test_cursor(&data);
+
+				if (!data.extended)
+					break;
+			}
+		}
 
 		igt_describe("Negative case to verify if changes in fb are rejected from kernel as expected");
-		igt_subtest("invalid-async-flip")
-			test_invalid(&data);
+		igt_subtest("invalid-async-flip") {
+			for_each_connected_output(&data.display, output) {
+				data.output = output;
+				test_invalid(&data);
+
+				if (!data.extended)
+					break;
+			}
+		}
 
 		igt_describe("Use CRC to verify async flip scans out the correct framebuffer");
-		igt_subtest("crc")
-			test_crc(&data);
+		igt_subtest("crc") {
+			for_each_connected_output(&data.display, output) {
+				data.output = output;
+				test_crc(&data);
+
+				if (!data.extended)
+					break;
+			}
+		}
 
 		igt_fixture {
 			for (i = 0; i < ARRAY_SIZE(data.bufs); i++)
@@ -581,6 +659,9 @@ igt_main
 		}
 	}
 
-	igt_fixture
+	igt_fixture {
+		igt_display_reset(&data.display);
+		igt_display_commit(&data.display);
 		igt_display_fini(&data.display);
+	}
 }
Signature · 1 line
2.22.0
#1 lore raw

PATCH v3 2/2 tests/kms_async_flips: Convert tests to dynamic

v2: -Get the mode after igt_display_reset() (Bhanu)

---
 tests/kms_async_flips.c | 135 ++++++++++++++++++++++------------------
 1 file changed, 75 insertions(+), 60 deletions(-)
tests/kms_async_flips.c +75 -60
index 1b5af111..eeeb8a40 100644
@@ -59,6 +59,7 @@ typedef struct {
 	int frame_count;
 	bool flip_pending;
 	bool extended;
+	enum pipe pipe;
 } data_t;
 
 static void flip_handler(int fd_, unsigned int sequence, unsigned int tv_sec,
@@ -135,24 +136,10 @@ static void require_monotonic_timestamp(int fd)
 		      "Monotonic timestamps not supported\n");
 }
 
-static enum pipe get_pipe_for_output(igt_display_t *display, igt_output_t *output)
-{
-	enum pipe pipe;
-
-	for_each_pipe(display, pipe) {
-		if (igt_pipe_connector_valid(pipe, output))
-			return pipe;
-	}
-
-	igt_assert_f(false, "No pipe found for output %s\n",
-		     igt_output_name(output));
-}
-
 static void test_init(data_t *data)
 {
 	int i;
 	uint32_t width, height;
-	enum pipe pipe;
 	igt_plane_t *plane;
 	static uint32_t prev_output_id;
 	drmModeModeInfo *mode;
@@ -160,16 +147,14 @@ static void test_init(data_t *data)
 	igt_display_reset(&data->display);
 	igt_display_commit(&data->display);
 
-	pipe = get_pipe_for_output(&data->display, data->output);
-
 	mode = igt_output_get_mode(data->output);
 	width = mode->hdisplay;
 	height = mode->vdisplay;
 
-	data->crtc_id = data->display.pipes[pipe].crtc_id;
+	data->crtc_id = data->display.pipes[data->pipe].crtc_id;
 	data->refresh_rate = mode->vrefresh;
 
-	igt_output_set_pipe(data->output, pipe);
+	igt_output_set_pipe(data->output, data->pipe);
 	plane = igt_output_get_plane_type(data->output, DRM_PLANE_TYPE_PRIMARY);
 
 	if (prev_output_id != data->output->id) {
@@ -573,6 +558,7 @@ igt_main_args("e", NULL, help_str, opt_handler, &data)
 {
 	int i;
 	igt_output_t *output;
+	enum pipe pipe;
 
 	igt_fixture {
 		data.drm_fd = drm_open_driver_master(DRIVER_ANY);
@@ -587,69 +573,98 @@ igt_main_args("e", NULL, help_str, opt_handler, &data)
 	igt_describe("Verify the async flip functionality and the fps during async flips");
 	igt_subtest_group {
 		igt_describe("Wait for page flip events in between successive asynchronous flips");
-		igt_subtest("async-flip-with-page-flip-events") {
-			for_each_connected_output(&data.display, output) {
-				data.output = output;
-				test_async_flip(&data, false);
-
-				if (!data.extended)
-					break;
+		igt_subtest_with_dynamic("async-flip-with-page-flip-events") {
+			for_each_pipe_static(pipe) {
+				for_each_valid_output_on_pipe(&data.display, pipe, output) {
+					igt_dynamic_f("%s-pipe-%s", output->name, kmstest_pipe_name(pipe)) {
+						data.output = output;
+						data.pipe = pipe;
+						test_async_flip(&data, false);
+					}
+
+					if (!data.extended)
+						break;
+				}
 			}
 		}
 
 		igt_describe("Alternate between sync and async flips");
-		igt_subtest("alternate-sync-async-flip") {
-			for_each_connected_output(&data.display, output) {
-				data.output = output;
-				test_async_flip(&data, true);
-
-				if (!data.extended)
-					break;
+		igt_subtest_with_dynamic("alternate-sync-async-flip") {
+			for_each_pipe_static(pipe) {
+				for_each_valid_output_on_pipe(&data.display, pipe, output) {
+					igt_dynamic_f("%s-pipe-%s", output->name, kmstest_pipe_name(pipe)) {
+						data.output = output;
+						data.pipe = pipe;
+						test_async_flip(&data, true);
+					}
+
+					if (!data.extended)
+						break;
+				}
 			}
 		}
 
-
 		igt_describe("Verify that the async flip timestamp does not coincide with either previous or next vblank");
-		igt_subtest("test-time-stamp") {
-			for_each_connected_output(&data.display, output) {
-				data.output = output;
-				test_timestamp(&data);
-
-				if (!data.extended)
+		igt_subtest_with_dynamic("test-time-stamp") {
+			for_each_pipe_static(pipe) {
+				for_each_valid_output_on_pipe(&data.display, pipe, output) {
+					igt_dynamic_f("%s-pipe-%s", output->name, kmstest_pipe_name(pipe)) {
+						data.output = output;
+						data.pipe = pipe;
+						test_timestamp(&data);
+					}
+
+					if (!data.extended)
 					break;
+				}
 			}
 		}
 
 		igt_describe("Verify that the DRM_IOCTL_MODE_CURSOR passes after async flip");
-		igt_subtest("test-cursor") {
-			for_each_connected_output(&data.display, output) {
-				data.output = output;
-				test_cursor(&data);
-
-				if (!data.extended)
-					break;
+		igt_subtest_with_dynamic("test-cursor") {
+			for_each_pipe_static(pipe) {
+				for_each_valid_output_on_pipe(&data.display, pipe, output) {
+					igt_dynamic_f("%s-pipe-%s", output->name, kmstest_pipe_name(pipe)) {
+						data.output = output;
+						data.pipe = pipe;
+						test_cursor(&data);
+					}
+
+					if (!data.extended)
+						break;
+				}
 			}
 		}
 
 		igt_describe("Negative case to verify if changes in fb are rejected from kernel as expected");
-		igt_subtest("invalid-async-flip") {
-			for_each_connected_output(&data.display, output) {
-				data.output = output;
-				test_invalid(&data);
-
-				if (!data.extended)
-					break;
+		igt_subtest_with_dynamic("invalid-async-flip") {
+			for_each_pipe_static(pipe) {
+				for_each_valid_output_on_pipe(&data.display, pipe, output) {
+					igt_dynamic_f("%s-pipe-%s", output->name, kmstest_pipe_name(pipe)) {
+						data.output = output;
+						data.pipe = pipe;
+						test_invalid(&data);
+					}
+
+					if (!data.extended)
+						break;
+				}
 			}
 		}
 
 		igt_describe("Use CRC to verify async flip scans out the correct framebuffer");
-		igt_subtest("crc") {
-			for_each_connected_output(&data.display, output) {
-				data.output = output;
-				test_crc(&data);
-
-				if (!data.extended)
-					break;
+		igt_subtest_with_dynamic("crc") {
+			for_each_pipe_static(pipe) {
+				for_each_valid_output_on_pipe(&data.display, pipe, output) {
+					igt_dynamic_f("%s-pipe-%s", output->name, kmstest_pipe_name(pipe)) {
+						data.output = output;
+						data.pipe = pipe;
+						test_crc(&data);
+					}
+
+					if (!data.extended)
+						break;
+				}
 			}
 		}
 
Signature · 1 line
2.22.0
#2 lore raw

Re: [igt-dev] [PATCH i-g-t v3 2/2] tests/kms_async_flips: Convert tests to dynamic

Quoted 74 lines · Karthik B S

v2: -Get the mode after igt_display_reset() (Bhanu)

---
  tests/kms_async_flips.c | 135 ++++++++++++++++++++++------------------
  1 file changed, 75 insertions(+), 60 deletions(-)
tests/kms_async_flips.c +4 -18
index 1b5af111..eeeb8a40 100644
@@ -59,6 +59,7 @@ typedef struct {
  	int frame_count;
  	bool flip_pending;
  	bool extended;
+	enum pipe pipe;
  } data_t;
 
  static void flip_handler(int fd_, unsigned int sequence, unsigned int tv_sec,
@@ -135,24 +136,10 @@ static void require_monotonic_timestamp(int fd)
  		      "Monotonic timestamps not supported\n");
  }
 
-static enum pipe get_pipe_for_output(igt_display_t *display, igt_output_t *output)
-{
-	enum pipe pipe;
-
-	for_each_pipe(display, pipe) {
-		if (igt_pipe_connector_valid(pipe, output))
-			return pipe;
-	}
-
-	igt_assert_f(false, "No pipe found for output %s\n",
-		     igt_output_name(output));
-}
-
  static void test_init(data_t *data)
  {
  	int i;
  	uint32_t width, height;
-	enum pipe pipe;
  	igt_plane_t *plane;
  	static uint32_t prev_output_id;
  	drmModeModeInfo *mode;
@@ -160,16 +147,14 @@ static void test_init(data_t *data)
  	igt_display_reset(&data->display);
  	igt_display_commit(&data->display);
 
-	pipe = get_pipe_for_output(&data->display, data->output);
-
  	mode = igt_output_get_mode(data->output);
  	width = mode->hdisplay;
  	height = mode->vdisplay;
 
-	data->crtc_id = data->display.pipes[pipe].crtc_id;
+	data->crtc_id = data->display.pipes[data->pipe].crtc_id;
  	data->refresh_rate = mode->vrefresh;
 
-	igt_output_set_pipe(data->output, pipe);
+	igt_output_set_pipe(data->output, data->pipe);
  	plane = igt_output_get_plane_type(data->output, DRM_PLANE_TYPE_PRIMARY);
 
  	if (prev_output_id != data->output->id) {
@@ -573,6 +558,7 @@ igt_main_args("e", NULL, help_str, opt_handler, &data)
  {
  	int i;
  	igt_output_t *output;
+	enum pipe pipe;
 
  	igt_fixture {
  		data.drm_fd = drm_open_driver_master(DRIVER_ANY);
@@ -587,69 +573,98 @@ igt_main_args("e", NULL, help_str, opt_handler, &data)
  	igt_describe("Verify the async flip functionality and the fps during async flips");
  	igt_subtest_group {

tests/kms_async_flips.c igt_main_args("e", NULL, help_str, opt_handler, &data) · line 577

Quoted 10 lines
tests/kms_async_flips.c +2 -7
  		igt_describe("Wait for page flip events in between successive asynchronous flips");
-		igt_subtest("async-flip-with-page-flip-events") {
-			for_each_connected_output(&data.display, output) {
-				data.output = output;
-				test_async_flip(&data, false);
-
-				if (!data.extended)
-					break;
+		igt_subtest_with_dynamic("async-flip-with-page-flip-events") {
+			for_each_pipe_static(pipe) {

"s/for_each_pipe_static()/for_each_pipe()/g"

tests/kms_async_flips.c igt_main_args("e", NULL, help_str, opt_handler, &data) · line 579

Quoted 2 lines
tests/kms_async_flips.c +2 -0
+				for_each_valid_output_on_pipe(&data.display, pipe, output) {
+					igt_dynamic_f("%s-pipe-%s", output->name, kmstest_pipe_name(pipe)) {

Can we use the dynamic subtest name as "<pipe_name>-<output_name>"?

These comments are applicable for all the places.

- Bhanu

Quoted 126 lines
tests/kms_async_flips.c +67 -35
+						data.output = output;
+						data.pipe = pipe;
+						test_async_flip(&data, false);
+					}
+
+					if (!data.extended)
+						break;
+				}
  			}
  		}
 
  		igt_describe("Alternate between sync and async flips");
-		igt_subtest("alternate-sync-async-flip") {
-			for_each_connected_output(&data.display, output) {
-				data.output = output;
-				test_async_flip(&data, true);
-
-				if (!data.extended)
-					break;
+		igt_subtest_with_dynamic("alternate-sync-async-flip") {
+			for_each_pipe_static(pipe) {
+				for_each_valid_output_on_pipe(&data.display, pipe, output) {
+					igt_dynamic_f("%s-pipe-%s", output->name, kmstest_pipe_name(pipe)) {
+						data.output = output;
+						data.pipe = pipe;
+						test_async_flip(&data, true);
+					}
+
+					if (!data.extended)
+						break;
+				}
  			}
  		}
 
-
  		igt_describe("Verify that the async flip timestamp does not coincide with either previous or next vblank");
-		igt_subtest("test-time-stamp") {
-			for_each_connected_output(&data.display, output) {
-				data.output = output;
-				test_timestamp(&data);
-
-				if (!data.extended)
+		igt_subtest_with_dynamic("test-time-stamp") {
+			for_each_pipe_static(pipe) {
+				for_each_valid_output_on_pipe(&data.display, pipe, output) {
+					igt_dynamic_f("%s-pipe-%s", output->name, kmstest_pipe_name(pipe)) {
+						data.output = output;
+						data.pipe = pipe;
+						test_timestamp(&data);
+					}
+
+					if (!data.extended)
  					break;
+				}
  			}
  		}
 
  		igt_describe("Verify that the DRM_IOCTL_MODE_CURSOR passes after async flip");
-		igt_subtest("test-cursor") {
-			for_each_connected_output(&data.display, output) {
-				data.output = output;
-				test_cursor(&data);
-
-				if (!data.extended)
-					break;
+		igt_subtest_with_dynamic("test-cursor") {
+			for_each_pipe_static(pipe) {
+				for_each_valid_output_on_pipe(&data.display, pipe, output) {
+					igt_dynamic_f("%s-pipe-%s", output->name, kmstest_pipe_name(pipe)) {
+						data.output = output;
+						data.pipe = pipe;
+						test_cursor(&data);
+					}
+
+					if (!data.extended)
+						break;
+				}
  			}
  		}
 
  		igt_describe("Negative case to verify if changes in fb are rejected from kernel as expected");
-		igt_subtest("invalid-async-flip") {
-			for_each_connected_output(&data.display, output) {
-				data.output = output;
-				test_invalid(&data);
-
-				if (!data.extended)
-					break;
+		igt_subtest_with_dynamic("invalid-async-flip") {
+			for_each_pipe_static(pipe) {
+				for_each_valid_output_on_pipe(&data.display, pipe, output) {
+					igt_dynamic_f("%s-pipe-%s", output->name, kmstest_pipe_name(pipe)) {
+						data.output = output;
+						data.pipe = pipe;
+						test_invalid(&data);
+					}
+
+					if (!data.extended)
+						break;
+				}
  			}
  		}
 
  		igt_describe("Use CRC to verify async flip scans out the correct framebuffer");
-		igt_subtest("crc") {
-			for_each_connected_output(&data.display, output) {
-				data.output = output;
-				test_crc(&data);
-
-				if (!data.extended)
-					break;
+		igt_subtest_with_dynamic("crc") {
+			for_each_pipe_static(pipe) {
+				for_each_valid_output_on_pipe(&data.display, pipe, output) {
+					igt_dynamic_f("%s-pipe-%s", output->name, kmstest_pipe_name(pipe)) {
+						data.output = output;
+						data.pipe = pipe;
+						test_crc(&data);
+					}
+
+					if (!data.extended)
+						break;
+				}
  			}
  		}
 
#3 lore raw

Re: [igt-dev] [PATCH i-g-t v3 2/2] tests/kms_async_flips: Convert tests to dynamic

Quoted 74 lines · Bhanuprakash
Quoted 73 lines · Karthik B S

v2: -Get the mode after igt_display_reset() (Bhanu)

---
  tests/kms_async_flips.c | 135 ++++++++++++++++++++++------------------

  1 file changed, 75 insertions(+), 60 deletions(-)
tests/kms_async_flips.c +4 -17
index 1b5af111..eeeb8a40 100644
@@ -59,6 +59,7 @@ typedef struct {
       int frame_count;
       bool flip_pending;
       bool extended;
+    enum pipe pipe;
   } data_t;
     static void flip_handler(int fd_, unsigned int sequence, unsigned int tv_sec,
@@ -135,24 +136,10 @@ static void require_monotonic_timestamp(int fd)
                 "Monotonic timestamps not supported\n");
   }
   -static enum pipe get_pipe_for_output(igt_display_t *display, igt_output_t *output)
-{
-    enum pipe pipe;
-
-    for_each_pipe(display, pipe) {
-        if (igt_pipe_connector_valid(pipe, output))
-            return pipe;
-    }
-
-    igt_assert_f(false, "No pipe found for output %s\n",
-             igt_output_name(output));
-}
-
   static void test_init(data_t *data)
   {
       int i;
       uint32_t width, height;
-    enum pipe pipe;
       igt_plane_t *plane;
       static uint32_t prev_output_id;
       drmModeModeInfo *mode;
@@ -160,16 +147,14 @@ static void test_init(data_t *data)
       igt_display_reset(&data->display);
       igt_display_commit(&data->display);
   -    pipe = get_pipe_for_output(&data->display, data->output);
-
       mode = igt_output_get_mode(data->output);
       width = mode->hdisplay;
       height = mode->vdisplay;
   -    data->crtc_id = data->display.pipes[pipe].crtc_id;
+    data->crtc_id = data->display.pipes[data->pipe].crtc_id;
       data->refresh_rate = mode->vrefresh;
   -    igt_output_set_pipe(data->output, pipe);
+    igt_output_set_pipe(data->output, data->pipe);
       plane = igt_output_get_plane_type(data->output, DRM_PLANE_TYPE_PRIMARY);
         if (prev_output_id != data->output->id) {
@@ -573,6 +558,7 @@ igt_main_args("e", NULL, help_str, opt_handler, 
 &data)
   {
       int i;
       igt_output_t *output;
+    enum pipe pipe;
         igt_fixture {
           data.drm_fd = drm_open_driver_master(DRIVER_ANY);
@@ -587,69 +573,98 @@ igt_main_args("e", NULL, help_str, opt_handler, 
 &data)
       igt_describe("Verify the async flip functionality and the fps during async flips");
       igt_subtest_group {
           igt_describe("Wait for page flip events in between successive asynchronous flips");
-        igt_subtest("async-flip-with-page-flip-events") {
-            for_each_connected_output(&data.display, output) {
-                data.output = output;
Quoted 8 lines

tests/kms_async_flips.c igt_main_args("e", NULL, help_str, opt_handler, &data) · line 577

Quoted 6 lines
tests/kms_async_flips.c +2 -4
-                test_async_flip(&data, false);
-
-                if (!data.extended)
-                    break;
+ igt_subtest_with_dynamic("async-flip-with-page-flip-events") {
+            for_each_pipe_static(pipe) {

"s/for_each_pipe_static()/for_each_pipe()/g"

Thank you for the review.
Will update this.

Quoted 8 lines

tests/kms_async_flips.c igt_main_args("e", NULL, help_str, opt_handler, · line 581

Quoted 4 lines
tests/kms_async_flips.c +2 -0
+ for_each_valid_output_on_pipe(&data.display, pipe, output) {
+                    igt_dynamic_f("%s-pipe-%s", output->name, 
 kmstest_pipe_name(pipe)) {

Can we use the dynamic subtest name as "<pipe_name>-<output_name>"?

These comments are applicable for all the places.

Sure, will update this.

Thanks,
Karthik.B.S

Quoted 129 lines

- Bhanu

Quoted 125 lines
tests/kms_async_flips.c +20 -7
+                        data.output = output;
+                        data.pipe = pipe;
+                        test_async_flip(&data, false);
+                    }
+
+                    if (!data.extended)
+                        break;
+                }
               }
           }
             igt_describe("Alternate between sync and async flips");
-        igt_subtest("alternate-sync-async-flip") {
-            for_each_connected_output(&data.display, output) {
-                data.output = output;
-                test_async_flip(&data, true);
-
-                if (!data.extended)
-                    break;
+        igt_subtest_with_dynamic("alternate-sync-async-flip") {
+            for_each_pipe_static(pipe) {
+ for_each_valid_output_on_pipe(&data.display, pipe, output) {
+                    igt_dynamic_f("%s-pipe-%s", output->name, 
 kmstest_pipe_name(pipe)) {
+                        data.output = output;
+                        data.pipe = pipe;
+                        test_async_flip(&data, true);
+                    }
+
+                    if (!data.extended)
+                        break;
+                }
               }
           }

  -
          igt_describe("Verify that the async flip timestamp does not coincide with either previous or next vblank"); -        igt_subtest("test-time-stamp") {
-            for_each_connected_output(&data.display, output) {
-                data.output = output;
-                test_timestamp(&data);
-
-                if (!data.extended)
+        igt_subtest_with_dynamic("test-time-stamp") {
+            for_each_pipe_static(pipe) {
+ for_each_valid_output_on_pipe(&data.display, pipe, output) {
+                    igt_dynamic_f("%s-pipe-%s", output->name,
kmstest_pipe_name(pipe)) {
+                        data.output = output;
+                        data.pipe = pipe;
+                        test_timestamp(&data);
+                    }
+
+                    if (!data.extended)
                      break;
+                }
              }
          }
            igt_describe("Verify that the DRM_IOCTL_MODE_CURSOR passes after async flip");
-        igt_subtest("test-cursor") {
-            for_each_connected_output(&data.display, output) {
-                data.output = output;
-                test_cursor(&data);
-
-                if (!data.extended)
-                    break;
+        igt_subtest_with_dynamic("test-cursor") {
+            for_each_pipe_static(pipe) {
+ for_each_valid_output_on_pipe(&data.display, pipe, output) {
+                    igt_dynamic_f("%s-pipe-%s", output->name,
kmstest_pipe_name(pipe)) {
+                        data.output = output;
+                        data.pipe = pipe;
+                        test_cursor(&data);
+                    }
+
+                    if (!data.extended)
+                        break;
+                }
              }
          }
            igt_describe("Negative case to verify if changes in fb are rejected from kernel as expected"); -        igt_subtest("invalid-async-flip") {
-            for_each_connected_output(&data.display, output) {
-                data.output = output;
-                test_invalid(&data);
-
-                if (!data.extended)
-                    break;
+        igt_subtest_with_dynamic("invalid-async-flip") {
+            for_each_pipe_static(pipe) {
+ for_each_valid_output_on_pipe(&data.display, pipe, output) {
+                    igt_dynamic_f("%s-pipe-%s", output->name,
kmstest_pipe_name(pipe)) {
+                        data.output = output;
+                        data.pipe = pipe;
+                        test_invalid(&data);
+                    }
+
+                    if (!data.extended)
+                        break;
+                }
              }
          }
            igt_describe("Use CRC to verify async flip scans out the correct framebuffer");
-        igt_subtest("crc") {
-            for_each_connected_output(&data.display, output) {
-                data.output = output;
-                test_crc(&data);
-
-                if (!data.extended)
-                    break;
+        igt_subtest_with_dynamic("crc") {
+            for_each_pipe_static(pipe) {
+ for_each_valid_output_on_pipe(&data.display, pipe, output) {
+                    igt_dynamic_f("%s-pipe-%s", output->name,
kmstest_pipe_name(pipe)) {
+                        data.output = output;
+                        data.pipe = pipe;
+                        test_crc(&data);
+                    }
+
+                    if (!data.extended)
+                        break;
+                }
              }
          }

#4 lore raw

[igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,v3,1/2] tests/kms_async_flips: Test Cleanup

In reply to Karthik B S
== Series Details ==

== Series Details ==

Series: series starting with [i-g-t,v3,1/2] tests/kms_async_flips: Test Cleanup
URL : https://patchwork.freedesktop.org/series/103063/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_11550 -> IGTPW_6991
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with IGTPW_6991 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in IGTPW_6991, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6991/index.html

Participating hosts (43 -> 43)
------------------------------

Additional (2): bat-dg2-8 bat-dg1-6
Missing (2): fi-kbl-soraka fi-bsw-cyan

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in IGTPW_6991:

### IGT changes ###

#### Possible regressions ####

* igt@gem_exec_suspend@basic-s0@smem:
- bat-dg1-6: NOTRUN -> [INCOMPLETE][1]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6991/bat-dg1-6/igt@gem_exec_suspend@[email protected]

Known issues
------------

Here are the changes found in IGTPW_6991 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@i915_selftest@live@gtt:
- fi-bdw-5557u: NOTRUN -> [INCOMPLETE][2] ([i915#5685])
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6991/fi-bdw-5557u/igt@i915_selftest@[email protected]

* igt@i915_selftest@live@hangcheck:
- fi-ivb-3770: [PASS][3] -> [INCOMPLETE][4] ([i915#5370])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11550/fi-ivb-3770/igt@i915_selftest@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6991/fi-ivb-3770/igt@i915_selftest@[email protected]

* igt@kms_chamelium@dp-crc-fast:
- fi-bdw-5557u: NOTRUN -> [SKIP][5] ([fdo#109271] / [fdo#111827]) +8 similar issues
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6991/fi-bdw-5557u/igt@[email protected]

* igt@kms_setmode@basic-clone-single-crtc:
- fi-bdw-5557u: NOTRUN -> [SKIP][6] ([fdo#109271]) +14 similar issues
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6991/fi-bdw-5557u/igt@[email protected]

#### Possible fixes ####

* igt@i915_selftest@live@gt_heartbeat:
- fi-cfl-guc: [DMESG-FAIL][7] ([i915#5334]) -> [PASS][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11550/fi-cfl-guc/igt@i915_selftest@live@gt_heartbeat.html
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6991/fi-cfl-guc/igt@i915_selftest@live@gt_heartbeat.html

* igt@i915_selftest@live@hangcheck:
- fi-snb-2600: [INCOMPLETE][9] ([i915#3921]) -> [PASS][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11550/fi-snb-2600/igt@i915_selftest@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6991/fi-snb-2600/igt@i915_selftest@[email protected]

* igt@kms_busy@basic@flip:
- {bat-adlp-6}: [DMESG-WARN][11] ([i915#3576]) -> [PASS][12] +1 similar issue
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11550/bat-adlp-6/igt@kms_busy@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6991/bat-adlp-6/igt@kms_busy@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
[fdo#111827]: https://bugs.freedesktop.org/show_bug.cgi?id=111827
[i915#1072]: https://gitlab.freedesktop.org/drm/intel/issues/1072
[i915#1155]: https://gitlab.freedesktop.org/drm/intel/issues/1155
[i915#2582]: https://gitlab.freedesktop.org/drm/intel/issues/2582
[i915#3291]: https://gitlab.freedesktop.org/drm/intel/issues/3291
[i915#3555]: https://gitlab.freedesktop.org/drm/intel/issues/3555
[i915#3576]: https://gitlab.freedesktop.org/drm/intel/issues/3576
[i915#3595]: https://gitlab.freedesktop.org/drm/intel/issues/3595
[i915#3708]: https://gitlab.freedesktop.org/drm/intel/issues/3708
[i915#3921]: https://gitlab.freedesktop.org/drm/intel/issues/3921
[i915#4077]: https://gitlab.freedesktop.org/drm/intel/issues/4077
[i915#4079]: https://gitlab.freedesktop.org/drm/intel/issues/4079
[i915#4083]: https://gitlab.freedesktop.org/drm/intel/issues/4083
[i915#4103]: https://gitlab.freedesktop.org/drm/intel/issues/4103
[i915#4212]: https://gitlab.freedesktop.org/drm/intel/issues/4212
[i915#4213]: https://gitlab.freedesktop.org/drm/intel/issues/4213
[i915#4215]: https://gitlab.freedesktop.org/drm/intel/issues/4215
[i915#4312]: https://gitlab.freedesktop.org/drm/intel/issues/4312
[i915#4873]: https://gitlab.freedesktop.org/drm/intel/issues/4873
[i915#5190]: https://gitlab.freedesktop.org/drm/intel/issues/5190
[i915#5270]: https://gitlab.freedesktop.org/drm/intel/issues/5270
[i915#5274]: https://gitlab.freedesktop.org/drm/intel/issues/5274
[i915#5275]: https://gitlab.freedesktop.org/drm/intel/issues/5275
[i915#5329]: https://gitlab.freedesktop.org/drm/intel/issues/5329
[i915#5334]: https://gitlab.freedesktop.org/drm/intel/issues/5334
[i915#5341]: https://gitlab.freedesktop.org/drm/intel/issues/5341
[i915#5354]: https://gitlab.freedesktop.org/drm/intel/issues/5354
[i915#5356]: https://gitlab.freedesktop.org/drm/intel/issues/5356
[i915#5370]: https://gitlab.freedesktop.org/drm/intel/issues/5370
[i915#5401]: https://gitlab.freedesktop.org/drm/intel/issues/5401
[i915#5537]: https://gitlab.freedesktop.org/drm/intel/issues/5537
[i915#5685]: https://gitlab.freedesktop.org/drm/intel/issues/5685
[i915#5763]: https://gitlab.freedesktop.org/drm/intel/issues/5763

Build changes
-------------

* CI: CI-20190529 -> None
* IGT: IGT_6451 -> IGTPW_6991

CI-20190529: 20190529
CI_DRM_11550: 56b089ae03ef8ea8ab7f474eaa70367898891ef0 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_6991: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6991/index.html
IGT_6451: f055bd83bd831a938d639718c2359516224f15f9 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_6991/index.html

#5 lore raw
In reply to Karthik B S
Quoted 77 lines · Karthik B S
(quoted diff) +0 -3
-Convert tests to dynamic
-Replace drm function call with existing library functions
-igt_display_reset() before all subtests

v2: -Move conversion to dynamic subtest to a separate patch (Bhanu)
-Use igt_output_get_mode to get default mode (Bhanu) -Add 'is_atomic' check before igt_display_commit2 (Bhanu)

v3: -Move test_init after the checks to skip subtest (Bhanu)
-Update the logic to call make_fb() in test_init()

---
  tests/kms_async_flips.c | 221 +++++++++++++++++++++++++++-------------
  1 file changed, 151 insertions(+), 70 deletions(-)
tests/kms_async_flips.c +5 -22
index 5e11cd43..1b5af111 100644
@@ -50,7 +50,7 @@ typedef struct {
  	uint32_t refresh_rate;
  	struct igt_fb bufs[4];
  	igt_display_t display;
-	drmModeConnectorPtr connector;
+	igt_output_t *output;
  	unsigned long flip_timestamp_us;
  	double flip_interval;
  	igt_pipe_crc_t *pipe_crc;
@@ -58,24 +58,9 @@ typedef struct {
  	int flip_count;
  	int frame_count;
  	bool flip_pending;
+	bool extended;
  } data_t;
 
-static drmModeConnectorPtr find_connector_for_modeset(data_t *data)
-{
-	igt_output_t *output;
-	drmModeConnectorPtr ret = NULL;
-
-	for_each_connected_output(&data->display, output) {
-		if (output->config.connector->count_modes > 0) {
-			ret = output->config.connector;
-			break;
-		}
-	}
-
-	igt_assert_f(ret, "Connector NOT found\n");
-	return ret;
-}
-
  static void flip_handler(int fd_, unsigned int sequence, unsigned int tv_sec,
  			 unsigned int tv_usec, void *_data)
  {
@@ -129,14 +114,10 @@ static void wait_flip_event(data_t *data)
  }
 
  static void make_fb(data_t *data, struct igt_fb *fb,
-		    drmModeConnectorPtr connector, int index)
+		    uint32_t width, uint32_t height, int index)
  {
-	uint32_t width, height;
  	int rec_width;
 
-	width = connector->modes[0].hdisplay;
-	height = connector->modes[0].vdisplay;
-
  	rec_width = width / (ARRAY_SIZE(data->bufs) * 2);
 
  	igt_create_fb(data->drm_fd, width, height, DRM_FORMAT_XRGB8888,
@@ -154,6 +135,61 @@ static void require_monotonic_timestamp(int fd)
  		      "Monotonic timestamps not supported\n");
  }
 
+static enum pipe get_pipe_for_output(igt_display_t *display, igt_output_t *output)
+{

tests/kms_async_flips.c static void require_monotonic_timestamp(int fd) · line 149

Quoted 10 lines
tests/kms_async_flips.c +10 -0
+	enum pipe pipe;
+
+	for_each_pipe(display, pipe) {
+		if (igt_pipe_connector_valid(pipe, output))
+			return pipe;
+	}
+
+	igt_assert_f(false, "No pipe found for output %s\n",
+		     igt_output_name(output));
+}

This block of code is removed by patch 2/2 in this series. I would suggest, to change the order of patches (1- dynamic subtests, 2- cleanup) to get rid of this dummy code.

With these chnages, this series is looks good to me.

- Bhanu

Quoted 271 lines
tests/kms_async_flips.c +136 -48
+
+static void test_init(data_t *data)
+{
+	int i;
+	uint32_t width, height;
+	enum pipe pipe;
+	igt_plane_t *plane;
+	static uint32_t prev_output_id;
+	drmModeModeInfo *mode;
+
+	igt_display_reset(&data->display);
+	igt_display_commit(&data->display);
+
+	pipe = get_pipe_for_output(&data->display, data->output);
+
+	mode = igt_output_get_mode(data->output);
+	width = mode->hdisplay;
+	height = mode->vdisplay;
+
+	data->crtc_id = data->display.pipes[pipe].crtc_id;
+	data->refresh_rate = mode->vrefresh;
+
+	igt_output_set_pipe(data->output, pipe);
+	plane = igt_output_get_plane_type(data->output, DRM_PLANE_TYPE_PRIMARY);
+
+	if (prev_output_id != data->output->id) {
+		prev_output_id = data->output->id;
+
+		if (data->bufs[0].fb_id) {
+			for (i = 0; i < ARRAY_SIZE(data->bufs); i++)
+				igt_remove_fb(data->drm_fd, &data->bufs[i]);
+	}
+
+		for (i = 0; i < ARRAY_SIZE(data->bufs); i++)
+			make_fb(data, &data->bufs[i], width, height, i);
+	}
+
+	igt_plane_set_fb(plane, &data->bufs[0]);
+	igt_plane_set_size(plane, width, height);
+
+	igt_display_commit2(&data->display, data->display.is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
+}
+
  static void test_async_flip(data_t *data, bool alternate_sync_async)
  {
  	int ret, frame;
@@ -161,6 +197,7 @@ static void test_async_flip(data_t *data, bool alternate_sync_async)
  	struct timeval start, end, diff;
 
  	require_monotonic_timestamp(data->drm_fd);
+	test_init(data);
 
  	gettimeofday(&start, NULL);
  	frame = 1;
@@ -254,6 +291,7 @@ static void test_timestamp(data_t *data)
  	int ret;
 
  	require_monotonic_timestamp(data->drm_fd);
+	test_init(data);
 
  	/*
  	 * In older platforms(<= gen10), async address update bit is double buffered.
@@ -312,6 +350,8 @@ static void test_cursor(data_t *data)
  	do_or_die(drmGetCap(data->drm_fd, DRM_CAP_CURSOR_WIDTH, &width));
  	do_or_die(drmGetCap(data->drm_fd, DRM_CAP_CURSOR_WIDTH, &height));
 
+	test_init(data);
+
  	igt_create_color_fb(data->drm_fd, width, height, DRM_FORMAT_ARGB8888,
  			    DRM_FORMAT_MOD_LINEAR, 1., 1., 1., &cursor_fb);
 
@@ -346,13 +386,17 @@ static void test_invalid(data_t *data)
  	int ret;
  	uint32_t width, height;
  	struct igt_fb fb;
+	drmModeModeInfo *mode;
 
-	width = data->connector->modes[0].hdisplay;
-	height = data->connector->modes[0].vdisplay;
+	mode = igt_output_get_mode(data->output);
+	width = mode->hdisplay;
+	height = mode->vdisplay;
 
  	igt_require(igt_display_has_format_mod(&data->display, DRM_FORMAT_XRGB8888,
  					       I915_FORMAT_MOD_Y_TILED));
 
+	test_init(data);
+
  	igt_create_fb(data->drm_fd, width, height, DRM_FORMAT_XRGB8888,
  		      I915_FORMAT_MOD_Y_TILED, &fb);
 
@@ -367,33 +411,6 @@ static void test_invalid(data_t *data)
  	igt_remove_fb(data->drm_fd, &fb);
  }
 
-static void test_init(data_t *data)
-{
-	drmModeResPtr res;
-	int i, ret;
-
-	res = drmModeGetResources(data->drm_fd);
-	igt_assert(res);
-
-	kmstest_unset_all_crtcs(data->drm_fd, res);
-
-	data->connector = find_connector_for_modeset(data);
-	data->crtc_id = kmstest_find_crtc_for_connector(data->drm_fd,
-							res, data->connector, 0);
-
-	data->refresh_rate = data->connector->modes[0].vrefresh;
-
-	for (i = 0; i < ARRAY_SIZE(data->bufs); i++)
-		make_fb(data, &data->bufs[i], data->connector, i);
-
-	ret = drmModeSetCrtc(data->drm_fd, data->crtc_id, data->bufs[0].fb_id, 0, 0,
-			     &data->connector->connector_id, 1, &data->connector->modes[0]);
-
-	igt_assert(ret == 0);
-
-	drmModeFreeResources(res);
-}
-
  static void queue_vblank(data_t *data)
  {
  	int pipe = kmstest_get_pipe_from_crtc_id(data->drm_fd, data->crtc_id);
@@ -490,11 +507,14 @@ static void test_crc(data_t *data)
  	data->frame_count = 0;
  	data->flip_pending = false;
 
+	test_init(data);
+
  	igt_draw_fill_fb(data->drm_fd, &data->bufs[frame], 0xff0000ff);
  	igt_draw_fill_fb(data->drm_fd, &data->bufs[!frame], 0xff0000ff);
 
  	ret = drmModeSetCrtc(data->drm_fd, data->crtc_id, data->bufs[frame].fb_id, 0, 0,
-			     &data->connector->connector_id, 1, &data->connector->modes[0]);
+			     &data->output->config.connector->connector_id, 1,
+			     &data->output->config.connector->modes[0]);
  	igt_assert_eq(ret, 0);
 
  	data->pipe_crc = igt_pipe_crc_new(data->drm_fd,
@@ -531,10 +551,28 @@ static void test_crc(data_t *data)
  	igt_assert_lt(data->frame_count * 2, data->flip_count);
  }
 
-igt_main
+static int opt_handler(int opt, int opt_index, void *_data)
+{
+	data_t *data = _data;
+
+	switch (opt) {
+	case 'e':
+		data->extended = true;
+		break;
+	}
+
+	return IGT_OPT_HANDLER_SUCCESS;
+}
+
+static const char help_str[] =
+	"  --e \t\tRun the extended tests\n";
+
+static data_t data;
+
+igt_main_args("e", NULL, help_str, opt_handler, &data)
  {
-	static data_t data;
  	int i;
+	igt_output_t *output;
 
  	igt_fixture {
  		data.drm_fd = drm_open_driver_master(DRIVER_ANY);
@@ -548,32 +586,72 @@ igt_main
 
  	igt_describe("Verify the async flip functionality and the fps during async flips");
  	igt_subtest_group {
-		igt_fixture
-			test_init(&data);
-
  		igt_describe("Wait for page flip events in between successive asynchronous flips");
-		igt_subtest("async-flip-with-page-flip-events")
-			test_async_flip(&data, false);
+		igt_subtest("async-flip-with-page-flip-events") {
+			for_each_connected_output(&data.display, output) {
+				data.output = output;
+				test_async_flip(&data, false);
+
+				if (!data.extended)
+					break;
+			}
+		}
 
  		igt_describe("Alternate between sync and async flips");
-		igt_subtest("alternate-sync-async-flip")
-			test_async_flip(&data, true);
+		igt_subtest("alternate-sync-async-flip") {
+			for_each_connected_output(&data.display, output) {
+				data.output = output;
+				test_async_flip(&data, true);
+
+				if (!data.extended)
+					break;
+			}
+		}
+
 
  		igt_describe("Verify that the async flip timestamp does not coincide with either previous or next vblank");
-		igt_subtest("test-time-stamp")
-			test_timestamp(&data);
+		igt_subtest("test-time-stamp") {
+			for_each_connected_output(&data.display, output) {
+				data.output = output;
+				test_timestamp(&data);
+
+				if (!data.extended)
+					break;
+			}
+		}
 
  		igt_describe("Verify that the DRM_IOCTL_MODE_CURSOR passes after async flip");
-		igt_subtest("test-cursor")
-			test_cursor(&data);
+		igt_subtest("test-cursor") {
+			for_each_connected_output(&data.display, output) {
+				data.output = output;
+				test_cursor(&data);
+
+				if (!data.extended)
+					break;
+			}
+		}
 
  		igt_describe("Negative case to verify if changes in fb are rejected from kernel as expected");
-		igt_subtest("invalid-async-flip")
-			test_invalid(&data);
+		igt_subtest("invalid-async-flip") {
+			for_each_connected_output(&data.display, output) {
+				data.output = output;
+				test_invalid(&data);
+
+				if (!data.extended)
+					break;
+			}
+		}
 
  		igt_describe("Use CRC to verify async flip scans out the correct framebuffer");
-		igt_subtest("crc")
-			test_crc(&data);
+		igt_subtest("crc") {
+			for_each_connected_output(&data.display, output) {
+				data.output = output;
+				test_crc(&data);
+
+				if (!data.extended)
+					break;
+			}
+		}
 
  		igt_fixture {
  			for (i = 0; i < ARRAY_SIZE(data.bufs); i++)
@@ -581,6 +659,9 @@ igt_main
  		}
  	}
 
-	igt_fixture
+	igt_fixture {
+		igt_display_reset(&data.display);
+		igt_display_commit(&data.display);
  		igt_display_fini(&data.display);
+	}
  }
#6 lore raw
Quoted 86 lines · Bhanuprakash
Quoted 72 lines · Karthik B S
(quoted diff) +0 -3
-Convert tests to dynamic
-Replace drm function call with existing library functions
-igt_display_reset() before all subtests

v2: -Move conversion to dynamic subtest to a separate patch (Bhanu) -Use igt_output_get_mode to get default mode (Bhanu) -Add 'is_atomic' check before igt_display_commit2 (Bhanu)

v3: -Move test_init after the checks to skip subtest (Bhanu) -Update the logic to call make_fb() in test_init()

---
  tests/kms_async_flips.c | 221 +++++++++++++++++++++++++++-------------

  1 file changed, 151 insertions(+), 70 deletions(-)
tests/kms_async_flips.c +4 -20
index 5e11cd43..1b5af111 100644
@@ -50,7 +50,7 @@ typedef struct {
       uint32_t refresh_rate;
       struct igt_fb bufs[4];
       igt_display_t display;
-    drmModeConnectorPtr connector;
+    igt_output_t *output;
       unsigned long flip_timestamp_us;
       double flip_interval;
       igt_pipe_crc_t *pipe_crc;
@@ -58,24 +58,9 @@ typedef struct {
       int flip_count;
       int frame_count;
       bool flip_pending;
+    bool extended;
   } data_t;
   -static drmModeConnectorPtr find_connector_for_modeset(data_t *data)
-{
-    igt_output_t *output;
-    drmModeConnectorPtr ret = NULL;
-
-    for_each_connected_output(&data->display, output) {
-        if (output->config.connector->count_modes > 0) {
-            ret = output->config.connector;
-            break;
-        }
-    }
-
-    igt_assert_f(ret, "Connector NOT found\n");
-    return ret;
-}
-
   static void flip_handler(int fd_, unsigned int sequence, unsigned int tv_sec,
                unsigned int tv_usec, void *_data)
   {
@@ -129,14 +114,10 @@ static void wait_flip_event(data_t *data)
   }
     static void make_fb(data_t *data, struct igt_fb *fb,
-            drmModeConnectorPtr connector, int index)
+            uint32_t width, uint32_t height, int index)
   {
-    uint32_t width, height;
       int rec_width;
   -    width = connector->modes[0].hdisplay;
-    height = connector->modes[0].vdisplay;
-
       rec_width = width / (ARRAY_SIZE(data->bufs) * 2);
         igt_create_fb(data->drm_fd, width, height, DRM_FORMAT_XRGB8888,
@@ -154,6 +135,61 @@ static void require_monotonic_timestamp(int fd)
                 "Monotonic timestamps not supported\n");
   }
   +static enum pipe get_pipe_for_output(igt_display_t *display, igt_output_t *output)
+{

tests/kms_async_flips.c static void require_monotonic_timestamp(int fd) · line 148

Quoted 10 lines
tests/kms_async_flips.c +10 -0
+    enum pipe pipe;
+
+    for_each_pipe(display, pipe) {
+        if (igt_pipe_connector_valid(pipe, output))
+            return pipe;
+    }
+
+    igt_assert_f(false, "No pipe found for output %s\n",
+             igt_output_name(output));
+}

This block of code is removed by patch 2/2 in this series. I would suggest, to change the order of patches (1- dynamic subtests, 2- cleanup) to get rid of this dummy code.

Quoted 1 line

With these chnages, this series is looks good to me.

Thank you for the review. Will fix this.

Thanks,
Karthik.B.S

Quoted 257 lines

- Bhanu

Quoted 253 lines
tests/kms_async_flips.c +43 -0
+
+static void test_init(data_t *data)
+{
+    int i;
+    uint32_t width, height;
+    enum pipe pipe;
+    igt_plane_t *plane;
+    static uint32_t prev_output_id;
+    drmModeModeInfo *mode;
+
+    igt_display_reset(&data->display);
+    igt_display_commit(&data->display);
+
+    pipe = get_pipe_for_output(&data->display, data->output);
+
+    mode = igt_output_get_mode(data->output);
+    width = mode->hdisplay;
+    height = mode->vdisplay;
+
+    data->crtc_id = data->display.pipes[pipe].crtc_id;
+    data->refresh_rate = mode->vrefresh;
+
+    igt_output_set_pipe(data->output, pipe);
+    plane = igt_output_get_plane_type(data->output, 
 DRM_PLANE_TYPE_PRIMARY);
+
+    if (prev_output_id != data->output->id) {
+        prev_output_id = data->output->id;
+
+        if (data->bufs[0].fb_id) {
+            for (i = 0; i < ARRAY_SIZE(data->bufs); i++)
+                igt_remove_fb(data->drm_fd, &data->bufs[i]);
+    }
+
+        for (i = 0; i < ARRAY_SIZE(data->bufs); i++)
+            make_fb(data, &data->bufs[i], width, height, i);
+    }
+
+    igt_plane_set_fb(plane, &data->bufs[0]);
+    igt_plane_set_size(plane, width, height);
+
+    igt_display_commit2(&data->display, data->display.is_atomic ? 
 COMMIT_ATOMIC : COMMIT_LEGACY);
+}
+
   static void test_async_flip(data_t *data, bool alternate_sync_async)

  {
      int ret, frame;

tests/kms_async_flips.c +3 -0
@@ -161,6 +197,7 @@ static void test_async_flip(data_t *data, bool 
 alternate_sync_async)
       struct timeval start, end, diff;
         require_monotonic_timestamp(data->drm_fd);
+    test_init(data);
         gettimeofday(&start, NULL);
       frame = 1;
@@ -254,6 +291,7 @@ static void test_timestamp(data_t *data)
       int ret;
         require_monotonic_timestamp(data->drm_fd);
+    test_init(data);
         /*
        * In older platforms(<= gen10), async address update bit is double buffered.
@@ -312,6 +350,8 @@ static void test_cursor(data_t *data)
       do_or_die(drmGetCap(data->drm_fd, DRM_CAP_CURSOR_WIDTH, &width));
       do_or_die(drmGetCap(data->drm_fd, DRM_CAP_CURSOR_WIDTH, &height));
   +    test_init(data);
+
       igt_create_color_fb(data->drm_fd, width, height, DRM_FORMAT_ARGB8888,
                   DRM_FORMAT_MOD_LINEAR, 1., 1., 1., &cursor_fb);
   @@ -346,13 +386,17 @@ static void test_invalid(data_t *data)

      int ret;
      uint32_t width, height;
      struct igt_fb fb;
+    drmModeModeInfo *mode;
  -    width = data->connector->modes[0].hdisplay;
-    height = data->connector->modes[0].vdisplay;
+    mode = igt_output_get_mode(data->output);
+    width = mode->hdisplay;
+    height = mode->vdisplay; igt_require(igt_display_has_format_mod(&data->display, DRM_FORMAT_XRGB8888, I915_FORMAT_MOD_Y_TILED));
  +    test_init(data);
+
      igt_create_fb(data->drm_fd, width, height, DRM_FORMAT_XRGB8888, I915_FORMAT_MOD_Y_TILED, &fb);
  @@ -367,33 +411,6 @@ static void test_invalid(data_t *data) igt_remove_fb(data->drm_fd, &fb);
  }
  -static void test_init(data_t *data)

tests/kms_async_flips.c +0 -19
-{
-    drmModeResPtr res;
-    int i, ret;
-
-    res = drmModeGetResources(data->drm_fd);
-    igt_assert(res);
-
-    kmstest_unset_all_crtcs(data->drm_fd, res);
-
-    data->connector = find_connector_for_modeset(data);
-    data->crtc_id = kmstest_find_crtc_for_connector(data->drm_fd,
-                            res, data->connector, 0);
-
-    data->refresh_rate = data->connector->modes[0].vrefresh;
-
-    for (i = 0; i < ARRAY_SIZE(data->bufs); i++)
-        make_fb(data, &data->bufs[i], data->connector, i);
-
-    ret = drmModeSetCrtc(data->drm_fd, data->crtc_id, 

data->bufs[0].fb_id, 0, 0,
-                 &data->connector->connector_id, 1, &data->connector->modes[0]);

tests/kms_async_flips.c +0 -6
-
-    igt_assert(ret == 0);
-
-    drmModeFreeResources(res);
-}
-

  static void queue_vblank(data_t *data)
  {
      int pipe = kmstest_get_pipe_from_crtc_id(data->drm_fd, data->crtc_id);

tests/kms_async_flips.c +3 -1
@@ -490,11 +507,14 @@ static void test_crc(data_t *data)
       data->frame_count = 0;
       data->flip_pending = false;
   +    test_init(data);
+
       igt_draw_fill_fb(data->drm_fd, &data->bufs[frame], 0xff0000ff);
       igt_draw_fill_fb(data->drm_fd, &data->bufs[!frame], 0xff0000ff);
         ret = drmModeSetCrtc(data->drm_fd, data->crtc_id, data->bufs[frame].fb_id, 0, 0,
-                 &data->connector->connector_id, 1, 
 &data->connector->modes[0]);
+ &data->output->config.connector->connector_id, 1,
+ &data->output->config.connector->modes[0]);
       igt_assert_eq(ret, 0);
         data->pipe_crc = igt_pipe_crc_new(data->drm_fd,
@@ -531,10 +551,28 @@ static void test_crc(data_t *data)
       igt_assert_lt(data->frame_count * 2, data->flip_count);
   }

  -igt_main

tests/kms_async_flips.c +19 -0
+static int opt_handler(int opt, int opt_index, void *_data)
+{
+    data_t *data = _data;
+
+    switch (opt) {
+    case 'e':
+        data->extended = true;
+        break;
+    }
+
+    return IGT_OPT_HANDLER_SUCCESS;
+}
+
+static const char help_str[] =
+    "  --e \t\tRun the extended tests\n";
+
+static data_t data;
+
+igt_main_args("e", NULL, help_str, opt_handler, &data)

  {
-    static data_t data;
      int i;
+    igt_output_t *output;
        igt_fixture {
          data.drm_fd = drm_open_driver_master(DRIVER_ANY);

tests/kms_async_flips.c +55 -15
@@ -548,32 +586,72 @@ igt_main
         igt_describe("Verify the async flip functionality and the fps during async flips");
       igt_subtest_group {
-        igt_fixture
-            test_init(&data);
-
           igt_describe("Wait for page flip events in between successive asynchronous flips");
-        igt_subtest("async-flip-with-page-flip-events")
-            test_async_flip(&data, false);
+        igt_subtest("async-flip-with-page-flip-events") {
+            for_each_connected_output(&data.display, output) {
+                data.output = output;
+                test_async_flip(&data, false);
+
+                if (!data.extended)
+                    break;
+            }
+        }
             igt_describe("Alternate between sync and async flips");
-        igt_subtest("alternate-sync-async-flip")
-            test_async_flip(&data, true);
+        igt_subtest("alternate-sync-async-flip") {
+            for_each_connected_output(&data.display, output) {
+                data.output = output;
+                test_async_flip(&data, true);
+
+                if (!data.extended)
+                    break;
+            }
+        }
+
             igt_describe("Verify that the async flip timestamp does not coincide with either previous or next vblank");
-        igt_subtest("test-time-stamp")
-            test_timestamp(&data);
+        igt_subtest("test-time-stamp") {
+            for_each_connected_output(&data.display, output) {
+                data.output = output;
+                test_timestamp(&data);
+
+                if (!data.extended)
+                    break;
+            }
+        }
             igt_describe("Verify that the DRM_IOCTL_MODE_CURSOR passes after async flip");
-        igt_subtest("test-cursor")
-            test_cursor(&data);
+        igt_subtest("test-cursor") {
+            for_each_connected_output(&data.display, output) {
+                data.output = output;
+                test_cursor(&data);
+
+                if (!data.extended)
+                    break;
+            }
+        }
             igt_describe("Negative case to verify if changes in fb are rejected from kernel as expected");
-        igt_subtest("invalid-async-flip")
-            test_invalid(&data);
+        igt_subtest("invalid-async-flip") {
+            for_each_connected_output(&data.display, output) {
+                data.output = output;
+                test_invalid(&data);
+
+                if (!data.extended)
+                    break;
+            }
+        }
             igt_describe("Use CRC to verify async flip scans out the correct framebuffer");
-        igt_subtest("crc")
-            test_crc(&data);
+        igt_subtest("crc") {
+            for_each_connected_output(&data.display, output) {
+                data.output = output;
+                test_crc(&data);
+
+                if (!data.extended)
+                    break;
+            }
+        }
             igt_fixture {
               for (i = 0; i < ARRAY_SIZE(data.bufs); i++)
@@ -581,6 +659,9 @@ igt_main
           }
       }

  -    igt_fixture
+    igt_fixture {
+        igt_display_reset(&data.display);
+        igt_display_commit(&data.display);
          igt_display_fini(&data.display);
+    }
  }