drm_hwcomposer: Fix issue with display resources not being released
Fixes an issue where the display resources and DRM devices were not
released when ComposerClient was being destroyed. This also fixes the
issue of DrmDevice being unable to acquire DRM master if the composer
client was destroyed and re-created without restarting the whole
composer service.
Change-Id: I3eb25dd250dff639dcf66fdd4123d7b2c87e45d4
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
Signed-off-by: Drew Davenport <ddavenport@google.com>
diff --git a/hwc3/ComposerClient.cpp b/hwc3/ComposerClient.cpp
index e49698f..da6f0f5 100644
--- a/hwc3/ComposerClient.cpp
+++ b/hwc3/ComposerClient.cpp
@@ -77,7 +77,6 @@
return composer_resources_ != nullptr;
}
-// NOLINTNEXTLINE(bugprone-exception-escape)
ComposerClient::~ComposerClient() {
DEBUG_FUNC();
LOG(DEBUG) << "removed composer client";
diff --git a/hwc3/DrmHwcThree.cpp b/hwc3/DrmHwcThree.cpp
index b39d834..4fb33a1 100644
--- a/hwc3/DrmHwcThree.cpp
+++ b/hwc3/DrmHwcThree.cpp
@@ -25,17 +25,9 @@
using ::android::HwcDisplay;
-// NOLINTNEXTLINE(bugprone-exception-escape)
DrmHwcThree::~DrmHwcThree() {
- std::vector<uint64_t> display_ids;
- display_ids.reserve(Displays().size());
- for (auto& [display_id, display] : Displays()) {
- display_ids.push_back(display_id);
- }
-
- for (auto display_id : display_ids) {
- RemoveAndDestroyDisplay(display_id);
- }
+ /* Display deinit routine is handled by resource manager */
+ GetResMan().DeInit();
}
void DrmHwcThree::Init(std::shared_ptr<IComposerCallback> callback) {
@@ -72,17 +64,12 @@
composer_callback_->onHotplug(static_cast<int64_t>(display_id), connected);
}
-void DrmHwcThree::RemoveAndDestroyDisplay(uint64_t display_id) {
+void DrmHwcThree::RemoveDisplay(uint64_t display_id) {
DEBUG_FUNC();
HwcDisplay* display = GetDisplay(display_id);
if (display == nullptr) {
return;
}
-
- display->SetPowerMode(static_cast<int32_t>(HWC2::PowerMode::Off));
- display->Deinit();
-
- composer_resources_->RemoveDisplay(static_cast<int64_t>(display_id));
Displays().erase(display_id);
}
diff --git a/hwc3/DrmHwcThree.h b/hwc3/DrmHwcThree.h
index 90e5f32..76b9949 100644
--- a/hwc3/DrmHwcThree.h
+++ b/hwc3/DrmHwcThree.h
@@ -42,7 +42,7 @@
bool connected) override;
private:
- void RemoveAndDestroyDisplay(uint64_t display_id);
+ void RemoveDisplay(uint64_t display_id);
void CleanDisplayResources(uint64_t display_id);
void HandleDisplayHotplugEvent(uint64_t display_id, bool connected);