From 6e02c9dac49084e7e94f33e3861e30b46647f914 Mon Sep 17 00:00:00 2001 From: Isaac Simha Date: Wed, 14 Oct 2015 11:40:29 -0700 Subject: [PATCH] drm_hwcomposer: Do not close duplicate gem handles in nvimporter When closing gem handles in ReleaseBufferImpl, do not try to close the same one more than once. BUG=chrome-os-partner:46443 TEST=Play youtube video, minimize. Observe no "Failed to close gem handle" messages in logcat. Change-Id: I06598f304e3bd167a77f105eb2be86595ada8f4d Signed-off-by: Isaac Simha Signed-off-by: Sean Paul --- nvimporter.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nvimporter.cpp b/nvimporter.cpp index de3ed55..71b3b7f 100644 --- a/nvimporter.cpp +++ b/nvimporter.cpp @@ -157,10 +157,15 @@ void NvImporter::ReleaseBufferImpl(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 { + /* Clear any duplicate gem handle as well but don't close again */ + 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; + } } } -- 2.11.0