OSDN Git Service

minigbm: respect map_flags in all cases
authorGurchetan Singh <gurchetansingh@chromium.org>
Thu, 5 Oct 2017 21:52:24 +0000 (14:52 -0700)
committerGurchetan Singh <gurchetansingh@chromium.org>
Fri, 13 Oct 2017 16:17:33 +0000 (16:17 +0000)
When the map flags do not feature BO_TRANSFER_WRITE, we should
not copy back any shadow buffers we maintain.

BUG=b:67434931
TEST=android.view.cts.SurfaceViewSyncTests on Mediatek/Rockchip

Change-Id: I7078bfc5a8d770a52949d43ea68efc4a870e9227
Reviewed-on: https://chromium-review.googlesource.com/703875
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>

drv.c
drv.h
mediatek.c
rockchip.c
tegra.c

diff --git a/drv.c b/drv.c
index 13722b0..6094ad5 100644 (file)
--- a/drv.c
+++ b/drv.c
@@ -401,6 +401,8 @@ void *drv_bo_map(struct bo *bo, uint32_t x, uint32_t y, uint32_t width, uint32_t
 
        if (!drmHashLookup(bo->drv->map_table, bo->handles[plane].u32, &ptr)) {
                data = (struct map_info *)ptr;
+               /* TODO(gsingh): support mapping same buffer with different flags. */
+               assert(data->map_flags == map_flags);
                data->refcount++;
                goto success;
        }
@@ -417,6 +419,7 @@ void *drv_bo_map(struct bo *bo, uint32_t x, uint32_t y, uint32_t width, uint32_t
        data->refcount = 1;
        data->addr = addr;
        data->handle = bo->handles[plane].u32;
+       data->map_flags = map_flags;
        drmHashInsert(bo->drv->map_table, bo->handles[plane].u32, (void *)data);
 
 success:
diff --git a/drv.h b/drv.h
index ad2f82a..e62d164 100644 (file)
--- a/drv.h
+++ b/drv.h
@@ -82,6 +82,7 @@ struct map_info {
        void *addr;
        size_t length;
        uint32_t handle;
+       uint32_t map_flags;
        int32_t refcount;
        void *priv;
 };
index 8494c3d..1a1061c 100644 (file)
@@ -126,7 +126,7 @@ static int mediatek_bo_unmap(struct bo *bo, struct map_info *data)
 static int mediatek_bo_flush(struct bo *bo, struct map_info *data)
 {
        struct mediatek_private_map_data *priv = data->priv;
-       if (priv)
+       if (priv && (data->map_flags & BO_MAP_WRITE))
                memcpy(priv->gem_addr, priv->cached_addr, bo->total_size);
 
        return 0;
index 6de5e92..97ca85b 100644 (file)
@@ -292,7 +292,7 @@ static int rockchip_bo_unmap(struct bo *bo, struct map_info *data)
 static int rockchip_bo_flush(struct bo *bo, struct map_info *data)
 {
        struct rockchip_private_map_data *priv = data->priv;
-       if (priv)
+       if (priv && (data->map_flags & BO_MAP_WRITE))
                memcpy(priv->gem_addr, priv->cached_addr, bo->total_size);
 
        return 0;
diff --git a/tegra.c b/tegra.c
index f116c36..02f0d1a 100644 (file)
--- a/tegra.c
+++ b/tegra.c
@@ -44,7 +44,6 @@ enum tegra_map_type {
 struct tegra_private_map_data {
        void *tiled;
        void *untiled;
-       uint32_t map_flags;
 };
 
 static const uint32_t render_target_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_XRGB8888 };
@@ -323,7 +322,6 @@ static void *tegra_bo_map(struct bo *bo, struct map_info *data, size_t plane, ui
                priv = calloc(1, sizeof(*priv));
                priv->untiled = calloc(1, bo->total_size);
                priv->tiled = addr;
-               priv->map_flags = map_flags;
                data->priv = priv;
                transfer_tiled_memory(bo, priv->tiled, priv->untiled, TEGRA_READ_TILED_BUFFER);
                addr = priv->untiled;
@@ -349,7 +347,7 @@ static int tegra_bo_flush(struct bo *bo, struct map_info *data)
 {
        struct tegra_private_map_data *priv = data->priv;
 
-       if (priv && (priv->map_flags & BO_MAP_WRITE))
+       if (priv && (data->map_flags & BO_MAP_WRITE))
                transfer_tiled_memory(bo, priv->tiled, priv->untiled, TEGRA_WRITE_TILED_BUFFER);
 
        return 0;