<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Arial;font-size:10pt;color:#0000FF;margin:5pt;" align="Left">
[AMD Official Use Only]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I'm just looking to clarify this code. The macro eventually expands to look like this</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-size: 10pt; font-family: Consolas, Courier, monospace;">   if ((smu)->ppt_funcs)</span>
<div><span style="font-size: 10pt; font-family: Consolas, Courier, monospace;">   {</span></div>
<div><span style="font-size: 10pt; font-family: Consolas, Courier, monospace;">      if ((smu)->ppt_funcs->get_power_limit)</span></div>
<div><span style="font-size: 10pt; font-family: Consolas, Courier, monospace;">          (smu)->ppt_funcs->get_power_limit(smu, </span></div>
<div><span style="font-size: 10pt; font-family: Consolas, Courier, monospace;">                                            &smu->current_power_limit,
<span style="background-color:rgb(255, 255, 255);display:inline !important">                       
<span style="background-color:rgb(255, 255, 255);display:inline !important">                                           <span> </span></span><span></span></span>&smu->default_power_limit, </span></div>
<div><span style="font-size: 10pt; font-family: Consolas, Courier, monospace;"><span style="background-color:rgb(255, 255, 255);display:inline !important">                                           <span> </span></span>&smu->max_power_limit);</span></div>
<div><span style="font-size: 10pt; font-family: Consolas, Courier, monospace;">      else</span></div>
<div><span style="font-size: 10pt; font-family: Consolas, Courier, monospace;">         return 0;</span></div>
<div><span style="font-size: 10pt; font-family: Consolas, Courier, monospace;">   }</span></div>
<div><span style="font-size: 10pt; font-family: Consolas, Courier, monospace;">   else</span></div>
<span style="font-size: 10pt; font-family: Consolas, Courier, monospace;">      return -EINVAL;</span><br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span><br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>But you have to dig to realize that it's a macro, and that it makes no modification if the function is not defined. It's not clear without then searching and following the function pointers which platforms are using the saved value. I thought of inserting
 the following comment or should I just drop this altogether?</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Consolas, Courier, monospace; font-size: 10pt;"> /* seed the cached smu power limit values iff get_power_limit is defined, otherwise they remain 0 */</span><span><br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Consolas, Courier, monospace; font-size: 10pt;"><br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt;">Thanks</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt;">Darren</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span><br>
</span></div>
<div id="appendonsend"></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> Lazar, Lijo <Lijo.Lazar@amd.com><br>
<b>Sent:</b> Monday, October 4, 2021 6:43 AM<br>
<b>To:</b> Powell, Darren <Darren.Powell@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Subject:</b> Re: [PATCH 3/3] drm/amd/pm: explicitly initialize cached power limits in smu struct</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText"><br>
<br>
On 10/3/2021 10:16 AM, Darren Powell wrote:<br>
> Code appears to initialize values but macro will exit without error<br>
> or initializing value if function is not implmented<br>
> <br>
> Signed-off-by: Darren Powell <darren.powell@amd.com><br>
> ---<br>
>   drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 4 ++++<br>
>   1 file changed, 4 insertions(+)<br>
> <br>
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c<br>
> index faa78a048b1f..210f047e136d 100644<br>
> --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c<br>
> +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c<br>
> @@ -712,6 +712,10 @@ static int smu_late_init(void *handle)<br>
>                return ret;<br>
>        }<br>
>   <br>
> +     smu->current_power_limit = 0;<br>
> +     smu->default_power_limit = 0;<br>
> +     smu->max_power_limit = 0;<br>
> +<br>
<br>
If this is only about first-time init - smu_context is part of adev, it <br>
will be zero initialized when adev is allocated.<br>
<br>
<br>
Thanks,<br>
Lijo<br>
<br>
>        ret = smu_get_asic_power_limits(smu,<br>
>                                        &smu->current_power_limit,<br>
>                                        &smu->default_power_limit,<br>
> <br>
</div>
</span></font></div>
</div>
</body>
</html>