[Mesa-dev] [PATCH 2/3] gallium/radeon: add new GPU-sdma-busy HUD query

Marek Olšák maraeo at gmail.com
Fri Jan 27 18:46:34 UTC 2017


SRBM_STATUS2 doesn't exist on R600-R700, so it shouldn't be read on those gens.

Marek

On Thu, Jan 26, 2017 at 8:54 PM, Samuel Pitoiset
<samuel.pitoiset at gmail.com> wrote:
> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
> ---
>  src/gallium/drivers/radeon/r600_gpu_load.c    | 11 +++++++++++
>  src/gallium/drivers/radeon/r600_pipe_common.h |  3 +++
>  src/gallium/drivers/radeon/r600_query.c       |  5 ++++-
>  src/gallium/drivers/radeon/r600_query.h       |  1 +
>  4 files changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/drivers/radeon/r600_gpu_load.c b/src/gallium/drivers/radeon/r600_gpu_load.c
> index c84b86d76c..5bea6e2643 100644
> --- a/src/gallium/drivers/radeon/r600_gpu_load.c
> +++ b/src/gallium/drivers/radeon/r600_gpu_load.c
> @@ -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,11 @@ 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);
> +
> +       /* SRBM_STATUS */
> +       rscreen->ws->read_registers(rscreen->ws, SRBM_STATUS2, 1, &value);
> +
> +       UPDATE_COUNTER(sdma, SDMA_BUSY);
>  }
>
>  #undef UPDATE_COUNTER
> @@ -210,6 +219,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");
>         }
> diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h b/src/gallium/drivers/radeon/r600_pipe_common.h
> index 76fbf2af98..08de238bba 100644
> --- a/src/gallium/drivers/radeon/r600_pipe_common.h
> +++ b/src/gallium/drivers/radeon/r600_pipe_common.h
> @@ -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];
>  };
> diff --git a/src/gallium/drivers/radeon/r600_query.c b/src/gallium/drivers/radeon/r600_query.c
> index d4e41306a4..ef73323bae 100644
> --- a/src/gallium/drivers/radeon/r600_query.c
> +++ b/src/gallium/drivers/radeon/r600_query.c
> @@ -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);
> @@ -1765,6 +1767,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),
> @@ -1782,7 +1785,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,
> diff --git a/src/gallium/drivers/radeon/r600_query.h b/src/gallium/drivers/radeon/r600_query.h
> index f2af9240d2..0b32793c65 100644
> --- a/src/gallium/drivers/radeon/r600_query.h
> +++ b/src/gallium/drivers/radeon/r600_query.h
> @@ -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,
> --
> 2.11.0
>
> _______________________________________________
> 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