drm: scan only cards and not outputs, safeguard against null renderer (#106)

* drm: dont scan card outputs

no need to scan for card[0-9]* and probe card0-eDP etc if they are kms,
bootvga and rendernodes etc. skip the wildcard and remove a unused
size_t variable.

* drm: dont commit state if renderer is missing

setting certain env vars to force egl implentations makes the render
creation fail on the second gpu. instead of causing a coredump,
safeguard commitState and let the monitor turn blank instead.
This commit is contained in:
Tom Englund 2024-11-13 12:10:16 +01:00 committed by GitHub
parent 545f506a63
commit 3b00e96f90
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -50,7 +50,7 @@ static udev_enumerate* enumDRMCards(udev* udev) {
return nullptr; return nullptr;
udev_enumerate_add_match_subsystem(enumerate, "drm"); udev_enumerate_add_match_subsystem(enumerate, "drm");
udev_enumerate_add_match_sysname(enumerate, DRM_PRIMARY_MINOR_NAME "[0-9]*"); udev_enumerate_add_match_sysname(enumerate, DRM_PRIMARY_MINOR_NAME "[0-9]");
if (udev_enumerate_scan_devices(enumerate)) { if (udev_enumerate_scan_devices(enumerate)) {
udev_enumerate_unref(enumerate); udev_enumerate_unref(enumerate);
@ -75,8 +75,6 @@ static std::vector<SP<CSessionDevice>> scanGPUs(SP<CBackend> backend) {
} }
udev_list_entry* entry = nullptr; udev_list_entry* entry = nullptr;
size_t i = 0;
std::deque<SP<CSessionDevice>> devices; std::deque<SP<CSessionDevice>> devices;
udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(enumerate)) { udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(enumerate)) {
@ -125,8 +123,6 @@ static std::vector<SP<CSessionDevice>> scanGPUs(SP<CBackend> backend) {
devices.push_front(sessionDevice); devices.push_front(sessionDevice);
else else
devices.push_back(sessionDevice); devices.push_back(sessionDevice);
++i;
} }
udev_enumerate_unref(enumerate); udev_enumerate_unref(enumerate);
@ -1404,6 +1400,11 @@ bool Aquamarine::CDRMOutput::commitState(bool onlyTest) {
return false; return false;
} }
if (!backend->rendererState.renderer) {
backend->backend->log(AQ_LOG_ERROR, "drm: No renderer attached to backend");
return false;
}
const auto& STATE = state->state(); const auto& STATE = state->state();
const uint32_t COMMITTED = STATE.committed; const uint32_t COMMITTED = STATE.committed;