summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Stultz <john.stultz@linaro.org>2018-05-31 17:46:50 -0700
committerJohn Stultz <john.stultz@linaro.org>2018-06-14 10:47:14 -0700
commit53cb4ef4da1ad4c3cb1d138cf8d05f988b304a0d (patch)
treecfb12aa40bd64d73b322c30ea4b34be73cf331df
parent1542d29a538683250b818922527aec33774c793b (diff)
drm_hwcomposer: platformdrmgeneric: Handle closing gem_handles if we have duplicate handles
In some cases some multi-plane bo's may have multiple gem_handles/offsets/pitches set. And its possible to have multiple planes that use the same gem_handle with different offsets/pitches. Thus, when closing the gem_handles, if we're not careful we could close the same handle multiple times. So this patch avoids this by taking some old code from the nv importer: https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer/blob/aeccd89eaafec467cb9449cce5c64152a240c138/platformnv.cpp#L176 Many thanks to Stefan Schake for pointing me to that code. Change-Id: Ifecd0f95de5ada5280a0af807005d0b0186a068c Signed-off-by: John Stultz <john.stultz@linaro.org>
-rw-r--r--platformdrmgeneric.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/platformdrmgeneric.cpp b/platformdrmgeneric.cpp
index 5b42c4a..7c4758d 100644
--- a/platformdrmgeneric.cpp
+++ b/platformdrmgeneric.cpp
@@ -128,10 +128,14 @@ int DrmGenericImporter::ReleaseBuffer(hwc_drm_bo_t *bo) {
gem_close.handle = bo->gem_handles[i];
int ret = drmIoctl(drm_->fd(), DRM_IOCTL_GEM_CLOSE, &gem_close);
- if (ret)
+ if (ret) {
ALOGE("Failed to close gem handle %d %d", i, ret);
- else
+ } else {
+ for (int j = i + 1; j < num_gem_handles; j++)
+ if (bo->gem_handles[j] == bo->gem_handles[i])
+ bo->gem_handles[j] = 0;
bo->gem_handles[i] = 0;
+ }
}
return 0;
}