From 0b8e73a6ae2a77d0e9a7810cca5b181ba5f0893e Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Tue, 24 Feb 2015 00:50:20 +0100 Subject: r600g,radeonsi: add driver queries for GPU temperature and shader+memory clocks Reviewed-by: Alex Deucher --- src/gallium/drivers/radeon/r600_pipe_common.c | 13 +++++++++++-- src/gallium/drivers/radeon/r600_pipe_common.h | 3 +++ src/gallium/drivers/radeon/r600_query.c | 21 +++++++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) (limited to 'src/gallium/drivers') diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c b/src/gallium/drivers/radeon/r600_pipe_common.c index c6d79181d19..97eed136331 100644 --- a/src/gallium/drivers/radeon/r600_pipe_common.c +++ b/src/gallium/drivers/radeon/r600_pipe_common.c @@ -665,12 +665,21 @@ static int r600_get_driver_query_info(struct pipe_screen *screen, {"num-bytes-moved", R600_QUERY_NUM_BYTES_MOVED, 0, TRUE}, {"VRAM-usage", R600_QUERY_VRAM_USAGE, rscreen->info.vram_size, TRUE}, {"GTT-usage", R600_QUERY_GTT_USAGE, rscreen->info.gart_size, TRUE}, + {"temperature", R600_QUERY_GPU_TEMPERATURE, 100, FALSE}, + {"shader-clock", R600_QUERY_CURRENT_GPU_SCLK, 0, FALSE}, + {"memory-clock", R600_QUERY_CURRENT_GPU_MCLK, 0, FALSE} }; + unsigned num_queries; + + if (rscreen->info.drm_major == 2 && rscreen->info.drm_minor >= 42) + num_queries = Elements(list); + else + num_queries = 8; if (!info) - return Elements(list); + return num_queries; - if (index >= Elements(list)) + if (index >= num_queries) return 0; *info = list[index]; diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h b/src/gallium/drivers/radeon/r600_pipe_common.h index 384a9a6a200..c23072c49de 100644 --- a/src/gallium/drivers/radeon/r600_pipe_common.h +++ b/src/gallium/drivers/radeon/r600_pipe_common.h @@ -55,6 +55,9 @@ #define R600_QUERY_NUM_BYTES_MOVED (PIPE_QUERY_DRIVER_SPECIFIC + 5) #define R600_QUERY_VRAM_USAGE (PIPE_QUERY_DRIVER_SPECIFIC + 6) #define R600_QUERY_GTT_USAGE (PIPE_QUERY_DRIVER_SPECIFIC + 7) +#define R600_QUERY_GPU_TEMPERATURE (PIPE_QUERY_DRIVER_SPECIFIC + 8) +#define R600_QUERY_CURRENT_GPU_SCLK (PIPE_QUERY_DRIVER_SPECIFIC + 9) +#define R600_QUERY_CURRENT_GPU_MCLK (PIPE_QUERY_DRIVER_SPECIFIC + 10) #define R600_CONTEXT_STREAMOUT_FLUSH (1u << 0) #define R600_CONTEXT_PRIVATE_FLAG (1u << 1) diff --git a/src/gallium/drivers/radeon/r600_query.c b/src/gallium/drivers/radeon/r600_query.c index 6a35ab8190a..758064af712 100644 --- a/src/gallium/drivers/radeon/r600_query.c +++ b/src/gallium/drivers/radeon/r600_query.c @@ -86,6 +86,9 @@ static struct r600_resource *r600_new_query_buffer(struct r600_common_context *c case R600_QUERY_NUM_BYTES_MOVED: case R600_QUERY_VRAM_USAGE: case R600_QUERY_GTT_USAGE: + case R600_QUERY_GPU_TEMPERATURE: + case R600_QUERY_CURRENT_GPU_SCLK: + case R600_QUERY_CURRENT_GPU_MCLK: return NULL; } @@ -382,6 +385,9 @@ static struct pipe_query *r600_create_query(struct pipe_context *ctx, unsigned q case R600_QUERY_NUM_BYTES_MOVED: case R600_QUERY_VRAM_USAGE: case R600_QUERY_GTT_USAGE: + case R600_QUERY_GPU_TEMPERATURE: + case R600_QUERY_CURRENT_GPU_SCLK: + case R600_QUERY_CURRENT_GPU_MCLK: skip_allocation = true; break; default: @@ -439,6 +445,9 @@ static void r600_begin_query(struct pipe_context *ctx, struct pipe_query *query) case R600_QUERY_REQUESTED_GTT: case R600_QUERY_VRAM_USAGE: case R600_QUERY_GTT_USAGE: + case R600_QUERY_GPU_TEMPERATURE: + case R600_QUERY_CURRENT_GPU_SCLK: + case R600_QUERY_CURRENT_GPU_MCLK: rquery->begin_result = 0; return; case R600_QUERY_BUFFER_WAIT_TIME: @@ -513,6 +522,15 @@ static void r600_end_query(struct pipe_context *ctx, struct pipe_query *query) case R600_QUERY_GTT_USAGE: rquery->end_result = rctx->ws->query_value(rctx->ws, RADEON_GTT_USAGE); return; + case R600_QUERY_GPU_TEMPERATURE: + rquery->end_result = rctx->ws->query_value(rctx->ws, RADEON_GPU_TEMPERATURE) / 1000; + return; + case R600_QUERY_CURRENT_GPU_SCLK: + rquery->end_result = rctx->ws->query_value(rctx->ws, RADEON_CURRENT_SCLK) * 1000000; + return; + case R600_QUERY_CURRENT_GPU_MCLK: + rquery->end_result = rctx->ws->query_value(rctx->ws, RADEON_CURRENT_MCLK) * 1000000; + return; } r600_emit_query_end(rctx, rquery); @@ -570,6 +588,9 @@ static boolean r600_get_query_buffer_result(struct r600_common_context *ctx, case R600_QUERY_NUM_BYTES_MOVED: case R600_QUERY_VRAM_USAGE: case R600_QUERY_GTT_USAGE: + case R600_QUERY_GPU_TEMPERATURE: + case R600_QUERY_CURRENT_GPU_SCLK: + case R600_QUERY_CURRENT_GPU_MCLK: result->u64 = query->end_result - query->begin_result; return TRUE; } -- cgit v1.2.3