From d2a5dbe1041550f2e6f9202b4d99828762f289fb Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 20 Aug 2024 19:46:38 +0200 Subject: [PATCH] backend/drm: use CRTCs in-order When lighting up a new connector, we'd use the last CRTC instead of the first one. This causes issues because drivers have the expectation that userspace will match CRTCs to connectors in-order [1]. The order has regressed a long time ago in 5b13b8a12c55 ("backend/drm: consider continue not using resources"). That commit was a fix to avoid moving a connector between CRTCs [2]. Revert that commit and use a different approach: even if we've found a solution, always try not using a CRTC in the hope that we'll find another solution with less CRTC replacements. [1]: https://lore.kernel.org/dri-devel/20240612141903.17219-2-ville.syrjala@linux.intel.com/ [2]: https://github.com/swaywm/wlroots/issues/1230 Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3098 --- backend/drm/util.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/backend/drm/util.c b/backend/drm/util.c index a14e5e1ef..7e52fc11e 100644 --- a/backend/drm/util.c +++ b/backend/drm/util.c @@ -170,12 +170,6 @@ static bool match_obj_(struct match_state *st, size_t skips, size_t score, size_ has_best = true; } } - if (st->orig[i] == UNMATCHED) { - st->res[i] = UNMATCHED; - if (match_obj_(st, skips, score, replaced, i + 1)) { - has_best = true; - } - } if (st->exit_early) { return true; } @@ -211,13 +205,13 @@ static bool match_obj_(struct match_state *st, size_t skips, size_t score, size_ } } - if (has_best) { - return true; - } - // Maybe this resource can't be matched st->res[i] = UNMATCHED; - return match_obj_(st, skips, score, replaced, i + 1); + if (match_obj_(st, skips, score, replaced, i + 1)) { + has_best = true; + } + + return has_best; } size_t match_obj(size_t num_objs, const uint32_t objs[static restrict num_objs],