From acc6d94db048118e7e910d7812431dfb27b2d769 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 27 May 2022 13:21:55 +0200 Subject: backend/drm: make commits without a buffer blocking The wlr_output API requires compositors to wait for wlr_output.frame before submitting a new buffer. However, compositors can perform a commit which doesn't involve a buffer anytime. If the commit is a modeset, we set DRM_MODE_ATOMIC_ALLOW_MODESET and block until the commit is done. If it isn't, we currently always perform a non-blocking commit. This is an issue because a previous page-flip might still be in flight kernel-side, returning EBUSY. Fix this by using blocking commits when a buffer isn't submitted by the compositor. Closes: https://github.com/swaywm/sway/issues/6962 References: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/2239 --- backend/drm/atomic.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/drm/atomic.c b/backend/drm/atomic.c index cacb8e87..1d4f9df4 100644 --- a/backend/drm/atomic.c +++ b/backend/drm/atomic.c @@ -264,7 +264,12 @@ static bool atomic_crtc_commit(struct wlr_drm_connector *conn, } if (modeset) { flags |= DRM_MODE_ATOMIC_ALLOW_MODESET; - } else if (!test_only) { + } else if (!test_only && (state->base->committed & WLR_OUTPUT_STATE_BUFFER)) { + // The wlr_output API requires non-modeset commits with a new buffer to + // wait for the frame event. However compositors often perform + // non-modesets commits without a new buffer without waiting for the + // frame event. In that case we need to make the KMS commit blocking, + // otherwise the kernel will error out with EBUSY. flags |= DRM_MODE_ATOMIC_NONBLOCK; } -- cgit v1.2.3