<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
Hi Evan,<br>
<br>
I set tmp=smu7_profiling[PP_SMC_PROFILE_CUSTOM] before checking the bupdate parameters (see below). That way I don't have ugly 100-character-long checks in the if size==0 check. Then if its invalid I just return -EINVAL, or if it'svalid then we use it to writeto
 the SMU. If parameters are passed in, tmp is overwritten with the passed-in values and we use it as before.<br>
<br>
Kent<br>
<br>
KENT RUSSELL<br>
Sr. Software Engineer | Linux Compute Kernel<br>
1 Commerce Valley Drive East<br>
Markham, ON L3T 7X6<br>
O +(1) 289-695-2122 | Ext 72122<br>
<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> Quan, Evan<br>
<b>Sent:</b> Wednesday, March 27, 2019 9:26:41 PM<br>
<b>To:</b> Russell, Kent; amd-gfx@lists.freedesktop.org<br>
<b>Cc:</b> Russell, Kent<br>
<b>Subject:</b> RE: [PATCH 2/2] drm/amdgpu: Allow switching to CUSTOM profile on smu7 v2</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">I think you should use smu7_profiling[PP_SMC_POWER_PROFILE_CUSTOM].bupdate_sclk/bupdate_mclk to judge whether there is saved custom profile.<br>
That's where previous custom profile settings store in.<br>
'tmp' is a temporary structures and you should not rely on that.<br>
<br>
Regards,<br>
Evan<br>
> -----Original Message-----<br>
> From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of<br>
> Russell, Kent<br>
> Sent: Wednesday, March 27, 2019 9:59 PM<br>
> To: amd-gfx@lists.freedesktop.org<br>
> Cc: Russell, Kent <Kent.Russell@amd.com><br>
> Subject: [PATCH 2/2] drm/amdgpu: Allow switching to CUSTOM profile on<br>
> smu7 v2<br>
> <br>
> Allow changing to the CUSTOM profile without requiring the parameters<br>
> being passed in each time. Store the values in the smu7_profiling table since<br>
> it's defined here anyways<br>
> <br>
> v2: Add check that CUSTOM was previously set<br>
> <br>
> Change-Id: I6c5e3a1487e12410a6a7670a5cf1a6599253344d<br>
> Signed-off-by: Kent Russell <kent.russell@amd.com><br>
> ---<br>
>  .../gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c  | 32 ++++++++++++--<br>
> -----<br>
>  1 file changed, 21 insertions(+), 11 deletions(-)<br>
> <br>
> diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c<br>
> b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c<br>
> index 83d3d935f3ac..048757e8f494 100644<br>
> --- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c<br>
> +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c<br>
> @@ -77,7 +77,7 @@<br>
>  #define PCIE_BUS_CLK                10000<br>
>  #define TCLK                        (PCIE_BUS_CLK / 10)<br>
> <br>
> -static const struct profile_mode_setting smu7_profiling[7] =<br>
> +static struct profile_mode_setting smu7_profiling[7] =<br>
>                                        {{0, 0, 0, 0, 0, 0, 0, 0},<br>
>                                         {1, 0, 100, 30, 1, 0, 100, 10},<br>
>                                         {1, 10, 0, 30, 0, 0, 0, 0},<br>
> @@ -4984,17 +4984,27 @@ static int smu7_set_power_profile_mode(struct<br>
> pp_hwmgr *hwmgr, long *input, uint<br>
>        mode = input[size];<br>
>        switch (mode) {<br>
>        case PP_SMC_POWER_PROFILE_CUSTOM:<br>
> -             if (size < 8)<br>
> +             if (size < 8 && size != 0)<br>
>                        return -EINVAL;<br>
> -<br>
> -             tmp.bupdate_sclk = input[0];<br>
> -             tmp.sclk_up_hyst = input[1];<br>
> -             tmp.sclk_down_hyst = input[2];<br>
> -             tmp.sclk_activity = input[3];<br>
> -             tmp.bupdate_mclk = input[4];<br>
> -             tmp.mclk_up_hyst = input[5];<br>
> -             tmp.mclk_down_hyst = input[6];<br>
> -             tmp.mclk_activity = input[7];<br>
> +             /* If only CUSTOM is passed in, use the saved values. Check<br>
> +              * that we actually have a CUSTOM profile by ensuring that<br>
> +              * the "use sclk" or the "use mclk" bits are set<br>
> +              */<br>
> +             tmp = smu7_profiling[PP_SMC_POWER_PROFILE_CUSTOM];<br>
> +             if (size == 0) {<br>
> +                     if (tmp.bupdate_sclk == 0 && tmp.bupdate_mclk ==<br>
> 0)<br>
> +                             return -EINVAL;<br>
> +             } else {<br>
> +                     tmp.bupdate_sclk = input[0];<br>
> +                     tmp.sclk_up_hyst = input[1];<br>
> +                     tmp.sclk_down_hyst = input[2];<br>
> +                     tmp.sclk_activity = input[3];<br>
> +                     tmp.bupdate_mclk = input[4];<br>
> +                     tmp.mclk_up_hyst = input[5];<br>
> +                     tmp.mclk_down_hyst = input[6];<br>
> +                     tmp.mclk_activity = input[7];<br>
> +                     smu7_profiling[PP_SMC_POWER_PROFILE_CUSTOM]<br>
> = tmp;<br>
> +             }<br>
>                if (!smum_update_dpm_settings(hwmgr, &tmp)) {<br>
>                        memcpy(&data->current_profile_setting, &tmp,<br>
> sizeof(struct profile_mode_setting));<br>
>                        hwmgr->power_profile_mode = mode;<br>
> --<br>
> 2.17.1<br>
> <br>
> _______________________________________________<br>
> amd-gfx mailing list<br>
> amd-gfx@lists.freedesktop.org<br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><br>
</div>
</span></font></div>
</body>
</html>