[Mesa-dev] [PATCH 2/2] gallium/radeon: add HUD queries for GPU temperature and clocks

Marek Olšák maraeo at gmail.com
Mon Apr 10 15:43:50 UTC 2017


For the series:

Reviewed-by: Marek Olšák <marek.olsak at amd.com>

Marek

On Mon, Apr 10, 2017 at 11:49 AM, Samuel Pitoiset
<samuel.pitoiset at gmail.com> wrote:
> Only the Radeon kernel driver exposed the GPU temperature and
> the shader/memory clocks, this implements the same functionality
> for the AMDGPU kernel driver.
>
> These queries will return 0 if the DRM version is less than 3.10,
> I don't explicitely check the version here because the query
> codepath is already a bit messy.
>
> v2: - rebase on top of master
>
> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
> ---
>  src/gallium/drivers/radeon/r600_query.c       | 12 ++++++------
>  src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c |  7 ++++++-
>  2 files changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/src/gallium/drivers/radeon/r600_query.c b/src/gallium/drivers/radeon/r600_query.c
> index cb90850a50..0980eca788 100644
> --- a/src/gallium/drivers/radeon/r600_query.c
> +++ b/src/gallium/drivers/radeon/r600_query.c
> @@ -1799,6 +1799,10 @@ static struct pipe_driver_query_info r600_driver_query_list[] = {
>         XG(GPIN, "GPIN_003",            GPIN_NUM_SPI,           UINT, AVERAGE),
>         XG(GPIN, "GPIN_004",            GPIN_NUM_SE,            UINT, AVERAGE),
>
> +       X("temperature",                GPU_TEMPERATURE,        UINT64, AVERAGE),
> +       X("shader-clock",               CURRENT_GPU_SCLK,       HZ, AVERAGE),
> +       X("memory-clock",               CURRENT_GPU_MCLK,       HZ, AVERAGE),
> +
>         /* The following queries must be at the end of the list because their
>          * availability is adjusted dynamically based on the DRM version. */
>         X("GPU-load",                   GPU_LOAD,               UINT64, AVERAGE),
> @@ -1823,10 +1827,6 @@ static struct pipe_driver_query_info r600_driver_query_list[] = {
>         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),
> -       X("memory-clock",               CURRENT_GPU_MCLK,       HZ, AVERAGE),
>  };
>
>  #undef X
> @@ -1839,9 +1839,9 @@ static unsigned r600_get_num_queries(struct r600_common_screen *rscreen)
>                 return ARRAY_SIZE(r600_driver_query_list);
>         else if (rscreen->info.drm_major == 3) {
>                 if (rscreen->chip_class >= VI)
> -                       return ARRAY_SIZE(r600_driver_query_list) - 3;
> +                       return ARRAY_SIZE(r600_driver_query_list);
>                 else
> -                       return ARRAY_SIZE(r600_driver_query_list) - 10;
> +                       return ARRAY_SIZE(r600_driver_query_list) - 7;
>         }
>         else
>                 return ARRAY_SIZE(r600_driver_query_list) - 25;
> diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
> index bb7e545ed6..f3a0c958ed 100644
> --- a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
> +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
> @@ -471,9 +471,14 @@ static uint64_t amdgpu_query_value(struct radeon_winsys *rws,
>        amdgpu_query_heap_info(ws->dev, AMDGPU_GEM_DOMAIN_GTT, 0, &heap);
>        return heap.heap_usage;
>     case RADEON_GPU_TEMPERATURE:
> +      amdgpu_query_sensor_info(ws->dev, AMDGPU_INFO_SENSOR_GPU_TEMP, 4, &retval);
> +      return retval;
>     case RADEON_CURRENT_SCLK:
> +      amdgpu_query_sensor_info(ws->dev, AMDGPU_INFO_SENSOR_GFX_SCLK, 4, &retval);
> +      return retval;
>     case RADEON_CURRENT_MCLK:
> -      return 0;
> +      amdgpu_query_sensor_info(ws->dev, AMDGPU_INFO_SENSOR_GFX_MCLK, 4, &retval);
> +      return retval;
>     case RADEON_GPU_RESET_COUNTER:
>        assert(0);
>        return 0;
> --
> 2.12.2
>
> _______________________________________________
> 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