drm_hwcomposer: Fix bug where DrmDevice can be released early
DrmFbImporter can outlive DrmDevice which will cause issues when
resources are released. Addressing this would require a restructure
on how ResourceManager stores DrmDevices and DrmFbImporter to make
sure they depend on each other. For now, just acquire the DRM fd from
the DrmDevice to make sure it is not closed.
Change-Id: If46ca0f879bee4a5da2f93d341b6f1278e593010
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
Signed-off-by: Drew Davenport <ddavenport@google.com>
diff --git a/drm/DrmFbImporter.h b/drm/DrmFbImporter.h
index 9a7c335..30f57ba 100644
--- a/drm/DrmFbImporter.h
+++ b/drm/DrmFbImporter.h
@@ -24,6 +24,7 @@
#include "bufferinfo/BufferInfo.h"
#include "drm/DrmDevice.h"
+#include "utils/fd.h"
#ifndef DRM_FORMAT_INVALID
#define DRM_FORMAT_INVALID 0
@@ -49,9 +50,9 @@
}
private:
- explicit DrmFbIdHandle(DrmDevice &drm) : drm_(&drm){};
+ explicit DrmFbIdHandle(DrmDevice &drm) : drm_fd_(drm.GetFd()) {};
- DrmDevice *const drm_;
+ SharedFd drm_fd_;
uint32_t fb_id_{};
std::array<GemHandle, kBufferMaxPlanes> gem_handles_{};
@@ -81,6 +82,7 @@
}
DrmDevice *const drm_;
+ SharedFd drm_fd_;
std::map<GemHandle, std::weak_ptr<DrmFbIdHandle>> drm_fb_id_handle_cache_;
};