gallium/radeon: add new GPU-sdma-busy HUD query
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 30 Jan 2017 11:52:24 +0000 (12:52 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 30 Jan 2017 13:37:00 +0000 (14:37 +0100)
For simplicity, GPU-sdma-busy will return 0 on previous gens.

v2: only read SRBM_STATUS2 on Evergreen+

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 c84b86d76cf297bfe6e0092b15e14b5e130648fc..058006b8261107f4e3eca88fc33d09c761393de5 100644 (file)
@@ -58,6 +58,9 @@
 #define CB_BUSY(x)             (((x) >> 30) & 0x1)
 #define GUI_ACTIVE(x)          (((x) >> 31) & 0x1)
 
+#define SRBM_STATUS2           0x0e4c
+#define SDMA_BUSY(x)           (((x) >> 5) & 0x1)
+
 #define UPDATE_COUNTER(field, mask)                                    \
        do {                                                            \
                if (mask(value))                                        \
@@ -71,6 +74,7 @@ static void r600_update_mmio_counters(struct r600_common_screen *rscreen,
 {
        uint32_t value = 0;
 
+       /* GRBM_STATUS */
        rscreen->ws->read_registers(rscreen->ws, GRBM_STATUS, 1, &value);
 
        UPDATE_COUNTER(ta, TA_BUSY);
@@ -87,6 +91,13 @@ static void r600_update_mmio_counters(struct r600_common_screen *rscreen,
        UPDATE_COUNTER(cp, CP_BUSY);
        UPDATE_COUNTER(cb, CB_BUSY);
        UPDATE_COUNTER(gui, GUI_ACTIVE);
+
+       if (rscreen->chip_class >= EVERGREEN) {
+               /* SRBM_STATUS2 */
+               rscreen->ws->read_registers(rscreen->ws, SRBM_STATUS2, 1, &value);
+
+               UPDATE_COUNTER(sdma, SDMA_BUSY);
+       }
 }
 
 #undef UPDATE_COUNTER
@@ -210,6 +221,8 @@ static unsigned busy_index_from_type(struct r600_common_screen *rscreen,
                return BUSY_INDEX(rscreen, cp);
        case R600_QUERY_GPU_CB_BUSY:
                return BUSY_INDEX(rscreen, cb);
+       case R600_QUERY_GPU_SDMA_BUSY:
+               return BUSY_INDEX(rscreen, sdma);
        default:
                unreachable("invalid query type");
        }
index b9608e05f78d5e24c8e9e52c36c0ab193f091c1f..9118b6bcf846306ec286e07a78088e204a876e03 100644 (file)
@@ -374,6 +374,9 @@ union r600_mmio_counters {
                struct r600_mmio_counter db;
                struct r600_mmio_counter cp;
                struct r600_mmio_counter cb;
+
+               /* SRBM_STATUS2 */
+               struct r600_mmio_counter sdma;
        } named;
        unsigned array[0];
 };
index 4b9a155dad20643932908006cbb1e60e4f52fd24..1747026d0dc1492209e10a47dd201e301582fa86 100644 (file)
@@ -162,6 +162,7 @@ static bool r600_query_sw_begin(struct r600_common_context *rctx,
        case R600_QUERY_GPU_DB_BUSY:
        case R600_QUERY_GPU_CP_BUSY:
        case R600_QUERY_GPU_CB_BUSY:
+       case R600_QUERY_GPU_SDMA_BUSY:
                query->begin_result = r600_begin_counter(rctx->screen,
                                                         query->b.type);
                break;
@@ -269,6 +270,7 @@ static bool r600_query_sw_end(struct r600_common_context *rctx,
        case R600_QUERY_GPU_DB_BUSY:
        case R600_QUERY_GPU_CP_BUSY:
        case R600_QUERY_GPU_CB_BUSY:
+       case R600_QUERY_GPU_SDMA_BUSY:
                query->end_result = r600_end_counter(rctx->screen,
                                                     query->b.type,
                                                     query->begin_result);
@@ -1768,6 +1770,7 @@ static struct pipe_driver_query_info r600_driver_query_list[] = {
        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("GPU-sdma-busy",              GPU_SDMA_BUSY,          UINT64, AVERAGE),
 
        X("temperature",                GPU_TEMPERATURE,        UINT64, AVERAGE),
        X("shader-clock",               CURRENT_GPU_SCLK,       HZ, AVERAGE),
@@ -1785,7 +1788,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) - 17;
+               return ARRAY_SIZE(r600_driver_query_list) - 18;
 }
 
 static int r600_get_driver_query_info(struct pipe_screen *screen,
index f2af9240d2b8937cedb01afbdca951ec6ba8ebf5..0b32793c6573640f36bea05d0e16514c64fb57b0 100644 (file)
@@ -85,6 +85,7 @@ enum {
        R600_QUERY_GPU_DB_BUSY,
        R600_QUERY_GPU_CP_BUSY,
        R600_QUERY_GPU_CB_BUSY,
+       R600_QUERY_GPU_SDMA_BUSY,
        R600_QUERY_NUM_COMPILATIONS,
        R600_QUERY_NUM_SHADERS_CREATED,
        R600_QUERY_BACK_BUFFER_PS_DRAW_RATIO,