OSDN Git Service

minigbm: add drv_bo_flush
authorGurchetan Singh <gurchetansingh@chromium.org>
Thu, 14 Sep 2017 00:54:36 +0000 (17:54 -0700)
committerchrome-bot <chrome-bot@chromium.org>
Thu, 28 Sep 2017 06:52:08 +0000 (23:52 -0700)
As an optimization, we would like to separate buffer flush/writeback
and unmap. This patch adds the appropriate entry point in our
internal driver API. Overall, the proposed flow is:

- drv_bo_map(..) creates a mapping and associated metadata
- drv_bo_flush(..) writes memory from any cache or temporary
          buffer back to memory
        - drv_bo_unmap(..) flushes, and frees the mapping and
  associated metadata.

The drv_bo_flush function just does some sanity checks on
the map data at this point, but otherwise is a no-op.

BUG=chromium:764871
TEST=gbmtest, mmap_test -g on eve

Change-Id: If306f066a76bc5e0943c1170e2d6933fa5630eff
Reviewed-on: https://chromium-review.googlesource.com/668218
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
drv.c
drv.h
drv_priv.h

diff --git a/drv.c b/drv.c
index b43b771..fab9958 100644 (file)
--- a/drv.c
+++ b/drv.c
@@ -411,10 +411,9 @@ success:
 
 int drv_bo_unmap(struct bo *bo, struct map_info *data)
 {
 
 int drv_bo_unmap(struct bo *bo, struct map_info *data)
 {
-       int ret = 0;
-
-       assert(data);
-       assert(data->refcount >= 0);
+       int ret = drv_bo_flush(bo, data);
+       if (ret)
+               return ret;
 
        pthread_mutex_lock(&bo->drv->driver_lock);
 
 
        pthread_mutex_lock(&bo->drv->driver_lock);
 
@@ -429,6 +428,18 @@ int drv_bo_unmap(struct bo *bo, struct map_info *data)
        return ret;
 }
 
        return ret;
 }
 
+int drv_bo_flush(struct bo *bo, struct map_info *data)
+{
+       int ret = 0;
+       assert(data);
+       assert(data->refcount >= 0);
+
+       if (bo->drv->backend->bo_flush)
+               ret = bo->drv->backend->bo_flush(bo, data);
+
+       return ret;
+}
+
 uint32_t drv_bo_get_width(struct bo *bo)
 {
        return bo->width;
 uint32_t drv_bo_get_width(struct bo *bo)
 {
        return bo->width;
diff --git a/drv.h b/drv.h
index e4678a1..f9a7a87 100644 (file)
--- a/drv.h
+++ b/drv.h
@@ -113,7 +113,9 @@ struct bo *drv_bo_import(struct driver *drv, struct drv_import_fd_data *data);
 void *drv_bo_map(struct bo *bo, uint32_t x, uint32_t y, uint32_t width, uint32_t height,
                 uint32_t flags, struct map_info **map_data, size_t plane);
 
 void *drv_bo_map(struct bo *bo, uint32_t x, uint32_t y, uint32_t width, uint32_t height,
                 uint32_t flags, struct map_info **map_data, size_t plane);
 
-int drv_bo_unmap(struct bo *bo, struct map_info *map_data);
+int drv_bo_unmap(struct bo *bo, struct map_info *data);
+
+int drv_bo_flush(struct bo *bo, struct map_info *data);
 
 uint32_t drv_bo_get_width(struct bo *bo);
 
 
 uint32_t drv_bo_get_width(struct bo *bo);
 
index fed6c19..e7b2d25 100644 (file)
@@ -77,6 +77,7 @@ struct backend {
        int (*bo_import)(struct bo *bo, struct drv_import_fd_data *data);
        void *(*bo_map)(struct bo *bo, struct map_info *data, size_t plane, int prot);
        int (*bo_unmap)(struct bo *bo, struct map_info *data);
        int (*bo_import)(struct bo *bo, struct drv_import_fd_data *data);
        void *(*bo_map)(struct bo *bo, struct map_info *data, size_t plane, int prot);
        int (*bo_unmap)(struct bo *bo, struct map_info *data);
+       int (*bo_flush)(struct bo *bo, struct map_info *data);
        uint32_t (*resolve_format)(uint32_t format, uint64_t usage);
 };
 
        uint32_t (*resolve_format)(uint32_t format, uint64_t usage);
 };