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.

Signed-off-by: Aditya Tipre <[email protected]>
---
 tests/kms_writeback.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tests/kms_writeback.c b/tests/kms_writeback.c
index 7c30e8e..550d603 100644
--- a/tests/kms_writeback.c
+++ b/tests/kms_writeback.c
@@ -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)
-- 
2.50.1 (Apple Git-155)

Reply via email to