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 5b13b8a12c ("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
This commit is contained in:
Simon Ser 2024-08-20 19:46:38 +02:00 committed by Alexander Orzechowski
parent 43554c1966
commit d2a5dbe104

View File

@ -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],