From 0e04a078c5545d536173e50e32a0604b9abb42bc Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Mon, 30 Jan 2017 12:52:24 +0100 Subject: [PATCH] gallium/radeon: add new GPU-sdma-busy HUD query MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit For simplicity, GPU-sdma-busy will return 0 on previous gens. v2: only read SRBM_STATUS2 on Evergreen+ Signed-off-by: Samuel Pitoiset Reviewed-by: Marek Olšák --- src/gallium/drivers/radeon/r600_gpu_load.c | 13 +++++++++++++ src/gallium/drivers/radeon/r600_pipe_common.h | 3 +++ src/gallium/drivers/radeon/r600_query.c | 5 ++++- src/gallium/drivers/radeon/r600_query.h | 1 + 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/radeon/r600_gpu_load.c b/src/gallium/drivers/radeon/r600_gpu_load.c index c84b86d76cf..058006b8261 100644 --- a/src/gallium/drivers/radeon/r600_gpu_load.c +++ b/src/gallium/drivers/radeon/r600_gpu_load.c @@ -58,6 +58,9 @@ #define CB_BUSY(x) (((x) >> 30) & 0x1) #define GUI_ACTIVE(x) (((x) >> 31) & 0x1) +#define SRBM_STATUS2 0x0e4c +#define SDMA_BUSY(x) (((x) >> 5) & 0x1) + #define UPDATE_COUNTER(field, mask) \ do { \ if (mask(value)) \ @@ -71,6 +74,7 @@ static void r600_update_mmio_counters(struct r600_common_screen *rscreen, { uint32_t value = 0; + /* GRBM_STATUS */ rscreen->ws->read_registers(rscreen->ws, GRBM_STATUS, 1, &value); UPDATE_COUNTER(ta, TA_BUSY); @@ -87,6 +91,13 @@ static void r600_update_mmio_counters(struct r600_common_screen *rscreen, UPDATE_COUNTER(cp, CP_BUSY); UPDATE_COUNTER(cb, CB_BUSY); UPDATE_COUNTER(gui, GUI_ACTIVE); + + if (rscreen->chip_class >= EVERGREEN) { + /* SRBM_STATUS2 */ + rscreen->ws->read_registers(rscreen->ws, SRBM_STATUS2, 1, &value); + + UPDATE_COUNTER(sdma, SDMA_BUSY); + } } #undef UPDATE_COUNTER @@ -210,6 +221,8 @@ static unsigned busy_index_from_type(struct r600_common_screen *rscreen, return BUSY_INDEX(rscreen, cp); case R600_QUERY_GPU_CB_BUSY: return BUSY_INDEX(rscreen, cb); + case R600_QUERY_GPU_SDMA_BUSY: + return BUSY_INDEX(rscreen, sdma); default: unreachable("invalid query type"); } diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h b/src/gallium/drivers/radeon/r600_pipe_common.h index b9608e05f78..9118b6bcf84 100644 --- a/src/gallium/drivers/radeon/r600_pipe_common.h +++ b/src/gallium/drivers/radeon/r600_pipe_common.h @@ -374,6 +374,9 @@ union r600_mmio_counters { struct r600_mmio_counter db; struct r600_mmio_counter cp; struct r600_mmio_counter cb; + + /* SRBM_STATUS2 */ + struct r600_mmio_counter sdma; } named; unsigned array[0]; }; diff --git a/src/gallium/drivers/radeon/r600_query.c b/src/gallium/drivers/radeon/r600_query.c index 4b9a155dad2..1747026d0dc 100644 --- a/src/gallium/drivers/radeon/r600_query.c +++ b/src/gallium/drivers/radeon/r600_query.c @@ -162,6 +162,7 @@ static bool r600_query_sw_begin(struct r600_common_context *rctx, case R600_QUERY_GPU_DB_BUSY: case R600_QUERY_GPU_CP_BUSY: case R600_QUERY_GPU_CB_BUSY: + case R600_QUERY_GPU_SDMA_BUSY: query->begin_result = r600_begin_counter(rctx->screen, query->b.type); break; @@ -269,6 +270,7 @@ static bool r600_query_sw_end(struct r600_common_context *rctx, case R600_QUERY_GPU_DB_BUSY: case R600_QUERY_GPU_CP_BUSY: case R600_QUERY_GPU_CB_BUSY: + case R600_QUERY_GPU_SDMA_BUSY: query->end_result = r600_end_counter(rctx->screen, query->b.type, query->begin_result); @@ -1768,6 +1770,7 @@ static struct pipe_driver_query_info r600_driver_query_list[] = { X("GPU-db-busy", GPU_DB_BUSY, UINT64, AVERAGE), X("GPU-cp-busy", GPU_CP_BUSY, UINT64, AVERAGE), X("GPU-cb-busy", GPU_CB_BUSY, UINT64, AVERAGE), + X("GPU-sdma-busy", GPU_SDMA_BUSY, UINT64, AVERAGE), X("temperature", GPU_TEMPERATURE, UINT64, AVERAGE), X("shader-clock", CURRENT_GPU_SCLK, HZ, AVERAGE), @@ -1785,7 +1788,7 @@ static unsigned r600_get_num_queries(struct r600_common_screen *rscreen) else if (rscreen->info.drm_major == 3) return ARRAY_SIZE(r600_driver_query_list) - 3; else - return ARRAY_SIZE(r600_driver_query_list) - 17; + return ARRAY_SIZE(r600_driver_query_list) - 18; } static int r600_get_driver_query_info(struct pipe_screen *screen, diff --git a/src/gallium/drivers/radeon/r600_query.h b/src/gallium/drivers/radeon/r600_query.h index f2af9240d2b..0b32793c657 100644 --- a/src/gallium/drivers/radeon/r600_query.h +++ b/src/gallium/drivers/radeon/r600_query.h @@ -85,6 +85,7 @@ enum { R600_QUERY_GPU_DB_BUSY, R600_QUERY_GPU_CP_BUSY, R600_QUERY_GPU_CB_BUSY, + R600_QUERY_GPU_SDMA_BUSY, R600_QUERY_NUM_COMPILATIONS, R600_QUERY_NUM_SHADERS_CREATED, R600_QUERY_BACK_BUFFER_PS_DRAW_RATIO, -- 2.30.2