Mesa (master): panfrost: Make panfrost_bo_wait take a wait_readers bool

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Jul 18 01:56:45 UTC 2020


Module: Mesa
Branch: master
Commit: 858cc13eb28e4b034e1ce6fb5b2d0a49f0d97534
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=858cc13eb28e4b034e1ce6fb5b2d0a49f0d97534

Author: Icecream95 <ixn at keemail.me>
Date:   Sat Jul 18 11:36:36 2020 +1200

panfrost: Make panfrost_bo_wait take a wait_readers bool

panfrost_bo_wait is often used after
panfrost_flush_batches_accessing_bo, so make them take similar
arguments for consistency.

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5962>

---

 src/gallium/drivers/panfrost/pan_context.c  |  2 +-
 src/gallium/drivers/panfrost/pan_resource.c |  8 ++++----
 src/panfrost/encoder/pan_bo.c               | 17 ++++-------------
 src/panfrost/encoder/pan_bo.h               |  3 +--
 4 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c
index 37c9fee621c..ca383a8a8be 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -1391,7 +1391,7 @@ panfrost_get_query_result(struct pipe_context *pipe,
         case PIPE_QUERY_OCCLUSION_PREDICATE:
         case PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE:
                 panfrost_flush_batches_accessing_bo(ctx, query->bo, PAN_BO_ACCESS_WRITE);
-                panfrost_bo_wait(query->bo, INT64_MAX, PAN_BO_ACCESS_WRITE);
+                panfrost_bo_wait(query->bo, INT64_MAX, false);
 
                 /* Read back the query results */
                 unsigned *result = (unsigned *) query->bo->cpu;
diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c
index 9440ef7956a..70a6d3d9b66 100644
--- a/src/gallium/drivers/panfrost/pan_resource.c
+++ b/src/gallium/drivers/panfrost/pan_resource.c
@@ -579,7 +579,7 @@ panfrost_transfer_map(struct pipe_context *pctx,
                  */
 
                 panfrost_flush_batches_accessing_bo(ctx, bo, PAN_BO_ACCESS_WRITE);
-                panfrost_bo_wait(bo, INT64_MAX, PAN_BO_ACCESS_WRITE);
+                panfrost_bo_wait(bo, INT64_MAX, false);
 
                 create_new_bo = true;
                 copy_resource = true;
@@ -591,7 +591,7 @@ panfrost_transfer_map(struct pipe_context *pctx,
                  * batches), we try to allocate a new one to avoid waiting.
                  */
                 if (panfrost_pending_batches_access_bo(ctx, bo) ||
-                    !panfrost_bo_wait(bo, 0, PAN_BO_ACCESS_RW)) {
+                    !panfrost_bo_wait(bo, 0, true)) {
                         /* We want the BO to be MMAPed. */
                         uint32_t flags = bo->flags & ~PAN_BO_DELAY_MMAP;
                         struct panfrost_bo *newbo = NULL;
@@ -627,10 +627,10 @@ panfrost_transfer_map(struct pipe_context *pctx,
         } else if (!(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) {
                 if (usage & PIPE_TRANSFER_WRITE) {
                         panfrost_flush_batches_accessing_bo(ctx, bo, true);
-                        panfrost_bo_wait(bo, INT64_MAX, PAN_BO_ACCESS_RW);
+                        panfrost_bo_wait(bo, INT64_MAX, true);
                 } else if (usage & PIPE_TRANSFER_READ) {
                         panfrost_flush_batches_accessing_bo(ctx, bo, false);
-                        panfrost_bo_wait(bo, INT64_MAX, PAN_BO_ACCESS_WRITE);
+                        panfrost_bo_wait(bo, INT64_MAX, false);
                 }
         }
 
diff --git a/src/panfrost/encoder/pan_bo.c b/src/panfrost/encoder/pan_bo.c
index 12ca68f8e49..71bc109060d 100644
--- a/src/panfrost/encoder/pan_bo.c
+++ b/src/panfrost/encoder/pan_bo.c
@@ -105,16 +105,11 @@ panfrost_bo_free(struct panfrost_bo *bo)
 
 /* Returns true if the BO is ready, false otherwise.
  * access_type is encoding the type of access one wants to ensure is done.
- * Say you want to make sure all writers are done writing, you should pass
- * PAN_BO_ACCESS_WRITE.
- * If you want to wait for all users, you should pass PAN_BO_ACCESS_RW.
- * PAN_BO_ACCESS_READ would work too as waiting for readers implies
- * waiting for writers as well, but we want to make things explicit and waiting
- * only for readers is impossible.
+ * Waiting is always done for writers, but if wait_readers is set then readers
+ * are also waited for.
  */
 bool
-panfrost_bo_wait(struct panfrost_bo *bo, int64_t timeout_ns,
-                 uint32_t access_type)
+panfrost_bo_wait(struct panfrost_bo *bo, int64_t timeout_ns, bool wait_readers)
 {
         struct drm_panfrost_wait_bo req = {
                 .handle = bo->gem_handle,
@@ -122,9 +117,6 @@ panfrost_bo_wait(struct panfrost_bo *bo, int64_t timeout_ns,
         };
         int ret;
 
-        assert(access_type == PAN_BO_ACCESS_WRITE ||
-               access_type == PAN_BO_ACCESS_RW);
-
         /* If the BO has been exported or imported we can't rely on the cached
          * state, we need to call the WAIT_BO ioctl.
          */
@@ -136,8 +128,7 @@ panfrost_bo_wait(struct panfrost_bo *bo, int64_t timeout_ns,
                 /* If the caller only wants to wait for writers and no
                  * writes are pending, we don't have to wait.
                  */
-                if (access_type == PAN_BO_ACCESS_WRITE &&
-                    !(bo->gpu_access & PAN_BO_ACCESS_WRITE))
+                if (!wait_readers && !(bo->gpu_access & PAN_BO_ACCESS_WRITE))
                         return true;
         }
 
diff --git a/src/panfrost/encoder/pan_bo.h b/src/panfrost/encoder/pan_bo.h
index dfd182290a3..84d2a0aee98 100644
--- a/src/panfrost/encoder/pan_bo.h
+++ b/src/panfrost/encoder/pan_bo.h
@@ -107,8 +107,7 @@ struct panfrost_bo {
 };
 
 bool
-panfrost_bo_wait(struct panfrost_bo *bo, int64_t timeout_ns,
-                 uint32_t access_type);
+panfrost_bo_wait(struct panfrost_bo *bo, int64_t timeout_ns, bool wait_readers);
 void
 panfrost_bo_reference(struct panfrost_bo *bo);
 void



More information about the mesa-commit mailing list