[PATCH] drm/amd/pm/powerplay/smumgr/vegam_smumgr: Fix error handling in vegam_populate_smc_boot_level()

Alex Deucher alexdeucher at gmail.com
Wed Apr 16 23:02:02 UTC 2025


On Tue, Apr 15, 2025 at 8:33 AM Wentao Liang <vulab at iscas.ac.cn> wrote:
>
> In vegam_populate_smc_boot_level(), the return value of
> phm_find_boot_level() is 0 or negative error code and the
> "if (result)" branch statement will never run into the true
> branch. Besides, this will skip setting the voltages later
> below. Returning early may break working devices.
>
> Add an error handling to phm_find_boot_level() to reset the
> boot level when the function fails. A proper implementation
> can be found in tonga_populate_smc_boot_level().
>
> Fixes: 4a1132782200 ("drm/amd/powerplay: return errno code to caller when error occur")
> Cc: stable at vger.kernel.org # v5.6+

I don't know that this is a fix per se so I don't think stable is appropriate.

This is probably ok, but TBH, I don't really remember how the pptables
were set up on these old chips and whether changing the current
behavior would actually fix or break anything.  I'd be more inclined
to just leave the logic as is lest something break.

> Signed-off-by: Wentao Liang <vulab at iscas.ac.cn>
> ---
>  .../drm/amd/pm/powerplay/smumgr/vegam_smumgr.c    | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/pm/powerplay/smumgr/vegam_smumgr.c b/drivers/gpu/drm/amd/pm/powerplay/smumgr/vegam_smumgr.c
> index 34c9f59b889a..c68dd12b858a 100644
> --- a/drivers/gpu/drm/amd/pm/powerplay/smumgr/vegam_smumgr.c
> +++ b/drivers/gpu/drm/amd/pm/powerplay/smumgr/vegam_smumgr.c
> @@ -1374,15 +1374,20 @@ static int vegam_populate_smc_boot_level(struct pp_hwmgr *hwmgr,
>         result = phm_find_boot_level(&(data->dpm_table.sclk_table),
>                         data->vbios_boot_state.sclk_bootup_value,
>                         (uint32_t *)&(table->GraphicsBootLevel));
> -       if (result)
> -               return result;
> +       if (result != 0) {
> +               table->GraphicsBootLevel = 0;
> +               pr_err("VBIOS did not find boot engine clock value in dependency table. Using Graphics DPM level 0!\n");
> +               result = 0;
> +       }
>
>         result = phm_find_boot_level(&(data->dpm_table.mclk_table),
>                         data->vbios_boot_state.mclk_bootup_value,
>                         (uint32_t *)&(table->MemoryBootLevel));
> -
> -       if (result)
> -               return result;
> +       if (result != 0) {
> +               table->MemoryBootLevel = 0;
> +               pr_err("VBIOS did not find boot engine clock value in dependency table. Using Memory DPM level 0!\n");
> +               result = 0;
> +       }
>
>         table->BootVddc  = data->vbios_boot_state.vddc_bootup_value *
>                         VOLTAGE_SCALE;
> --
> 2.42.0.windows.2
>


More information about the amd-gfx mailing list