diff options
author | Gurchetan Singh <gurchetansingh@chromium.org> | 2017-09-14 14:18:43 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-09-27 23:52:08 -0700 |
commit | 8e02e05537eab60fc39e2c660d41e43be2ac522b (patch) | |
tree | 512b5e6ba669461943547858f8a0ce63e6ce6060 | |
parent | ff7414151e34a82fc290f79168553d01f5e654eb (diff) |
minigbm: add (*bo_flush) implementations
Let's take the flush and writeback steps in the driver unmap
functions and move them to the (*bo_flush) callback.
BUG=chromium:764871
TEST=gbmtest, mmap_test -g on eve
Change-Id: Iecccafc25642b120bc84f2d1b8538303c8ce36eb
Reviewed-on: https://chromium-review.googlesource.com/668219
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
-rw-r--r-- | i915.c | 7 | ||||
-rw-r--r-- | mediatek.c | 12 | ||||
-rw-r--r-- | rockchip.c | 12 | ||||
-rw-r--r-- | tegra.c | 15 |
4 files changed, 38 insertions, 8 deletions
@@ -476,13 +476,13 @@ static void *i915_bo_map(struct bo *bo, struct map_info *data, size_t plane, int return addr; } -static int i915_bo_unmap(struct bo *bo, struct map_info *data) +static int i915_bo_flush(struct bo *bo, struct map_info *data) { struct i915_device *i915 = bo->drv->priv; if (!i915->has_llc && bo->tiling == I915_TILING_NONE) i915_clflush(data->addr, data->length); - return munmap(data->addr, data->length); + return 0; } static uint32_t i915_resolve_format(uint32_t format, uint64_t usage) @@ -512,7 +512,8 @@ struct backend backend_i915 = { .bo_destroy = drv_gem_bo_destroy, .bo_import = i915_bo_import, .bo_map = i915_bo_map, - .bo_unmap = i915_bo_unmap, + .bo_unmap = drv_bo_munmap, + .bo_flush = i915_bo_flush, .resolve_format = i915_resolve_format, }; @@ -113,7 +113,6 @@ static int mediatek_bo_unmap(struct bo *bo, struct map_info *data) { if (data->priv) { struct mediatek_private_map_data *priv = data->priv; - memcpy(priv->gem_addr, priv->cached_addr, bo->total_size); data->addr = priv->gem_addr; free(priv->cached_addr); free(priv); @@ -123,6 +122,16 @@ static int mediatek_bo_unmap(struct bo *bo, struct map_info *data) return munmap(data->addr, data->length); } +static int mediatek_bo_flush(struct bo *bo, struct map_info *data) +{ + struct mediatek_private_map_data *priv = data->priv; + + if (priv) + memcpy(priv->gem_addr, priv->cached_addr, bo->total_size); + + return 0; +} + static uint32_t mediatek_resolve_format(uint32_t format, uint64_t usage) { switch (format) { @@ -144,6 +153,7 @@ struct backend backend_mediatek = { .bo_import = drv_prime_bo_import, .bo_map = mediatek_bo_map, .bo_unmap = mediatek_bo_unmap, + .bo_flush = mediatek_bo_flush, .resolve_format = mediatek_resolve_format, }; @@ -280,7 +280,6 @@ static int rockchip_bo_unmap(struct bo *bo, struct map_info *data) { if (data->priv) { struct rockchip_private_map_data *priv = data->priv; - memcpy(priv->gem_addr, priv->cached_addr, bo->total_size); data->addr = priv->gem_addr; free(priv->cached_addr); free(priv); @@ -290,6 +289,16 @@ static int rockchip_bo_unmap(struct bo *bo, struct map_info *data) return munmap(data->addr, data->length); } +static int rockchip_bo_flush(struct bo *bo, struct map_info *data) +{ + struct rockchip_private_map_data *priv = data->priv; + + if (priv) + memcpy(priv->gem_addr, priv->cached_addr, bo->total_size); + + return 0; +} + static uint32_t rockchip_resolve_format(uint32_t format, uint64_t usage) { switch (format) { @@ -315,6 +324,7 @@ struct backend backend_rockchip = { .bo_import = drv_prime_bo_import, .bo_map = rockchip_bo_map, .bo_unmap = rockchip_bo_unmap, + .bo_flush = rockchip_bo_flush, .resolve_format = rockchip_resolve_format, }; @@ -334,9 +334,6 @@ static int tegra_bo_unmap(struct bo *bo, struct map_info *data) { if (data->priv) { struct tegra_private_map_data *priv = data->priv; - if (priv->prot & PROT_WRITE) - transfer_tiled_memory(bo, priv->tiled, priv->untiled, - TEGRA_WRITE_TILED_BUFFER); data->addr = priv->tiled; free(priv->untiled); free(priv); @@ -346,6 +343,17 @@ static int tegra_bo_unmap(struct bo *bo, struct map_info *data) return munmap(data->addr, data->length); } +static int tegra_bo_flush(struct bo *bo, struct map_info *data) +{ + struct tegra_private_map_data *priv = data->priv; + + if (priv && priv->prot & PROT_WRITE) + transfer_tiled_memory(bo, priv->tiled, priv->untiled, + TEGRA_WRITE_TILED_BUFFER); + + return 0; +} + struct backend backend_tegra = { .name = "tegra", .init = tegra_init, @@ -354,6 +362,7 @@ struct backend backend_tegra = { .bo_import = tegra_bo_import, .bo_map = tegra_bo_map, .bo_unmap = tegra_bo_unmap, + .bo_flush = tegra_bo_flush, }; #endif |