From 7afd8e495ad94e97861fe86ea3ee6582be0ce536 Mon Sep 17 00:00:00 2001 From: "Eric R. Smith" Date: Tue, 26 Mar 2024 17:56:04 -0300 Subject: [PATCH] panfrost: fix a GPU/CPU synchronization problem Remove a premature optimization. When PIPE_MAP_DISCARD_WHOLE_RESOURCE is set we were setting create_new_bo, and then if that was set we skipped a set of tests which if passed would cause a panfrost_flush_writer. In fact we need that flush in some cases (e.g. when any batch is reading the resource). Moreover, we should sometimes copy the resource (set the copy_resource flag) and that again was being skipped if create_new_bo was initially true due to PIPE_MAP_DISCARD_WHOLE_RESOURCE being set. Cc: mesa-stable Signed-off-by: Eric R. Smith Acked-by: Erik Faye-Lund Part-of: (cherry picked from commit e3d123b7a67aff618720e0bc550b2d27b1e56fc5) --- .pick_status.json | 2 +- src/gallium/drivers/panfrost/pan_resource.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 12ed6dea203..5ab8f901fd6 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -2614,7 +2614,7 @@ "description": "panfrost: fix a GPU/CPU synchronization problem", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index aa2974eb5eb..7bf25155e51 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -1181,7 +1181,7 @@ panfrost_ptr_map(struct pipe_context *pctx, struct pipe_resource *resource, bool create_new_bo = usage & PIPE_MAP_DISCARD_WHOLE_RESOURCE; bool copy_resource = false; - if (!create_new_bo && !(usage & PIPE_MAP_UNSYNCHRONIZED) && + if (!(usage & PIPE_MAP_UNSYNCHRONIZED) && !(resource->flags & PIPE_RESOURCE_FLAG_MAP_PERSISTENT) && (usage & PIPE_MAP_WRITE) && panfrost_any_batch_reads_rsrc(ctx, rsrc)) { /* When a resource to be modified is already being used by a