[Mesa-dev] [PATCH 3/3] gallium/radeon: add new HUD queries for monitoring the CP
Alex Deucher
alexdeucher at gmail.com
Fri Jan 27 18:52:27 UTC 2017
On Fri, Jan 27, 2017 at 1:49 PM, Marek Olšák <maraeo at gmail.com> wrote:
> CP_STAT is only readable on amdgpu and only VI.
>
It can be added to other chips if anyone wants to send me a patch.
Alex
> It's OK to expose the queries on other chips if it simplies things
> even if they don't update.
>
> Marek
>
> On Thu, Jan 26, 2017 at 8:54 PM, Samuel Pitoiset
> <samuel.pitoiset at gmail.com> wrote:
>> There are even more counters in the CP_STAT register but I think
>> these ones are enough for now.
>>
>> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
>> ---
>> src/gallium/drivers/radeon/r600_gpu_load.c | 34 +++++++++++++++++++++++++++
>> src/gallium/drivers/radeon/r600_pipe_common.h | 9 +++++++
>> src/gallium/drivers/radeon/r600_query.c | 23 +++++++++++++++++-
>> src/gallium/drivers/radeon/r600_query.h | 7 ++++++
>> 4 files changed, 72 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/gallium/drivers/radeon/r600_gpu_load.c b/src/gallium/drivers/radeon/r600_gpu_load.c
>> index 5bea6e2643..588442bebd 100644
>> --- a/src/gallium/drivers/radeon/r600_gpu_load.c
>> +++ b/src/gallium/drivers/radeon/r600_gpu_load.c
>> @@ -61,6 +61,15 @@
>> #define SRBM_STATUS2 0x0e4c
>> #define SDMA_BUSY(x) (((x) >> 5) & 0x1)
>>
>> +#define CP_STAT 0x8680
>> +#define PFP_BUSY(x) (((x) >> 15) & 0x1)
>> +#define MEQ_BUSY(x) (((x) >> 16) & 0x1)
>> +#define ME_BUSY(x) (((x) >> 17) & 0x1)
>> +#define SURFACE_SYNC_BUSY(x) (((x) >> 21) & 0x1)
>> +#define DMA_BUSY(x) (((x) >> 22) & 0x1)
>> +#define SCRATCH_RAM_BUSY(x) (((x) >> 24) & 0x1)
>> +#define CE_BUSY(x) (((x) >> 26) & 0x1)
>> +
>> #define UPDATE_COUNTER(field, mask) \
>> do { \
>> if (mask(value)) \
>> @@ -96,6 +105,17 @@ static void r600_update_mmio_counters(struct r600_common_screen *rscreen,
>> rscreen->ws->read_registers(rscreen->ws, SRBM_STATUS2, 1, &value);
>>
>> UPDATE_COUNTER(sdma, SDMA_BUSY);
>> +
>> + /* CP_STAT */
>> + rscreen->ws->read_registers(rscreen->ws, CP_STAT, 1, &value);
>> +
>> + UPDATE_COUNTER(pfp, PFP_BUSY);
>> + UPDATE_COUNTER(meq, MEQ_BUSY);
>> + UPDATE_COUNTER(me, ME_BUSY);
>> + UPDATE_COUNTER(surf_sync, SURFACE_SYNC_BUSY);
>> + UPDATE_COUNTER(dma, DMA_BUSY);
>> + UPDATE_COUNTER(scratch_ram, SCRATCH_RAM_BUSY);
>> + UPDATE_COUNTER(ce, CE_BUSY);
>> }
>>
>> #undef UPDATE_COUNTER
>> @@ -221,6 +241,20 @@ static unsigned busy_index_from_type(struct r600_common_screen *rscreen,
>> return BUSY_INDEX(rscreen, cb);
>> case R600_QUERY_GPU_SDMA_BUSY:
>> return BUSY_INDEX(rscreen, sdma);
>> + case R600_QUERY_GPU_PFP_BUSY:
>> + return BUSY_INDEX(rscreen, pfp);
>> + case R600_QUERY_GPU_MEQ_BUSY:
>> + return BUSY_INDEX(rscreen, meq);
>> + case R600_QUERY_GPU_ME_BUSY:
>> + return BUSY_INDEX(rscreen, me);
>> + case R600_QUERY_GPU_SURF_SYNC_BUSY:
>> + return BUSY_INDEX(rscreen, surf_sync);
>> + case R600_QUERY_GPU_DMA_BUSY:
>> + return BUSY_INDEX(rscreen, dma);
>> + case R600_QUERY_GPU_SCRATCH_RAM_BUSY:
>> + return BUSY_INDEX(rscreen, scratch_ram);
>> + case R600_QUERY_GPU_CE_BUSY:
>> + return BUSY_INDEX(rscreen, ce);
>> default:
>> unreachable("invalid query type");
>> }
>> diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h b/src/gallium/drivers/radeon/r600_pipe_common.h
>> index 08de238bba..a1576c49a4 100644
>> --- a/src/gallium/drivers/radeon/r600_pipe_common.h
>> +++ b/src/gallium/drivers/radeon/r600_pipe_common.h
>> @@ -377,6 +377,15 @@ union r600_mmio_counters {
>>
>> /* SRBM_STATUS2 */
>> struct r600_mmio_counter sdma;
>> +
>> + /* CP_STAT */
>> + struct r600_mmio_counter pfp;
>> + struct r600_mmio_counter meq;
>> + struct r600_mmio_counter me;
>> + struct r600_mmio_counter surf_sync;
>> + struct r600_mmio_counter dma;
>> + struct r600_mmio_counter scratch_ram;
>> + struct r600_mmio_counter ce;
>> } named;
>> unsigned array[0];
>> };
>> diff --git a/src/gallium/drivers/radeon/r600_query.c b/src/gallium/drivers/radeon/r600_query.c
>> index ef73323bae..83c1c60211 100644
>> --- a/src/gallium/drivers/radeon/r600_query.c
>> +++ b/src/gallium/drivers/radeon/r600_query.c
>> @@ -163,6 +163,13 @@ static bool r600_query_sw_begin(struct r600_common_context *rctx,
>> case R600_QUERY_GPU_CP_BUSY:
>> case R600_QUERY_GPU_CB_BUSY:
>> case R600_QUERY_GPU_SDMA_BUSY:
>> + case R600_QUERY_GPU_PFP_BUSY:
>> + case R600_QUERY_GPU_MEQ_BUSY:
>> + case R600_QUERY_GPU_ME_BUSY:
>> + case R600_QUERY_GPU_SURF_SYNC_BUSY:
>> + case R600_QUERY_GPU_DMA_BUSY:
>> + case R600_QUERY_GPU_SCRATCH_RAM_BUSY:
>> + case R600_QUERY_GPU_CE_BUSY:
>> query->begin_result = r600_begin_counter(rctx->screen,
>> query->b.type);
>> break;
>> @@ -271,6 +278,13 @@ static bool r600_query_sw_end(struct r600_common_context *rctx,
>> case R600_QUERY_GPU_CP_BUSY:
>> case R600_QUERY_GPU_CB_BUSY:
>> case R600_QUERY_GPU_SDMA_BUSY:
>> + case R600_QUERY_GPU_PFP_BUSY:
>> + case R600_QUERY_GPU_MEQ_BUSY:
>> + case R600_QUERY_GPU_ME_BUSY:
>> + case R600_QUERY_GPU_SURF_SYNC_BUSY:
>> + case R600_QUERY_GPU_DMA_BUSY:
>> + case R600_QUERY_GPU_SCRATCH_RAM_BUSY:
>> + case R600_QUERY_GPU_CE_BUSY:
>> query->end_result = r600_end_counter(rctx->screen,
>> query->b.type,
>> query->begin_result);
>> @@ -1768,6 +1782,13 @@ static struct pipe_driver_query_info r600_driver_query_list[] = {
>> 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("GPU-pfp-busy", GPU_PFP_BUSY, UINT64, AVERAGE),
>> + X("GPU-meq-busy", GPU_MEQ_BUSY, UINT64, AVERAGE),
>> + X("GPU-me-busy", GPU_ME_BUSY, UINT64, AVERAGE),
>> + X("GPU-surf-sync-busy", GPU_SURF_SYNC_BUSY, UINT64, AVERAGE),
>> + X("GPU-dma-busy", GPU_DMA_BUSY, UINT64, AVERAGE),
>> + X("GPU-scratch-ram-busy", GPU_SCRATCH_RAM_BUSY, UINT64, AVERAGE),
>> + X("GPU-ce-busy", GPU_CE_BUSY, UINT64, AVERAGE),
>>
>> X("temperature", GPU_TEMPERATURE, UINT64, AVERAGE),
>> X("shader-clock", CURRENT_GPU_SCLK, HZ, AVERAGE),
>> @@ -1785,7 +1806,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) - 18;
>> + return ARRAY_SIZE(r600_driver_query_list) - 25;
>> }
>>
>> static int r600_get_driver_query_info(struct pipe_screen *screen,
>> diff --git a/src/gallium/drivers/radeon/r600_query.h b/src/gallium/drivers/radeon/r600_query.h
>> index 0b32793c65..5de80d966c 100644
>> --- a/src/gallium/drivers/radeon/r600_query.h
>> +++ b/src/gallium/drivers/radeon/r600_query.h
>> @@ -86,6 +86,13 @@ enum {
>> R600_QUERY_GPU_CP_BUSY,
>> R600_QUERY_GPU_CB_BUSY,
>> R600_QUERY_GPU_SDMA_BUSY,
>> + R600_QUERY_GPU_PFP_BUSY,
>> + R600_QUERY_GPU_MEQ_BUSY,
>> + R600_QUERY_GPU_ME_BUSY,
>> + R600_QUERY_GPU_SURF_SYNC_BUSY,
>> + R600_QUERY_GPU_DMA_BUSY,
>> + R600_QUERY_GPU_SCRATCH_RAM_BUSY,
>> + R600_QUERY_GPU_CE_BUSY,
>> R600_QUERY_NUM_COMPILATIONS,
>> R600_QUERY_NUM_SHADERS_CREATED,
>> R600_QUERY_BACK_BUFFER_PS_DRAW_RATIO,
>> --
>> 2.11.0
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list