mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 00:49:04 +02:00
r600g,radeonsi: add driver queries for GPU temperature and shader+memory clocks
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
9143940da2
commit
0b8e73a6ae
5 changed files with 58 additions and 3 deletions
|
|
@ -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];
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,13 @@
|
|||
#define RADEON_INFO_ACTIVE_CU_COUNT 0x20
|
||||
#endif
|
||||
|
||||
#ifndef RADEON_INFO_CURRENT_GPU_TEMP
|
||||
#define RADEON_INFO_CURRENT_GPU_TEMP 0x21
|
||||
#define RADEON_INFO_CURRENT_GPU_SCLK 0x22
|
||||
#define RADEON_INFO_CURRENT_GPU_MCLK 0x23
|
||||
#define RADEON_INFO_READ_REG 0x24
|
||||
#endif
|
||||
|
||||
static struct util_hash_table *fd_tab = NULL;
|
||||
pipe_static_mutex(fd_tab_mutex);
|
||||
|
||||
|
|
@ -559,6 +566,18 @@ static uint64_t radeon_query_value(struct radeon_winsys *rws,
|
|||
radeon_get_drm_value(ws->fd, RADEON_INFO_GTT_USAGE,
|
||||
"gtt-usage", (uint32_t*)&retval);
|
||||
return retval;
|
||||
case RADEON_GPU_TEMPERATURE:
|
||||
radeon_get_drm_value(ws->fd, RADEON_INFO_CURRENT_GPU_TEMP,
|
||||
"gpu-temp", (uint32_t*)&retval);
|
||||
return retval;
|
||||
case RADEON_CURRENT_SCLK:
|
||||
radeon_get_drm_value(ws->fd, RADEON_INFO_CURRENT_GPU_SCLK,
|
||||
"current-gpu-sclk", (uint32_t*)&retval);
|
||||
return retval;
|
||||
case RADEON_CURRENT_MCLK:
|
||||
radeon_get_drm_value(ws->fd, RADEON_INFO_CURRENT_GPU_MCLK,
|
||||
"current-gpu-mclk", (uint32_t*)&retval);
|
||||
return retval;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -169,7 +169,10 @@ enum radeon_value_id {
|
|||
RADEON_NUM_CS_FLUSHES,
|
||||
RADEON_NUM_BYTES_MOVED,
|
||||
RADEON_VRAM_USAGE,
|
||||
RADEON_GTT_USAGE
|
||||
RADEON_GTT_USAGE,
|
||||
RADEON_GPU_TEMPERATURE,
|
||||
RADEON_CURRENT_SCLK,
|
||||
RADEON_CURRENT_MCLK
|
||||
};
|
||||
|
||||
enum radeon_bo_priority {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue