Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Yacoub <markyacoub@google.com>
To: igt-dev@lists.freedesktop.org
Cc: louis.chauvet@bootlin.com, Mark Yacoub <markyacoub@google.com>
Subject: [PATCH] tests/unigraf: Mitigate EDID cache races and zero-mode fallback panics
Date: Thu, 13 Aug 2026 14:42:27 -0400	[thread overview]
Message-ID: <20260813184227.2532503-1-markyacoub@google.com> (raw)

When initializing the active output geometry directly following an external
unigraf_hpd_pulse(), the legacy execution queried the DRM software cache for
the current mode.

Because the kernel utilizes an asynchronous background interrupt thread to
negotiate DP AUX EDID transactions, dynamically querying the software cache
right as the kernel is processing the HPD pulse frequently yields 0 structural
modes. Furthermore, since igt_output_get_mode() does not return a clean NULL
pointer when count_modes == 0—but instead returns a pointer to an uninitialized
geometry plane—dynamically assigning this blank pipe downstream fatally crashes
the test execution suite when it attempts to allocate a 0x0 coordinate block.

This patch stabilizes the execution vectors fundamentally:

1. It replaces igt_output_get_mode() with an active, polling drmModeGetConnector()
   evaluation loop configured to block until conn->count_modes > 0. This enforces
   strict timing synchronicity between the unigraf HPD pulse and the kernel
   DP AUX handler.
2. It hoists the mode fetching logic strictly before establishing and binding
   the software pipe to the CRTC, guaranteeing that the baseline hardware preferred
   mode is secured before any DRM surfaces are allocated.

Signed-off-by: Mark Yacoub <markyacoub@google.com>
---
 tests/unigraf/unigraf_lt.c | 34 ++++++++++++++++++++++++++++++----
 1 file changed, 30 insertions(+), 4 deletions(-)

diff --git a/tests/unigraf/unigraf_lt.c b/tests/unigraf/unigraf_lt.c
index 81e6ecd3f..0cac014e8 100644
--- a/tests/unigraf/unigraf_lt.c
+++ b/tests/unigraf/unigraf_lt.c
@@ -38,19 +38,45 @@ static void init_output_and_display_pattern(igt_display_t *display, igt_output_t
 	igt_crtc_t *crtc;
 	struct igt_fb fb;
 	igt_plane_t *primary;
-	drmModeModeInfo *mode;
+	drmModeModeInfo *mode = NULL;
 	int fb_id;
+	int retries = 10;
 
 	igt_modeset_disable_all_outputs(display);
 	igt_display_reset(display);
 
+	/* Get the current mode */
+
+	while (retries--) {
+		/* Force an active hardware probe instead of a cached one */
+		drmModeConnector *conn = drmModeGetConnector(display->drm_fd, output->id);
+
+		if (conn && conn->count_modes > 0) {
+			/* Found dynamically probed modes! Update the output config */
+			drmModeFreeConnector(output->config.connector);
+			output->config.connector = conn;
+
+			/* DO NOT call igt_output_refresh here! It would free our probed
+			 * connector and replace it with drmModeGetConnectorCurrent. */
+			mode = &conn->modes[0];
+			if (mode && mode->hdisplay > 0)
+				break;
+		} else if (conn) {
+			drmModeFreeConnector(conn);
+		}
+
+		igt_info("Waiting for connector modes to repopulate after HPD pulse... (%d)\n",
+			 retries);
+		sleep(1);
+	}
+
+	igt_assert(mode);
+
 	igt_output_set_crtc(output, 0);
 	crtc = igt_get_crtc_for_output(display, output);
 	igt_output_set_crtc(output, crtc);
 
-	/* Get the current mode */
-	mode = igt_output_get_mode(output);
-	igt_assert(mode);
+	igt_info("Final Mode: %dx%d\n", mode->hdisplay, mode->vdisplay);
 
 	/* Create a framebuffer with a solid color pattern */
 	fb_id = igt_create_color_pattern_fb(display->drm_fd, mode->hdisplay,
-- 
2.55.0.691.gc56d675ccc-goog


             reply	other threads:[~2026-08-13 18:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-13 18:42 Mark Yacoub [this message]
2026-08-13 22:06 ` ✓ Xe.CI.BAT: success for tests/unigraf: Mitigate EDID cache races and zero-mode fallback panics Patchwork
2026-08-13 22:34 ` ✓ i915.CI.BAT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260813184227.2532503-1-markyacoub@google.com \
    --to=markyacoub@google.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=louis.chauvet@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox