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 5825e8b..bd0a906 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 7aa684c..0bb7cdd 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 f4e3773..741dc99 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 9556777..d8aed8b 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 b1cc3d5..d73b7f4 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);