From 048d3deb517bf406a168d6c19e9eeb72891b23ee 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 --- 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 2072ce0c5..3be24e265 100644 --- a/hw/xfree86/drivers/modesetting/drmmode_display.c +++ b/hw/xfree86/drivers/modesetting/drmmode_display.c @@ -1664,7 +1664,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 421d70016..5828ce7da 100644 --- a/hw/xfree86/drivers/modesetting/present.c +++ b/hw/xfree86/drivers/modesetting/present.c @@ -444,6 +444,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; @@ -468,7 +470,6 @@ ms_present_unflip(ScreenPtr screen, uint64_t event_id) } present_event_notify(event_id, 0, 0); - ms->drmmode.present_flipping = FALSE; } #endif