drm_hwcomposer: Fixes for display hotplug / headless mode
Further testing showed that several issues is still present:
1. Boot without display doesn't work.
2. Unplug/plug primary display has some flaws due to incomplete
HwcDisplay disposal.
3. In case creation of the pipeline fails, hwcomposer crashes.
This commit aims to address them.
Fixes: bb594baa1c68 ("drm_hwcomposer: Rework HwcDisplay disposal to avoid races")
Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
diff --git a/hwc2_device/DrmHwcTwo.cpp b/hwc2_device/DrmHwcTwo.cpp
index e689419..4accb07 100644
--- a/hwc2_device/DrmHwcTwo.cpp
+++ b/hwc2_device/DrmHwcTwo.cpp
@@ -177,8 +177,14 @@
resource_manager_.Init();
} else {
resource_manager_.DeInit();
- /* Headless display may still be here, remove it */
- displays_.erase(kPrimaryDisplay);
+ /* Headless display may still be here. Remove it! */
+ if (displays_.count(kPrimaryDisplay) != 0) {
+ displays_[kPrimaryDisplay]->Deinit();
+ auto &mutex = GetResMan().GetMainLock();
+ mutex.unlock();
+ displays_.erase(kPrimaryDisplay);
+ mutex.lock();
+ }
}
break;
}