gallium/radeon: add a driver query for AMDGPU_INFO_NUM_EVICTIONS
authorMarek Olšák <marek.olsak@amd.com>
Wed, 17 Aug 2016 23:18:14 +0000 (01:18 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 26 Aug 2016 13:50:10 +0000 (15:50 +0200)
If the kernel driver doesn't support it, it returns 0.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/gallium/drivers/radeon/r600_query.c
src/gallium/drivers/radeon/r600_query.h
src/gallium/drivers/radeon/radeon_winsys.h
src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
src/gallium/winsys/radeon/drm/radeon_drm_winsys.c

index 5825e8b7add857c8396820ffbac0e85ca0ce6764..bd0a90669385a28d44ce34df66914c368be80a64 100644 (file)
@@ -56,6 +56,7 @@ static enum radeon_value_id winsys_id_from_type(unsigned type)
        case R600_QUERY_BUFFER_WAIT_TIME: return RADEON_BUFFER_WAIT_TIME_NS;
        case R600_QUERY_NUM_CS_FLUSHES: return RADEON_NUM_CS_FLUSHES;
        case R600_QUERY_NUM_BYTES_MOVED: return RADEON_NUM_BYTES_MOVED;
+       case R600_QUERY_NUM_EVICTIONS: return RADEON_NUM_EVICTIONS;
        case R600_QUERY_VRAM_USAGE: return RADEON_VRAM_USAGE;
        case R600_QUERY_GTT_USAGE: return RADEON_GTT_USAGE;
        case R600_QUERY_GPU_TEMPERATURE: return RADEON_GPU_TEMPERATURE;
@@ -103,7 +104,8 @@ static bool r600_query_sw_begin(struct r600_common_context *rctx,
                break;
        case R600_QUERY_BUFFER_WAIT_TIME:
        case R600_QUERY_NUM_CS_FLUSHES:
-       case R600_QUERY_NUM_BYTES_MOVED: {
+       case R600_QUERY_NUM_BYTES_MOVED:
+       case R600_QUERY_NUM_EVICTIONS: {
                enum radeon_value_id ws_id = winsys_id_from_type(query->b.type);
                query->begin_result = rctx->ws->query_value(rctx->ws, ws_id);
                break;
@@ -167,7 +169,8 @@ static bool r600_query_sw_end(struct r600_common_context *rctx,
        case R600_QUERY_CURRENT_GPU_MCLK:
        case R600_QUERY_BUFFER_WAIT_TIME:
        case R600_QUERY_NUM_CS_FLUSHES:
-       case R600_QUERY_NUM_BYTES_MOVED: {
+       case R600_QUERY_NUM_BYTES_MOVED:
+       case R600_QUERY_NUM_EVICTIONS: {
                enum radeon_value_id ws_id = winsys_id_from_type(query->b.type);
                query->end_result = rctx->ws->query_value(rctx->ws, ws_id);
                break;
@@ -1186,6 +1189,7 @@ static struct pipe_driver_query_info r600_driver_query_list[] = {
        X("buffer-wait-time",           BUFFER_WAIT_TIME,       MICROSECONDS, CUMULATIVE),
        X("num-cs-flushes",             NUM_CS_FLUSHES,         UINT64, AVERAGE),
        X("num-bytes-moved",            NUM_BYTES_MOVED,        BYTES, CUMULATIVE),
+       X("num-evictions",              NUM_EVICTIONS,          UINT64, CUMULATIVE),
        X("VRAM-usage",                 VRAM_USAGE,             BYTES, AVERAGE),
        X("GTT-usage",                  GTT_USAGE,              BYTES, AVERAGE),
        X("back-buffer-ps-draw-ratio",  BACK_BUFFER_PS_DRAW_RATIO, UINT64, AVERAGE),
index 7aa684c4dade80fe85ab23c62411fe73c0064d57..0bb7cddabde62f454cd5376e595c9422c855b538 100644 (file)
@@ -53,6 +53,7 @@ enum {
        R600_QUERY_BUFFER_WAIT_TIME,
        R600_QUERY_NUM_CS_FLUSHES,
        R600_QUERY_NUM_BYTES_MOVED,
+       R600_QUERY_NUM_EVICTIONS,
        R600_QUERY_VRAM_USAGE,
        R600_QUERY_GTT_USAGE,
        R600_QUERY_GPU_TEMPERATURE,
index f4e37733e2f19154824e355d6fddffa5b18fe4a7..741dc99f51b50a06fbe18be50fcb2ac4cdcd2790 100644 (file)
@@ -160,6 +160,7 @@ enum radeon_value_id {
     RADEON_TIMESTAMP,
     RADEON_NUM_CS_FLUSHES,
     RADEON_NUM_BYTES_MOVED,
+    RADEON_NUM_EVICTIONS,
     RADEON_VRAM_USAGE,
     RADEON_GTT_USAGE,
     RADEON_GPU_TEMPERATURE, /* DRM 2.42.0 */
index 95567776bee33718bf40b8c58308d652c7908064..d8aed8bb31d9e981ee12a5435351eb53372a47e0 100644 (file)
 #define     CIK__PIPE_CONFIG__ADDR_SURF_P16_32X32_8X16   16
 #define     CIK__PIPE_CONFIG__ADDR_SURF_P16_32X32_16X16  17
 
+#ifndef AMDGPU_INFO_NUM_EVICTIONS
+#define AMDGPU_INFO_NUM_EVICTIONS              0x18
+#endif
+
 static struct util_hash_table *dev_tab = NULL;
 pipe_static_mutex(dev_tab_mutex);
 
@@ -393,6 +397,9 @@ static uint64_t amdgpu_query_value(struct radeon_winsys *rws,
    case RADEON_NUM_BYTES_MOVED:
       amdgpu_query_info(ws->dev, AMDGPU_INFO_NUM_BYTES_MOVED, 8, &retval);
       return retval;
+   case RADEON_NUM_EVICTIONS:
+      amdgpu_query_info(ws->dev, AMDGPU_INFO_NUM_EVICTIONS, 8, &retval);
+      return retval;
    case RADEON_VRAM_USAGE:
       amdgpu_query_heap_info(ws->dev, AMDGPU_GEM_DOMAIN_VRAM, 0, &heap);
       return heap.heap_usage;
index b1cc3d50fd8e36ba9c9a2df51f06d461d74e47cc..d73b7f44ed90af1404de0138be63953aed2875a8 100644 (file)
@@ -624,6 +624,8 @@ static uint64_t radeon_query_value(struct radeon_winsys *rws,
         radeon_get_drm_value(ws->fd, RADEON_INFO_NUM_BYTES_MOVED,
                              "num-bytes-moved", (uint32_t*)&retval);
         return retval;
+    case RADEON_NUM_EVICTIONS:
+        return 0; /* unimplemented */
     case RADEON_VRAM_USAGE:
         radeon_get_drm_value(ws->fd, RADEON_INFO_VRAM_USAGE,
                              "vram-usage", (uint32_t*)&retval);