This avoids the need to manually change the power profile.
Reviewed-by: Mihai Preda <mhpreda@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18009>
if (sctx->gfx_level >= GFX10 && sctx->has_graphics)
gfx10_destroy_query(sctx);
- if (sctx->thread_trace)
+ if (sctx->thread_trace) {
+ struct si_screen *sscreen = sctx->screen;
+ if (sscreen->info.has_stable_pstate && sscreen->b.num_contexts == 1 &&
+ !(sctx->context_flags & SI_CONTEXT_FLAG_AUX))
+ sscreen->ws->cs_set_pstate(&sctx->gfx_cs, RADEON_CTX_PSTATE_NONE);
+
si_destroy_thread_trace(sctx);
+ }
pipe_resource_reference(&sctx->esgs_ring, NULL);
pipe_resource_reference(&sctx->gsvs_ring, NULL);
ctx = si_create_context(screen, flags);
if (ctx && sscreen->info.gfx_level >= GFX9 && sscreen->debug_flags & DBG(SQTT)) {
+ /* Auto-enable stable performance profile if possible. */
+ if (sscreen->info.has_stable_pstate && screen->num_contexts == 1 &&
+ sscreen->ws->cs_set_pstate(&((struct si_context *)ctx)->gfx_cs, RADEON_CTX_PSTATE_PEAK)) {
+ }
+
if (ac_check_profile_state(&sscreen->info)) {
fprintf(stderr, "radeonsi: Canceling RGP trace request as a hang condition has been "
"detected. Force the GPU into a profiling mode with e.g. "
RADEON_CTX_PRIORITY_REALTIME,
};
+enum radeon_ctx_pstate
+{
+ RADEON_CTX_PSTATE_NONE = 0,
+ RADEON_CTX_PSTATE_STANDARD,
+ RADEON_CTX_PSTATE_MIN_SCLK,
+ RADEON_CTX_PSTATE_MIN_MCLK,
+ RADEON_CTX_PSTATE_PEAK,
+};
+
+
/* Each group of two has the same priority. */
#define RADEON_PRIO_FENCE_TRACE (1 << 0)
#define RADEON_PRIO_SO_FILLED_SIZE (1 << 1)
* Secure context
*/
bool (*cs_is_secure)(struct radeon_cmdbuf *cs);
+
+ /**
+ * Stable pstate
+ */
+ bool (*cs_set_pstate)(struct radeon_cmdbuf *cs, enum radeon_ctx_pstate state);
};
static inline bool radeon_emitted(struct radeon_cmdbuf *cs, unsigned num_dw)
return cs->csc->secure;
}
+static uint32_t
+radeon_to_amdgpu_pstate(enum radeon_ctx_pstate pstate)
+{
+ switch (pstate) {
+ case RADEON_CTX_PSTATE_NONE:
+ return AMDGPU_CTX_STABLE_PSTATE_NONE;
+ case RADEON_CTX_PSTATE_STANDARD:
+ return AMDGPU_CTX_STABLE_PSTATE_STANDARD;
+ case RADEON_CTX_PSTATE_MIN_SCLK:
+ return AMDGPU_CTX_STABLE_PSTATE_MIN_SCLK;
+ case RADEON_CTX_PSTATE_MIN_MCLK:
+ return AMDGPU_CTX_STABLE_PSTATE_MIN_MCLK;
+ case RADEON_CTX_PSTATE_PEAK:
+ return AMDGPU_CTX_STABLE_PSTATE_PEAK;
+ default:
+ unreachable("Invalid pstate");
+ }
+}
+
+static bool
+amdgpu_cs_set_pstate(struct radeon_cmdbuf *rcs, enum radeon_ctx_pstate pstate)
+{
+ struct amdgpu_cs *cs = amdgpu_cs(rcs);
+ uint32_t amdgpu_pstate = radeon_to_amdgpu_pstate(pstate);
+ return amdgpu_cs_ctx_stable_pstate(cs->ctx->ctx,
+ AMDGPU_CTX_OP_SET_STABLE_PSTATE, amdgpu_pstate, NULL) == 0;
+}
+
PUBLIC struct radeon_winsys *
amdgpu_winsys_create(int fd, const struct pipe_screen_config *config,
radeon_screen_create_t screen_create)
ws->base.read_registers = amdgpu_read_registers;
ws->base.pin_threads_to_L3_cache = amdgpu_pin_threads_to_L3_cache;
ws->base.cs_is_secure = amdgpu_cs_is_secure;
+ ws->base.cs_set_pstate = amdgpu_cs_set_pstate;
amdgpu_bo_init_functions(ws);
amdgpu_cs_init_functions(ws);
return false;
}
+static bool radeon_cs_set_pstate(struct radeon_cmdbuf* cs, enum radeon_ctx_pstate state)
+{
+ return false;
+}
+
PUBLIC struct radeon_winsys *
radeon_drm_winsys_create(int fd, const struct pipe_screen_config *config,
radeon_screen_create_t screen_create)
ws->base.query_value = radeon_query_value;
ws->base.read_registers = radeon_read_registers;
ws->base.cs_is_secure = radeon_cs_is_secure;
+ ws->base.cs_set_pstate = radeon_cs_set_pstate;
radeon_drm_bo_init_functions(ws);
radeon_drm_cs_init_functions(ws);