From 8b5fd556582ba040aad5beeeb4c024e5dae40eba Mon Sep 17 00:00:00 2001 From: Sultan Alsawaf Date: Sun, 22 Jan 2023 21:02:45 -0800 Subject: [PATCH] modesetting: Improve TearFree state check in ms_present_check_flip Check that the VT is owned and that the CRTC is on before exporting info to Present stating that TearFree is available. Also, since `trf->buf[0].px` is checked, the `ms->drmmode.tearfree_enable` check is redundant and can therefore be removed. Signed-off-by: Sultan Alsawaf Reviewed-by: Martin Roukala --- hw/xfree86/drivers/modesetting/present.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/xfree86/drivers/modesetting/present.c b/hw/xfree86/drivers/modesetting/present.c index e147f3eda..acc299f3b 100644 --- a/hw/xfree86/drivers/modesetting/present.c +++ b/hw/xfree86/drivers/modesetting/present.c @@ -329,12 +329,13 @@ ms_present_check_flip(RRCrtcPtr crtc, no_flip: /* Export some info about TearFree if Present can't flip anyway */ - if (reason && ms->drmmode.tearfree_enable) { + if (reason) { xf86CrtcPtr xf86_crtc = crtc->devPrivate; drmmode_crtc_private_ptr drmmode_crtc = xf86_crtc->driver_private; drmmode_tearfree_ptr trf = &drmmode_crtc->tearfree; - if (trf->buf[0].px) { + /* Check if TearFree is active on this CRTC and tell Present about it */ + if (trf->buf[0].px && scrn->vtSema && xf86_crtc_on(xf86_crtc)) { if (trf->flip_seq) /* The driver has a TearFree flip pending */ *reason = PRESENT_FLIP_REASON_DRIVER_TEARFREE_FLIPPING;