OSDN Git Service

minigbm: flush buffer instead of unmapping
authorGurchetan Singh <gurchetansingh@chromium.org>
Thu, 14 Sep 2017 22:16:15 +0000 (15:16 -0700)
committerchrome-bot <chrome-bot@chromium.org>
Thu, 28 Sep 2017 06:52:08 +0000 (23:52 -0700)
As an optimization, let's call:
- drv_bo_flush when calling (*unlock).
- drv_bo_flush during gbm_bo_unmap()

CL:441916 makes sure that the buffer is unmapped before the
buffer destroy ioctl is called, so we will not be leaking
mappings in any case.

BUG=chromium:764871
TEST=Android boots, 8 CTS tests, and Youtube app works on Eve
     gbmtest, mmap_test -g

Change-Id: I429739a8c6435a434dac41ad125761364a3775d0
Reviewed-on: https://chromium-review.googlesource.com/668220
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
cros_gralloc/cros_gralloc_buffer.cc
gbm.c

index cec68a5..710b78f 100644 (file)
@@ -87,12 +87,9 @@ int32_t cros_gralloc_buffer::unlock()
                return -EINVAL;
        }
 
-       if (!--lockcount_) {
-               if (lock_data_[0]) {
-                       drv_bo_unmap(bo_, lock_data_[0]);
-                       lock_data_[0] = nullptr;
-               }
-       }
+       --lockcount_;
+       if (lock_data_[0])
+               return drv_bo_flush(bo_, lock_data_[0]);
 
        return 0;
 }
diff --git a/gbm.c b/gbm.c
index 58173ea..831dfbf 100644 (file)
--- a/gbm.c
+++ b/gbm.c
@@ -242,7 +242,7 @@ PUBLIC void *gbm_bo_map(struct gbm_bo *bo, uint32_t x, uint32_t y, uint32_t widt
 PUBLIC void gbm_bo_unmap(struct gbm_bo *bo, void *map_data)
 {
        assert(bo);
-       drv_bo_unmap(bo->bo, map_data);
+       drv_bo_flush(bo->bo, map_data);
 }
 
 PUBLIC uint32_t gbm_bo_get_width(struct gbm_bo *bo)