Mesa (master): freedreno: Fix missing rsc->seqno updates

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Sep 3 00:20:01 UTC 2020


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

Author: Rob Clark <robdclark at chromium.org>
Date:   Tue Sep  1 11:23:49 2020 -0700

freedreno: Fix missing rsc->seqno updates

There were a couple paths where we weren't getting valid seqno's, which
are supposed to be updated whenever the backing bo is set/changed.  So
wrap that up in a helper to make it harder to mess up.

Signed-off-by: Rob Clark <robdclark at chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6575>

---

 src/gallium/drivers/freedreno/freedreno_resource.c | 21 ++++++++++++++++-----
 src/gallium/drivers/freedreno/freedreno_resource.h |  2 +-
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c
index 0caa3f6756b..803054c4f2f 100644
--- a/src/gallium/drivers/freedreno/freedreno_resource.c
+++ b/src/gallium/drivers/freedreno/freedreno_resource.c
@@ -166,6 +166,15 @@ rebind_resource(struct fd_resource *rsc)
 	fd_screen_unlock(screen);
 }
 
+static inline void
+fd_resource_set_bo(struct fd_resource *rsc, struct fd_bo *bo)
+{
+	struct fd_screen *screen = fd_screen(rsc->base.screen);
+
+	rsc->bo = bo;
+	rsc->seqno = p_atomic_inc_return(&screen->rsc_seqno);
+}
+
 static void
 realloc_bo(struct fd_resource *rsc, uint32_t size)
 {
@@ -183,8 +192,9 @@ realloc_bo(struct fd_resource *rsc, uint32_t size)
 	if (rsc->bo)
 		fd_bo_del(rsc->bo);
 
-	rsc->bo = fd_bo_new(screen->dev, size, flags, "%ux%ux%u@%u:%x",
+	struct fd_bo *bo = fd_bo_new(screen->dev, size, flags, "%ux%ux%u@%u:%x",
 			prsc->width0, prsc->height0, prsc->depth0, rsc->layout.cpp, prsc->bind);
+	fd_resource_set_bo(rsc, bo);
 
 	/* Zero out the UBWC area on allocation.  This fixes intermittent failures
 	 * with UBWC, which I suspect are due to the HW having a hard time
@@ -197,7 +207,6 @@ realloc_bo(struct fd_resource *rsc, uint32_t size)
 		rsc->needs_ubwc_clear = true;
 	}
 
-	rsc->seqno = p_atomic_inc_return(&screen->rsc_seqno);
 	util_range_set_empty(&rsc->valid_buffer_range);
 	fd_bc_invalidate_resource(rsc, true);
 }
@@ -1077,10 +1086,12 @@ fd_resource_from_handle(struct pipe_screen *pscreen,
 
 	simple_mtx_init(&rsc->lock, mtx_plain);
 
-	rsc->bo = fd_screen_bo_from_handle(pscreen, handle);
-	if (!rsc->bo)
+	struct fd_bo *bo = fd_screen_bo_from_handle(pscreen, handle);
+	if (!bo)
 		goto fail;
 
+	fd_resource_set_bo(rsc, bo);
+
 	rsc->internal_format = tmpl->format;
 	rsc->layout.pitch0 = handle->stride;
 	slice->offset = handle->offset;
@@ -1270,7 +1281,7 @@ fd_resource_from_memobj(struct pipe_screen *pscreen,
 	}
 
 	/* Share the bo with the memory object. */
-	rsc->bo = fd_bo_ref(memobj->bo);
+	fd_resource_set_bo(rsc, fd_bo_ref(memobj->bo));
 
 	return prsc;
 }
diff --git a/src/gallium/drivers/freedreno/freedreno_resource.h b/src/gallium/drivers/freedreno/freedreno_resource.h
index 3bc0ffb1320..77beda2bbc2 100644
--- a/src/gallium/drivers/freedreno/freedreno_resource.h
+++ b/src/gallium/drivers/freedreno/freedreno_resource.h
@@ -46,7 +46,7 @@ enum fd_lrz_direction {
 
 struct fd_resource {
 	struct pipe_resource base;
-	struct fd_bo *bo;
+	struct fd_bo *bo;  /* use fd_resource_set_bo() to write */
 	enum pipe_format internal_format;
 	struct fdl_layout layout;
 



More information about the mesa-commit mailing list