From e29a640dd6f26d50e29cabac2611bd97841c2101 Mon Sep 17 00:00:00 2001 From: Gurchetan Singh Date: Thu, 5 Oct 2017 14:52:24 -0700 Subject: [PATCH 1/1] minigbm: respect map_flags in all cases 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 Tested-by: Gurchetan Singh Commit-Queue: Gurchetan Singh --- drv.c | 3 +++ drv.h | 1 + mediatek.c | 2 +- rockchip.c | 2 +- tegra.c | 4 +--- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drv.c b/drv.c index 13722b0..6094ad5 100644 --- 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 --- 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; }; diff --git a/mediatek.c b/mediatek.c index 8494c3d..1a1061c 100644 --- a/mediatek.c +++ b/mediatek.c @@ -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; diff --git a/rockchip.c b/rockchip.c index 6de5e92..97ca85b 100644 --- a/rockchip.c +++ b/rockchip.c @@ -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 --- 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; -- 2.11.0