Skip to contentSkip to conversation

kms_writeback: Synchronize writeback and test CRC continuity

PATCH New Aditya Tipre 2 participants 4 messages Nov 29

lore
Share & tools
lore
#0 lore raw

v4 cover kms_writeback: Synchronize writeback and test CRC continuity

This series fixes a synchronization issue in the existing writeback FB-ID test and adds a VKMS regression test for concurrent writeback and CRC capture.

The FB-ID test submits a writeback into the shared input framebuffer. It must wait for completion before a later subtest refills that buffer. Patch 1 requests and waits for the completion fence, preventing the older writeback from modifying the next subtest's reference contents.

Patch 2 keeps CRC capture active across four alternating writebacks and checks fresh CRC samples after each completion. It is restricted to VKMS, does not allow modesets after capture starts, and releases capture and the new framebuffers from the final fixture. It also clears the format probe's pending out-fence request so the subtest works independently.

Changes since v3:
- Rebased both patches onto current IGT master, c9e2cc3119d9.
- Added a cover letter with a subject describing the complete series. The patch contents are unchanged by the rebase.

Previous revision:
https://lore.kernel.org/igt-dev/[email protected]/

Validation performed on the rebased v4 series:
- Rebuilt IGT and kms_writeback on master c9e2cc3119d9 with both patches. The generated testlist and documentation consistency checks pass.
- ARM64 QEMU/HVF with one and two CPUs, using the original unfixed/fixed Linux kernel pair that demonstrated the VKMS composer lifetime bug.
- The prerequisite alone and the complete series pass all four existing applicable subtests on both kernels; the two XRGB2101010 cases skip.
- The new regression reaches the expected post-writeback CRC timeout on the unfixed kernel and passes with the VKMS composer lifetime fix, both independently and in the full writeback suite.
- Temporary failure probes verify framebuffer and buffer-handle cleanup after partial setup, CRC comparison failure, timeout, success, and skip.
- All 19 validation cases produced their expected outcomes, with no kernel warnings detected. Strict checkpatch reports no issues in either patch.

Aditya Tipre (2):
tests/kms_writeback: Wait for the valid FB ID writeback tests/kms_writeback: Check CRC capture survives writeback

 tests/kms_writeback.c | 75 +++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 73 insertions(+), 2 deletions(-)
Signature · 1 line
2.50.1 (Apple Git-155)
#1 lore raw

PATCH v4 1/2 tests/kms_writeback: Wait for the valid FB ID writeback

The positive WRITEBACK_FB_ID test submits a writeback to the common input framebuffer without requesting or waiting for its completion fence. A blocking atomic commit does not imply that writeback has finished.

The following pixel-output test fills the same buffer with its reference color. The earlier writeback can still be modifying it, leaving a mixture of the old and new contents and causing intermittent checksum failures. On ARM64 VKMS, a diagnostic run observed the prior fence still unsignalled and a black row in both the input and the captured output after the input had been filled red.

Request a fence for the successful FB ID writeback and wait for it before returning. Only require the returned fence descriptor to be -1 when the commit fails, so the shared commit helper also accepts this successful fenced operation. Keep all invalid-parameter checks intact.

---
 tests/kms_writeback.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
tests/kms_writeback.c +6 -2
index 7c30e8e..550d603 100644
@@ -228,7 +228,7 @@ static int do_writeback_test(igt_output_t *output, uint32_t fb_id,
 
 	ret = igt_display_try_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
 
-	if (ptr_valid)
+	if (ptr_valid && ret)
 		igt_assert(*out_fence_ptr == -1);
 
 	/* WRITEBACK_FB_ID must always read as zero */
@@ -288,8 +288,12 @@ static void writeback_fb_id(igt_output_t *output, igt_fb_t *valid_fb, igt_fb_t *
 	igt_assert_eq(ret, 0);
 
 	/* Valid output buffer */
-	ret = do_writeback_test(output, valid_fb->fb_id, NULL, false);
+	ret = do_writeback_test(output, valid_fb->fb_id,
+				&output->writeback_out_fence_fd, true);
 	igt_assert_eq(ret, 0);
+
+	/* The next subtest may reuse this buffer as input. */
+	igt_get_and_wait_out_fence(output);
 }
 
 static void fill_fb(igt_fb_t *fb, uint32_t pixel)
Signature · 1 line
2.50.1 (Apple Git-155)
#2 lore raw

PATCH v4 2/2 tests/kms_writeback: Check CRC capture survives writeback

In reply to Aditya Tipre

The existing writeback tests validate captured framebuffer contents, but do not keep pipe CRC capture active across writeback completion. This misses the VKMS bug where writeback cleanup disables the composer while CRC capture still needs it, leaving subsequent CRC reads waiting for samples that never arrive.

Add a VKMS-only writeback-preserves-crc subtest. Complete the initial modeset before starting capture and establish reference CRCs for separate red and blue input framebuffers. Keep capture open across four alternating writebacks, wait for each output fence, and compare three fresh CRC samples with the corresponding reference after each writeback. Do not allow modesets once capture starts, since they may disrupt CRC generation.

Clear the pending out-fence request left by the configuration probe before the initial modeset so the subtest also works when run independently. Use the final fixture to close capture, disable the output, and remove the two new framebuffers so subtest failure or skip also cleans them up.

Check output fence status in the shared wait helper so a signalled error fence cannot be treated as a successful writeback.

On ARM64 QEMU with one and two CPUs, the new subtest fails with a CRC read timeout on the unmodified kernel and passes with the VKMS composer-user lifetime fix, both independently and in the full writeback suite.

---
 tests/kms_writeback.c | 67 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)
tests/kms_writeback.c +67 -0
index 550d603..e277752 100644
@@ -64,6 +64,10 @@
  *
  * SUBTEST: writeback-pixel-formats
  * Description: Check the writeback format
+ *
+ * SUBTEST: writeback-preserves-crc
+ * Description: CRC capture remains active across completed writebacks
+ * Driver requirement: vkms
  */
 
 IGT_TEST_DESCRIPTION(
@@ -321,6 +325,7 @@ static void get_and_wait_out_fence(igt_output_t *output)
 
 	ret = sync_fence_wait(output->writeback_out_fence_fd, 1000);
 	igt_assert_f(ret == 0, "sync_fence_wait failed: %s\n", strerror(-ret));
+	igt_assert_eq(sync_fence_status(output->writeback_out_fence_fd), 1);
 	close(output->writeback_out_fence_fd);
 	output->writeback_out_fence_fd = -1;
 }
@@ -541,6 +546,8 @@ int igt_main_args("b:c:f:dl", long_options, help_str, opt_handler, NULL)
 	igt_output_t *output;
 	igt_plane_t *plane;
 	igt_fb_t input_fb, input_fb_10bit;
+	static igt_pipe_crc_t *pipe_crc;
+	static igt_fb_t crc_blue_fb, crc_output_fb;
 	drmModeModeInfo mode;
 	unsigned int fb_id;
 	int ret;
@@ -713,8 +720,68 @@ int igt_main_args("b:c:f:dl", long_options, help_str, opt_handler, NULL)
 		igt_remove_fb(display.drm_fd, &output_fb);
 	}
 
+	igt_describe("CRC capture remains active across completed writebacks");
+	igt_subtest("writeback-preserves-crc") {
+		igt_fb_t *colors[] = { &input_fb, &crc_blue_fb };
+		igt_crc_t reference[2], crc;
+		int i, j;
+
+		igt_skip_on(data.dump_check || data.list_modes);
+		igt_require(is_vkms_device(display.drm_fd));
+		igt_require(data.supported_colors & XRGB8888);
+		igt_require_pipe_crc(display.drm_fd);
+
+		igt_create_color_fb(display.drm_fd, mode.hdisplay, mode.vdisplay,
+				    DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_LINEAR,
+				    0.0, 0.0, 1.0, &crc_blue_fb);
+		igt_create_fb(display.drm_fd, mode.hdisplay, mode.vdisplay,
+			      DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_LINEAR,
+			      &crc_output_fb);
+		fill_fb(&input_fb, 0x00ff0000);
+		igt_plane_set_fb(plane, &input_fb);
+		igt_output_set_writeback_fb(output, NULL);
+		/* Discard the out-fence request left by the configuration probe. */
+		igt_output_set_prop_value(output, IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR,
+					  to_user_pointer(NULL));
+		igt_display_commit_atomic(&display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
+
+		/* Finish the modeset before starting continuous CRC capture. */
+		pipe_crc = igt_pipe_crc_new(display.drm_fd, output->config.crtc_index,
+					    IGT_PIPE_CRC_SOURCE_AUTO);
+		igt_pipe_crc_start(pipe_crc);
+
+		/*
+		 * Establish both references before writeback can affect capture.
+		 * Do not allow modesets below: they may disrupt continuous CRC
+		 * generation.
+		 */
+		for (i = 0; i < ARRAY_SIZE(colors); i++) {
+			igt_plane_set_fb(plane, colors[i]);
+			igt_display_commit_atomic(&display, 0, NULL);
+			igt_pipe_crc_get_current(display.drm_fd, pipe_crc, &reference[i]);
+		}
+
+		for (i = 0; i < 4; i++) {
+			int color = i % ARRAY_SIZE(colors);
+
+			igt_plane_set_fb(plane, colors[color]);
+			igt_output_set_writeback_fb(output, &crc_output_fb);
+			igt_display_commit_atomic(&display, 0, NULL);
+			get_and_wait_out_fence(output);
+
+			/* Require fresh frames without stopping or restarting capture. */
+			for (j = 0; j < 3; j++) {
+				igt_pipe_crc_get_current(display.drm_fd, pipe_crc, &crc);
+				igt_assert_crc_equal(&reference[color], &crc);
+			}
+		}
+	}
+
 	igt_fixture() {
+		igt_pipe_crc_free(pipe_crc);
 		cleanup_writeback(&display, output);
+		igt_remove_fb(display.drm_fd, &crc_blue_fb);
+		igt_remove_fb(display.drm_fd, &crc_output_fb);
 		igt_remove_fb(display.drm_fd, &input_fb);
 
 		if (data.supported_colors & XRGB2101010)
Signature · 1 line
2.50.1 (Apple Git-155)
#3 lore raw

✗ LGCI.VerificationFailed: failure for kms_writeback: Synchronize writeback and test CRC continuity

In reply to Aditya Tipre
== Series Details ==

== Series Details ==

Series: kms_writeback: Synchronize writeback and test CRC continuity
URL : https://patchwork.freedesktop.org/series/179961/
State : failure

== Summary ==

Series author address '[email protected]' is not on the allowlist, which prevents CI from being automatically triggered. If you want CI to run for this series, ask Patchwork project owners to click 'retest' on the series in Patchwork. Exception occurred during validation, bailing out!
Build URL: http://gfx-ci.igk.intel.com:8080/job/CI_IGTPW_check/244626/ (on cidrm1)