svga: finish readbacks before mapping resources
authorZack Rusin <zackr@vmware.com>
Wed, 2 Mar 2022 19:08:09 +0000 (14:08 -0500)
committerMarge Bot <emma+marge@anholt.net>
Tue, 26 Apr 2022 00:33:25 +0000 (00:33 +0000)
Flushing the command queue before mapping a resource is not enough
to guaruantee that the mapped content is not stale. We have to finish
to make sure that the gb readback actually updated the guest surface.

This fixes races in direct maps (map reads raced with gb readbacks)

Signed-off-by: Zack Rusin <zackr@vmware.com>
Reviewed-by: Charmaine Lee <charmainel@vmware.com>
Reviewed-by: Neha Bhende <bhenden@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16061>

src/gallium/drivers/svga/svga_resource_texture.c

index cc1514b..ff2c500 100644 (file)
@@ -342,9 +342,9 @@ svga_texture_transfer_map_direct(struct svga_context *svga,
 
       if (!svga->swc->force_coherent || tex->imported) {
          /* Readback the whole surface */
-        readback_texture_surface(svga, tex, surf);
+         readback_texture_surface(svga, tex, surf);
 
-         svga_context_flush(svga, NULL);
+         svga_context_finish(svga);
       }
       /*
        * Note: if PIPE_MAP_DISCARD_WHOLE_RESOURCE were specified