freedreno: Flush resources harder
authorRob Clark <robdclark@chromium.org>
Thu, 29 Apr 2021 18:10:46 +0000 (11:10 -0700)
committerRob Clark <robdclark@chromium.org>
Sat, 1 May 2021 15:46:27 +0000 (08:46 -0700)
pctx->flush_resource() has the same expectations that the resource can
be shared with an external client as pctx->flush(), but without the
convenience of a fence to know *when* the resource must be visible to
that external client.  So we need to ensure the batch is flushed all the
way to the kernel so that implicit-sync can do it's job.

Fixes: e9a9ac6f77f ("freedreno/drm: Async submit support")
Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10530>

src/gallium/drivers/freedreno/freedreno_resource.c

index da19157..2adaf60 100644 (file)
@@ -641,9 +641,18 @@ flush_resource(struct fd_context *ctx, struct fd_resource *rsc,
 }
 
 static void
-fd_flush_resource(struct pipe_context *pctx, struct pipe_resource *prsc) in_dt
+fd_flush_resource(struct pipe_context *pctx, struct pipe_resource *prsc)
+   in_dt
 {
-   flush_resource(fd_context(pctx), fd_resource(prsc), PIPE_MAP_READ);
+   struct fd_context *ctx = fd_context(pctx);
+   struct fd_resource *rsc = fd_resource(prsc);
+
+   flush_resource(ctx, rsc, PIPE_MAP_READ);
+
+   /* If we had to flush a batch, make sure it makes it's way all the
+    * way to the kernel:
+    */
+   fd_resource_wait(ctx, rsc, FD_BO_PREP_FLUSH);
 }
 
 static void