[PATCH] drm/amd/pm: avoid driver getting empty metrics table for the first time

Lazar, Lijo Lijo.Lazar at amd.com
Fri Aug 4 15:31:42 UTC 2023


[AMD Official Use Only - General]

Missed one thing - please replace msleep(1) with usleep_range.

Thanks,
Lijo
________________________________
From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> on behalf of Lazar, Lijo <lijo.lazar at amd.com>
Sent: Friday, August 4, 2023 8:07:11 PM
To: Wang, Yang(Kevin) <KevinYang.Wang at amd.com>; amd-gfx at lists.freedesktop.org <amd-gfx at lists.freedesktop.org>
Cc: Kamal, Asad <Asad.Kamal at amd.com>
Subject: Re: [PATCH] drm/amd/pm: avoid driver getting empty metrics table for the first time



On 8/4/2023 8:02 PM, Yang Wang wrote:
> From: Yang Wang <KevinYang.Wang at amd.com>
>
> add metrics.AccumulationCouter check to avoid driver getting an empty
> metrics data since metrics table not updated completely in pmfw side.
>
> Signed-off-by: Yang Wang <KevinYang.Wang at amd.com>
> Reviewed-by: Asad Kamal <asad.kamal at amd.com>
> Tested-by: Asad Kamal <asad.kamal at amd.com>

Reviewed-by: Lijo Lazar <lijo.lazar at amd.com>

Thanks,
Lijo

> ---
>   .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c  | 20 ++++++++++++++-----
>   1 file changed, 15 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
> index 6253ad13833c..5adc6b92bc49 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
> +++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
> @@ -325,14 +325,24 @@ static int smu_v13_0_6_setup_driver_pptable(struct smu_context *smu)
>        MetricsTable_t *metrics = (MetricsTable_t *)smu_table->metrics_table;
>        struct PPTable_t *pptable =
>                (struct PPTable_t *)smu_table->driver_pptable;
> -     int ret;
> -     int i;
> +     int ret, i, retry = 100;
>
>        /* Store one-time values in driver PPTable */
>        if (!pptable->Init) {
> -             ret = smu_v13_0_6_get_metrics_table(smu, NULL, false);
> -             if (ret)
> -                     return ret;
> +             while (retry--) {
> +                     ret = smu_v13_0_6_get_metrics_table(smu, NULL, true);
> +                     if (ret)
> +                             return ret;
> +
> +                     /* Ensure that metrics have been updated */
> +                     if (metrics->AccumulationCounter)
> +                             break;
> +
> +                     msleep(1);
> +             }
> +
> +             if (!retry)
> +                     return -ETIME;
>
>                pptable->MaxSocketPowerLimit =
>                        SMUQ10_TO_UINT(metrics->MaxSocketPowerLimit);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/amd-gfx/attachments/20230804/dc6f5115/attachment-0001.htm>


More information about the amd-gfx mailing list