From de8ba22aab3b6f00957b8a395611c423baa513ea Mon Sep 17 00:00:00 2001 From: Sultan Alsawaf Date: Sat, 15 Feb 2025 17:45:54 -0800 Subject: [PATCH] modesetting: Don't recursively force present to unflip Present calls drmmode_set_mode_major() as part of ms_present_unflip(), which leads to a crash due to the recursive attempt to force present to unflip when it already is. Fix it by simply skipping the forced present unflip when present itself is unflipping. This also speeds up drmmmode_prepare_modeset() when present isn't even flipping to begin with. Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1791 Fixes: 899c87af1 ("modesetting: unflip before any setcrtc() calls") Signed-off-by: Sultan Alsawaf Part-of: --- hw/xfree86/drivers/modesetting/drmmode_display.c | 2 +- hw/xfree86/drivers/modesetting/present.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c index c1f533c90..b30c20ea4 100644 --- a/hw/xfree86/drivers/modesetting/drmmode_display.c +++ b/hw/xfree86/drivers/modesetting/drmmode_display.c @@ -1669,7 +1669,7 @@ static void drmmmode_prepare_modeset(ScrnInfoPtr scrn) ScreenPtr pScreen = scrn->pScreen; modesettingPtr ms = modesettingPTR(scrn); - if (ms->drmmode.pending_modeset) + if (!ms->drmmode.present_flipping || ms->drmmode.pending_modeset) return; /* diff --git a/hw/xfree86/drivers/modesetting/present.c b/hw/xfree86/drivers/modesetting/present.c index a876a031e..21fd3f259 100644 --- a/hw/xfree86/drivers/modesetting/present.c +++ b/hw/xfree86/drivers/modesetting/present.c @@ -447,6 +447,8 @@ ms_present_unflip(ScreenPtr screen, uint64_t event_id) } } + ms->drmmode.present_flipping = FALSE; + for (i = 0; i < config->num_crtc; i++) { xf86CrtcPtr crtc = config->crtc[i]; drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; @@ -471,7 +473,6 @@ ms_present_unflip(ScreenPtr screen, uint64_t event_id) } present_event_notify(event_id, 0, 0); - ms->drmmode.present_flipping = FALSE; } #endif