diff options
author | Gurchetan Singh <gurchetansingh@chromium.org> | 2017-08-03 18:17:34 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-08-05 22:07:49 -0700 |
commit | 469a3aae8237451a1ce9f9fcf47ee0a16c07e27b (patch) | |
tree | 2a24f90261e6334e8dcc45fb8e3040b39f8b5826 /rockchip.c | |
parent | 43ba07f7d43e94b5f971f89835972ead7a1ada72 (diff) |
minigbm: rockchip/mediatek: keep a local cached mapping of the buffer
All GEM mappings are write-combined by default. This leads to
performance issues with renderscript CTS tests on ARM boards.
Let's keep a local copy of the buffer in the hopes of improving
the test's performance.
BUG=b:38097499
TEST=run cts -m CtsViewTestCases -t android.view.cts.SurfaceViewSyncTests
passes on 9776.0.0 veyron_minnie
Change-Id: I74da770f42524e66ca643adfbe9475362ee397cc
Reviewed-on: https://chromium-review.googlesource.com/602736
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Diffstat (limited to 'rockchip.c')
-rw-r--r-- | rockchip.c | 34 |
1 files changed, 33 insertions, 1 deletions
@@ -18,6 +18,11 @@ #include "helpers.h" #include "util.h" +struct rockchip_private_map_data { + void *cached_addr; + void *gem_addr; +}; + static const uint32_t render_target_formats[] = { DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB8888, DRM_FORMAT_RGB565, DRM_FORMAT_XBGR8888, DRM_FORMAT_XRGB8888 }; @@ -229,6 +234,7 @@ static void *rockchip_bo_map(struct bo *bo, struct map_info *data, size_t plane, { int ret; struct drm_rockchip_gem_map_off gem_map; + struct rockchip_private_map_data *priv; /* We can only map buffers created with SW access flags, which should * have no modifiers (ie, not AFBC). */ @@ -244,9 +250,34 @@ static void *rockchip_bo_map(struct bo *bo, struct map_info *data, size_t plane, return MAP_FAILED; } + void *addr = mmap(0, bo->total_size, prot, MAP_SHARED, bo->drv->fd, gem_map.offset); + data->length = bo->total_size; - return mmap(0, bo->total_size, prot, MAP_SHARED, bo->drv->fd, gem_map.offset); + if (bo->flags & BO_USE_RENDERSCRIPT) { + priv = calloc(1, sizeof(*priv)); + priv->cached_addr = calloc(1, bo->total_size); + priv->gem_addr = addr; + memcpy(priv->cached_addr, priv->gem_addr, bo->total_size); + data->priv = priv; + addr = priv->cached_addr; + } + + return addr; +} + +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); + data->priv = NULL; + } + + return munmap(data->addr, data->length); } static uint32_t rockchip_resolve_format(uint32_t format, uint64_t usage) @@ -270,6 +301,7 @@ struct backend backend_rockchip = { .bo_destroy = drv_gem_bo_destroy, .bo_import = drv_prime_bo_import, .bo_map = rockchip_bo_map, + .bo_unmap = rockchip_bo_unmap, .resolve_format = rockchip_resolve_format, }; |