radeonsi: inhibit clockgating when using SQTT
authorPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Wed, 13 Jan 2021 20:20:42 +0000 (21:20 +0100)
committerPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Tue, 19 Jan 2021 08:52:08 +0000 (09:52 +0100)
Ported from PAL.

Fixes: 07c1504d1b0 ("radeonsi: implement SQTT support")
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8480>

src/gallium/drivers/radeonsi/si_perfcounter.c
src/gallium/drivers/radeonsi/si_pipe.h
src/gallium/drivers/radeonsi/si_sqtt.c

index f28a51f..6363368 100644 (file)
@@ -919,14 +919,14 @@ static void si_pc_query_destroy(struct si_context *sctx, struct si_query *squery
    FREE(query);
 }
 
-static void si_inhibit_clockgating(struct si_context *sctx, bool inhibit)
+void si_inhibit_clockgating(struct si_context *sctx, struct radeon_cmdbuf *cs, bool inhibit)
 {
    if (sctx->chip_class >= GFX10) {
-      radeon_set_uconfig_reg(&sctx->gfx_cs, R_037390_RLC_PERFMON_CLK_CNTL,
-                            S_037390_PERFMON_CLOCK_STATE(inhibit));
+      radeon_set_uconfig_reg(cs, R_037390_RLC_PERFMON_CLK_CNTL,
+                             S_037390_PERFMON_CLOCK_STATE(inhibit));
    } else if (sctx->chip_class >= GFX8) {
-      radeon_set_uconfig_reg(&sctx->gfx_cs, R_0372FC_RLC_PERFMON_CLK_CNTL,
-                            S_0372FC_PERFMON_CLOCK_STATE(inhibit));
+      radeon_set_uconfig_reg(cs, R_0372FC_RLC_PERFMON_CLK_CNTL,
+                             S_0372FC_PERFMON_CLOCK_STATE(inhibit));
    }
 }
 
@@ -946,7 +946,7 @@ static void si_pc_query_resume(struct si_context *sctx, struct si_query *squery)
    if (query->shaders)
       si_pc_emit_shaders(sctx, query->shaders);
 
-   si_inhibit_clockgating(sctx, true);
+   si_inhibit_clockgating(sctx, &sctx->gfx_cs, true);
 
    for (struct si_query_group *group = query->groups; group; group = group->next) {
       struct si_pc_block *block = group->block;
@@ -1000,7 +1000,7 @@ static void si_pc_query_suspend(struct si_context *sctx, struct si_query *squery
 
    si_pc_emit_instance(sctx, -1, -1);
 
-   si_inhibit_clockgating(sctx, false);
+   si_inhibit_clockgating(sctx, &sctx->gfx_cs, false);
 }
 
 static bool si_pc_query_begin(struct si_context *ctx, struct si_query *squery)
index 71b85f4..055e4cf 100644 (file)
@@ -1492,6 +1492,7 @@ void si_init_compiler(struct si_screen *sscreen, struct ac_llvm_compiler *compil
 /* si_perfcounters.c */
 void si_init_perfcounters(struct si_screen *screen);
 void si_destroy_perfcounters(struct si_screen *screen);
+void si_inhibit_clockgating(struct si_context *sctx, struct radeon_cmdbuf *cs, bool inhibit);
 
 /* si_query.c */
 void si_init_screen_query_functions(struct si_screen *sscreen);
index 9bd1483..1366430 100644 (file)
@@ -378,6 +378,8 @@ si_thread_trace_start(struct si_context *sctx, int family, struct radeon_cmdbuf
       SI_CONTEXT_INV_L2;
    sctx->emit_cache_flush(sctx, cs);
 
+   si_inhibit_clockgating(sctx, cs, true);
+
    /* Enable SQG events that collects thread trace data. */
    si_emit_spi_config_cntl(sctx, cs, true);
 
@@ -418,6 +420,8 @@ si_thread_trace_stop(struct si_context *sctx, int family, struct radeon_cmdbuf *
 
    /* Restore previous state by disabling SQG events. */
    si_emit_spi_config_cntl(sctx, cs, false);
+
+   si_inhibit_clockgating(sctx, cs, false);
 }