gallium/radeon: add HUD queries for monitoring some hw blocks
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 20 Jan 2017 18:21:12 +0000 (19:21 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 23 Jan 2017 20:19:49 +0000 (21:19 +0100)
It's also possible to monitor them via performance counters but
the hardware can only use two counters simultaneously. It seems
easier to re-use the existing code which reads from MMIO instead
of writing a multi-pass approach.

v2: - add new lines after ':'

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/drivers/radeon/r600_gpu_load.c
src/gallium/drivers/radeon/r600_pipe_common.h
src/gallium/drivers/radeon/r600_query.c
src/gallium/drivers/radeon/r600_query.h

index 62f5d03..775ac7a 100644 (file)
 #define SAMPLES_PER_SEC 10000
 
 #define GRBM_STATUS            0x8010
+#define TA_BUSY(x)             (((x) >> 14) & 0x1)
+#define GDS_BUSY(x)            (((x) >> 15) & 0x1)
+#define VGT_BUSY(x)            (((x) >> 17) & 0x1)
+#define IA_BUSY(x)             (((x) >> 19) & 0x1)
+#define SX_BUSY(x)             (((x) >> 20) & 0x1)
+#define WD_BUSY(x)             (((x) >> 21) & 0x1)
 #define SPI_BUSY(x)            (((x) >> 22) & 0x1)
+#define BCI_BUSY(x)            (((x) >> 23) & 0x1)
+#define SC_BUSY(x)             (((x) >> 24) & 0x1)
+#define PA_BUSY(x)             (((x) >> 25) & 0x1)
+#define DB_BUSY(x)             (((x) >> 26) & 0x1)
+#define CP_BUSY(x)             (((x) >> 29) & 0x1)
+#define CB_BUSY(x)             (((x) >> 30) & 0x1)
 #define GUI_ACTIVE(x)          (((x) >> 31) & 0x1)
 
 #define UPDATE_COUNTER(field, mask)                            \
@@ -59,7 +71,19 @@ static void r600_update_grbm_counters(struct r600_common_screen *rscreen,
 
        rscreen->ws->read_registers(rscreen->ws, GRBM_STATUS, 1, &value);
 
+       UPDATE_COUNTER(ta, TA_BUSY);
+       UPDATE_COUNTER(gds, GDS_BUSY);
+       UPDATE_COUNTER(vgt, VGT_BUSY);
+       UPDATE_COUNTER(ia, IA_BUSY);
+       UPDATE_COUNTER(sx, SX_BUSY);
+       UPDATE_COUNTER(wd, WD_BUSY);
        UPDATE_COUNTER(spi, SPI_BUSY);
+       UPDATE_COUNTER(bci, BCI_BUSY);
+       UPDATE_COUNTER(sc, SC_BUSY);
+       UPDATE_COUNTER(pa, PA_BUSY);
+       UPDATE_COUNTER(db, DB_BUSY);
+       UPDATE_COUNTER(cp, CP_BUSY);
+       UPDATE_COUNTER(cb, CB_BUSY);
        UPDATE_COUNTER(gui, GUI_ACTIVE);
 }
 
@@ -158,6 +182,30 @@ static unsigned busy_index_from_type(struct r600_common_screen *rscreen,
                return BUSY_INDEX(rscreen, gui);
        case R600_QUERY_GPU_SHADERS_BUSY:
                return BUSY_INDEX(rscreen, spi);
+       case R600_QUERY_GPU_TA_BUSY:
+               return BUSY_INDEX(rscreen, ta);
+       case R600_QUERY_GPU_GDS_BUSY:
+               return BUSY_INDEX(rscreen, gds);
+       case R600_QUERY_GPU_VGT_BUSY:
+               return BUSY_INDEX(rscreen, vgt);
+       case R600_QUERY_GPU_IA_BUSY:
+               return BUSY_INDEX(rscreen, ia);
+       case R600_QUERY_GPU_SX_BUSY:
+               return BUSY_INDEX(rscreen, sx);
+       case R600_QUERY_GPU_WD_BUSY:
+               return BUSY_INDEX(rscreen, wd);
+       case R600_QUERY_GPU_BCI_BUSY:
+               return BUSY_INDEX(rscreen, bci);
+       case R600_QUERY_GPU_SC_BUSY:
+               return BUSY_INDEX(rscreen, sc);
+       case R600_QUERY_GPU_PA_BUSY:
+               return BUSY_INDEX(rscreen, pa);
+       case R600_QUERY_GPU_DB_BUSY:
+               return BUSY_INDEX(rscreen, db);
+       case R600_QUERY_GPU_CP_BUSY:
+               return BUSY_INDEX(rscreen, cp);
+       case R600_QUERY_GPU_CB_BUSY:
+               return BUSY_INDEX(rscreen, cb);
        default:
                unreachable("query type does not correspond to grbm id");
        }
index e340e6f..afb1385 100644 (file)
@@ -361,6 +361,18 @@ union r600_grbm_counters {
        struct {
                struct r600_grbm_counter spi;
                struct r600_grbm_counter gui;
+               struct r600_grbm_counter ta;
+               struct r600_grbm_counter gds;
+               struct r600_grbm_counter vgt;
+               struct r600_grbm_counter ia;
+               struct r600_grbm_counter sx;
+               struct r600_grbm_counter wd;
+               struct r600_grbm_counter bci;
+               struct r600_grbm_counter sc;
+               struct r600_grbm_counter pa;
+               struct r600_grbm_counter db;
+               struct r600_grbm_counter cp;
+               struct r600_grbm_counter cb;
        } named;
        unsigned array[0];
 };
index 1f9f191..25e7f5b 100644 (file)
@@ -146,6 +146,18 @@ static bool r600_query_sw_begin(struct r600_common_context *rctx,
        }
        case R600_QUERY_GPU_LOAD:
        case R600_QUERY_GPU_SHADERS_BUSY:
+       case R600_QUERY_GPU_TA_BUSY:
+       case R600_QUERY_GPU_GDS_BUSY:
+       case R600_QUERY_GPU_VGT_BUSY:
+       case R600_QUERY_GPU_IA_BUSY:
+       case R600_QUERY_GPU_SX_BUSY:
+       case R600_QUERY_GPU_WD_BUSY:
+       case R600_QUERY_GPU_BCI_BUSY:
+       case R600_QUERY_GPU_SC_BUSY:
+       case R600_QUERY_GPU_PA_BUSY:
+       case R600_QUERY_GPU_DB_BUSY:
+       case R600_QUERY_GPU_CP_BUSY:
+       case R600_QUERY_GPU_CB_BUSY:
                query->begin_result = r600_begin_counter(rctx->screen,
                                                         query->b.type);
                break;
@@ -239,6 +251,18 @@ static bool r600_query_sw_end(struct r600_common_context *rctx,
        }
        case R600_QUERY_GPU_LOAD:
        case R600_QUERY_GPU_SHADERS_BUSY:
+       case R600_QUERY_GPU_TA_BUSY:
+       case R600_QUERY_GPU_GDS_BUSY:
+       case R600_QUERY_GPU_VGT_BUSY:
+       case R600_QUERY_GPU_IA_BUSY:
+       case R600_QUERY_GPU_SX_BUSY:
+       case R600_QUERY_GPU_WD_BUSY:
+       case R600_QUERY_GPU_BCI_BUSY:
+       case R600_QUERY_GPU_SC_BUSY:
+       case R600_QUERY_GPU_PA_BUSY:
+       case R600_QUERY_GPU_DB_BUSY:
+       case R600_QUERY_GPU_CP_BUSY:
+       case R600_QUERY_GPU_CB_BUSY:
                query->end_result = r600_end_counter(rctx->screen,
                                                     query->b.type,
                                                     query->begin_result);
@@ -1721,6 +1745,19 @@ static struct pipe_driver_query_info r600_driver_query_list[] = {
         * availability is adjusted dynamically based on the DRM version. */
        X("GPU-load",                   GPU_LOAD,               UINT64, AVERAGE),
        X("GPU-shaders-busy",           GPU_SHADERS_BUSY,       UINT64, AVERAGE),
+       X("GPU-ta-busy",                GPU_TA_BUSY,            UINT64, AVERAGE),
+       X("GPU-gds-busy",               GPU_GDS_BUSY,           UINT64, AVERAGE),
+       X("GPU-vgt-busy",               GPU_VGT_BUSY,           UINT64, AVERAGE),
+       X("GPU-ia-busy",                GPU_IA_BUSY,            UINT64, AVERAGE),
+       X("GPU-sx-busy",                GPU_SX_BUSY,            UINT64, AVERAGE),
+       X("GPU-wd-busy",                GPU_WD_BUSY,            UINT64, AVERAGE),
+       X("GPU-bci-busy",               GPU_BCI_BUSY,           UINT64, AVERAGE),
+       X("GPU-sc-busy",                GPU_SC_BUSY,            UINT64, AVERAGE),
+       X("GPU-pa-busy",                GPU_PA_BUSY,            UINT64, AVERAGE),
+       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("temperature",                GPU_TEMPERATURE,        UINT64, AVERAGE),
        X("shader-clock",               CURRENT_GPU_SCLK,       HZ, AVERAGE),
        X("memory-clock",               CURRENT_GPU_MCLK,       HZ, AVERAGE),
@@ -1737,7 +1774,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) - 5;
+               return ARRAY_SIZE(r600_driver_query_list) - 17;
 }
 
 static int r600_get_driver_query_info(struct pipe_screen *screen,
index 43bca2b..1e4554d 100644 (file)
@@ -71,6 +71,18 @@ enum {
        R600_QUERY_CURRENT_GPU_MCLK,
        R600_QUERY_GPU_LOAD,
        R600_QUERY_GPU_SHADERS_BUSY,
+       R600_QUERY_GPU_TA_BUSY,
+       R600_QUERY_GPU_GDS_BUSY,
+       R600_QUERY_GPU_VGT_BUSY,
+       R600_QUERY_GPU_IA_BUSY,
+       R600_QUERY_GPU_SX_BUSY,
+       R600_QUERY_GPU_WD_BUSY,
+       R600_QUERY_GPU_BCI_BUSY,
+       R600_QUERY_GPU_SC_BUSY,
+       R600_QUERY_GPU_PA_BUSY,
+       R600_QUERY_GPU_DB_BUSY,
+       R600_QUERY_GPU_CP_BUSY,
+       R600_QUERY_GPU_CB_BUSY,
        R600_QUERY_NUM_COMPILATIONS,
        R600_QUERY_NUM_SHADERS_CREATED,
        R600_QUERY_BACK_BUFFER_PS_DRAW_RATIO,