<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
<p style="font-family:Arial;font-size:10pt;color:#0000FF;margin:5pt;font-style:normal;font-weight:normal;text-decoration:none;" align="Left">
[AMD Official Use Only - General]<br>
</p>
<br>
<div>
<div style="" dir="auto">Missed one thing - please replace msleep(1) with usleep_range.</div>
<div id="ms-outlook-mobile-signature" dir="auto">
<div><br>
</div>
Thanks,<br>
Lijo</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Lazar, Lijo <lijo.lazar@amd.com><br>
<b>Sent:</b> Friday, August 4, 2023 8:07:11 PM<br>
<b>To:</b> Wang, Yang(Kevin) <KevinYang.Wang@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Kamal, Asad <Asad.Kamal@amd.com><br>
<b>Subject:</b> Re: [PATCH] drm/amd/pm: avoid driver getting empty metrics table for the first time</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText"><br>
<br>
On 8/4/2023 8:02 PM, Yang Wang wrote:<br>
> From: Yang Wang <KevinYang.Wang@amd.com><br>
> <br>
> add metrics.AccumulationCouter check to avoid driver getting an empty<br>
> metrics data since metrics table not updated completely in pmfw side.<br>
> <br>
> Signed-off-by: Yang Wang <KevinYang.Wang@amd.com><br>
> Reviewed-by: Asad Kamal <asad.kamal@amd.com><br>
> Tested-by: Asad Kamal <asad.kamal@amd.com><br>
<br>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com><br>
<br>
Thanks,<br>
Lijo<br>
<br>
> ---<br>
>   .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c  | 20 ++++++++++++++-----<br>
>   1 file changed, 15 insertions(+), 5 deletions(-)<br>
> <br>
> 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<br>
> index 6253ad13833c..5adc6b92bc49 100644<br>
> --- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c<br>
> +++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c<br>
> @@ -325,14 +325,24 @@ static int smu_v13_0_6_setup_driver_pptable(struct smu_context *smu)<br>
>        MetricsTable_t *metrics = (MetricsTable_t *)smu_table->metrics_table;<br>
>        struct PPTable_t *pptable =<br>
>                (struct PPTable_t *)smu_table->driver_pptable;<br>
> -     int ret;<br>
> -     int i;<br>
> +     int ret, i, retry = 100;<br>
>   <br>
>        /* Store one-time values in driver PPTable */<br>
>        if (!pptable->Init) {<br>
> -             ret = smu_v13_0_6_get_metrics_table(smu, NULL, false);<br>
> -             if (ret)<br>
> -                     return ret;<br>
> +             while (retry--) {<br>
> +                     ret = smu_v13_0_6_get_metrics_table(smu, NULL, true);<br>
> +                     if (ret)<br>
> +                             return ret;<br>
> +<br>
> +                     /* Ensure that metrics have been updated */<br>
> +                     if (metrics->AccumulationCounter)<br>
> +                             break;<br>
> +<br>
> +                     msleep(1);<br>
> +             }<br>
> +<br>
> +             if (!retry)<br>
> +                     return -ETIME;<br>
>   <br>
>                pptable->MaxSocketPowerLimit =<br>
>                        SMUQ10_TO_UINT(metrics->MaxSocketPowerLimit);<br>
</div>
</span></font></div>
</div>
</body>
</html>