minigbm: rockchip/mediatek: invalidate shadow buffers

In the case where process A is writing to the buffer, and process
B is reading from the buffer via a shadow buffer, we should update
the shadow buffer.

This issue seems to only pop on renderscript tests on Mediatek devices,
but that's due the various differences between 3D driver implementations.
Let's modify rockchip for correctness as well.

BUG=b:69700010
TEST=run cts -m CtsViewTestCases -t android.view.cts.SurfaceViewSyncTests
     passes on Oak

Change-Id: Id551027a2093f5423ee380d8935637d6256d2295
Reviewed-on: https://chromium-review.googlesource.com/795038
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
This commit is contained in:
Gurchetan Singh 2017-11-28 16:56:17 -08:00 committed by chrome-bot
parent ca2938a5c6
commit ef262d8e31
2 changed files with 22 additions and 2 deletions

View file

@ -97,7 +97,6 @@ static void *mediatek_bo_map(struct bo *bo, struct vma *vma, size_t plane, uint3
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);
vma->priv = priv;
addr = priv->cached_addr;
}
@ -118,6 +117,16 @@ static int mediatek_bo_unmap(struct bo *bo, struct vma *vma)
return munmap(vma->addr, vma->length);
}
static int mediatek_bo_invalidate(struct bo *bo, struct mapping *mapping)
{
if (mapping->vma->priv) {
struct mediatek_private_map_data *priv = mapping->vma->priv;
memcpy(priv->cached_addr, priv->gem_addr, bo->total_size);
}
return 0;
}
static int mediatek_bo_flush(struct bo *bo, struct mapping *mapping)
{
struct mediatek_private_map_data *priv = mapping->vma->priv;
@ -148,6 +157,7 @@ const struct backend backend_mediatek = {
.bo_import = drv_prime_bo_import,
.bo_map = mediatek_bo_map,
.bo_unmap = mediatek_bo_unmap,
.bo_invalidate = mediatek_bo_invalidate,
.bo_flush = mediatek_bo_flush,
.resolve_format = mediatek_resolve_format,
};

View file

@ -260,7 +260,6 @@ static void *rockchip_bo_map(struct bo *bo, struct vma *vma, size_t plane, uint3
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);
vma->priv = priv;
addr = priv->cached_addr;
}
@ -281,6 +280,16 @@ static int rockchip_bo_unmap(struct bo *bo, struct vma *vma)
return munmap(vma->addr, vma->length);
}
static int rockchip_bo_invalidate(struct bo *bo, struct mapping *mapping)
{
if (mapping->vma->priv) {
struct rockchip_private_map_data *priv = mapping->vma->priv;
memcpy(priv->cached_addr, priv->gem_addr, bo->total_size);
}
return 0;
}
static int rockchip_bo_flush(struct bo *bo, struct mapping *mapping)
{
struct rockchip_private_map_data *priv = mapping->vma->priv;
@ -315,6 +324,7 @@ const struct backend backend_rockchip = {
.bo_import = drv_prime_bo_import,
.bo_map = rockchip_bo_map,
.bo_unmap = rockchip_bo_unmap,
.bo_invalidate = rockchip_bo_invalidate,
.bo_flush = rockchip_bo_flush,
.resolve_format = rockchip_resolve_format,
};