* [PATCH] tests/unigraf: Mitigate EDID cache races and zero-mode fallback panics
@ 2026-08-13 18:42 Mark Yacoub
0 siblings, 0 replies; only message in thread
From: Mark Yacoub @ 2026-08-13 18:42 UTC (permalink / raw)
To: igt-dev; +Cc: louis.chauvet, Mark Yacoub
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-08-13 18:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-13 18:42 [PATCH] tests/unigraf: Mitigate EDID cache races and zero-mode fallback panics Mark Yacoub
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox