From 607e92d2d5b4a610326707c8620b0b5ee550b348 Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Mon, 3 Feb 2025 10:12:48 +0100 Subject: [PATCH] metal: retry DRM device reset with modeset if non-modeset fails Unfortunately AMD gets a bit modeset happy when we set this flag even in situations where otherwise no modeset would be required. So we cannot set it unconditionally. --- src/backends/metal/video.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/backends/metal/video.rs b/src/backends/metal/video.rs index a4a2536b..6771cf8d 100644 --- a/src/backends/metal/video.rs +++ b/src/backends/metal/video.rs @@ -2328,7 +2328,18 @@ impl MetalBackend { } } } - if let Err(e) = changes.commit(flags, 0) { + let res = loop { + let res = changes.commit(flags, 0); + if let Err(e) = &res { + if flags.not_contains(DRM_MODE_ATOMIC_ALLOW_MODESET) { + log::warn!("Fast commit failed, retrying with modeset: {}", ErrorFmt(e)); + flags |= DRM_MODE_ATOMIC_ALLOW_MODESET; + continue; + } + } + break res; + }; + if let Err(e) = res { return Err(MetalError::Modeset(e)); } for connector in dev.connectors.lock().values() {