Mesa (master): freedreno: emit_marker() cleanup

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Nov 23 16:33:01 UTC 2020


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

Author: Rob Clark <robdclark at chromium.org>
Date:   Mon Nov 16 11:18:32 2020 -0800

freedreno: emit_marker() cleanup

1) Propagate the change to only emit markers in debug builds (and add
   the WFI that ensures they are synchronized with GPU.  We could
   consider dropping them entirely, since the GPU devcoredump support
   in newer kernels is more useful.  But it is still an occasionally
   useful fallback.

2) Use p_atomic_inc_return() to placate helgrind

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

---

 src/gallium/drivers/freedreno/a5xx/fd5_screen.h  |  9 ++++++---
 src/gallium/drivers/freedreno/a6xx/fd6_context.h |  9 ++-------
 src/gallium/drivers/freedreno/freedreno_util.c   |  2 +-
 src/gallium/drivers/freedreno/freedreno_util.h   | 15 ++++++++++++---
 4 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_screen.h b/src/gallium/drivers/freedreno/a5xx/fd5_screen.h
index 0a65b3b0737..fa54075d7f6 100644
--- a/src/gallium/drivers/freedreno/a5xx/fd5_screen.h
+++ b/src/gallium/drivers/freedreno/a5xx/fd5_screen.h
@@ -38,10 +38,13 @@ void fd5_screen_init(struct pipe_screen *pscreen);
 static inline void
 emit_marker5(struct fd_ringbuffer *ring, int scratch_idx)
 {
-	extern unsigned marker_cnt;
+	extern int32_t marker_cnt;
 	unsigned reg = REG_A5XX_CP_SCRATCH_REG(scratch_idx);
-	OUT_PKT4(ring, reg, 1);
-	OUT_RING(ring, ++marker_cnt);
+	if (__EMIT_MARKER) {
+		OUT_WFI5(ring);
+		OUT_PKT4(ring, reg, 1);
+		OUT_RING(ring, p_atomic_inc_return(&marker_cnt));
+	}
 }
 
 #endif /* FD5_SCREEN_H_ */
diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_context.h b/src/gallium/drivers/freedreno/a6xx/fd6_context.h
index 1ae97d47c91..ae1b4283c07 100644
--- a/src/gallium/drivers/freedreno/a6xx/fd6_context.h
+++ b/src/gallium/drivers/freedreno/a6xx/fd6_context.h
@@ -145,17 +145,12 @@ struct fd6_control {
 static inline void
 emit_marker6(struct fd_ringbuffer *ring, int scratch_idx)
 {
-	extern unsigned marker_cnt;
+	extern int32_t marker_cnt;
 	unsigned reg = REG_A6XX_CP_SCRATCH_REG(scratch_idx);
-#ifdef DEBUG
-#  define __EMIT_MARKER 1
-#else
-#  define __EMIT_MARKER 0
-#endif
 	if (__EMIT_MARKER) {
 		OUT_WFI5(ring);
 		OUT_PKT4(ring, reg, 1);
-		OUT_RING(ring, ++marker_cnt);
+		OUT_RING(ring, p_atomic_inc_return(&marker_cnt));
 	}
 }
 
diff --git a/src/gallium/drivers/freedreno/freedreno_util.c b/src/gallium/drivers/freedreno/freedreno_util.c
index bf1e05ba740..f5bc5024861 100644
--- a/src/gallium/drivers/freedreno/freedreno_util.c
+++ b/src/gallium/drivers/freedreno/freedreno_util.c
@@ -29,7 +29,7 @@
 
 #include "freedreno_util.h"
 
-unsigned marker_cnt;
+int32_t marker_cnt;
 
 enum adreno_rb_depth_format
 fd_pipe2depth(enum pipe_format format)
diff --git a/src/gallium/drivers/freedreno/freedreno_util.h b/src/gallium/drivers/freedreno/freedreno_util.h
index 0407ce00efe..0ae200b1968 100644
--- a/src/gallium/drivers/freedreno/freedreno_util.h
+++ b/src/gallium/drivers/freedreno/freedreno_util.h
@@ -272,16 +272,25 @@ __OUT_IB5(struct fd_ringbuffer *ring, struct fd_ringbuffer *target)
 // rework..
 #define HW_QUERY_BASE_REG REG_AXXX_CP_SCRATCH_REG4
 
+#ifdef DEBUG
+#  define __EMIT_MARKER 1
+#else
+#  define __EMIT_MARKER 0
+#endif
+
 static inline void
 emit_marker(struct fd_ringbuffer *ring, int scratch_idx)
 {
-	extern unsigned marker_cnt;
+	extern int32_t marker_cnt;
 	unsigned reg = REG_AXXX_CP_SCRATCH_REG0 + scratch_idx;
 	assert(reg != HW_QUERY_BASE_REG);
 	if (reg == HW_QUERY_BASE_REG)
 		return;
-	OUT_PKT0(ring, reg, 1);
-	OUT_RING(ring, ++marker_cnt);
+	if (__EMIT_MARKER) {
+		OUT_WFI5(ring);
+		OUT_PKT0(ring, reg, 1);
+		OUT_RING(ring, p_atomic_inc_return(&marker_cnt));
+	}
 }
 
 static inline uint32_t



More information about the mesa-commit mailing list