* [PATCH v2] drm/amd/pm/powerplay/smumgr/fiji_smumgr: Add error check in fiji_populate_smc_boot_level()
@ 2025-04-15 10:08 Wentao Liang
2025-04-15 11:55 ` Markus Elfring
2025-04-16 23:03 ` Alex Deucher
0 siblings, 2 replies; 4+ messages in thread
From: Wentao Liang @ 2025-04-15 10:08 UTC (permalink / raw)
To: kenneth.feng, alexander.deucher, christian.koenig, Xinhui.Pan,
airlied, simona
Cc: amd-gfx, dri-devel, linux-kernel, Wentao Liang, stable
The return value of fiji_populate_smc_boot_level() is needs to be checked.
An error handling is also needed 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: dcaf3483ae46 ("drm/amd/pm/powerplay/smumgr/fiji_smumgr: Remove unused variable 'result'")
Cc: stable@vger.kernel.org # v5.11+
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
v2: Fix error code.
.../drm/amd/pm/powerplay/smumgr/fiji_smumgr.c | 23 ++++++++++++++-----
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/amd/pm/powerplay/smumgr/fiji_smumgr.c b/drivers/gpu/drm/amd/pm/powerplay/smumgr/fiji_smumgr.c
index 5e43ad2b2956..78ba22f249b2 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/smumgr/fiji_smumgr.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/smumgr/fiji_smumgr.c
@@ -1600,19 +1600,30 @@ static int fiji_populate_smc_uvd_level(struct pp_hwmgr *hwmgr,
static int fiji_populate_smc_boot_level(struct pp_hwmgr *hwmgr,
struct SMU73_Discrete_DpmTable *table)
{
+ int result = 0;
struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend);
table->GraphicsBootLevel = 0;
table->MemoryBootLevel = 0;
/* find boot level from dpm table */
- phm_find_boot_level(&(data->dpm_table.sclk_table),
- data->vbios_boot_state.sclk_bootup_value,
- (uint32_t *)&(table->GraphicsBootLevel));
+ result = phm_find_boot_level(&(data->dpm_table.sclk_table),
+ data->vbios_boot_state.sclk_bootup_value,
+ (uint32_t *)&(table->GraphicsBootLevel));
+ 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;
+ }
- phm_find_boot_level(&(data->dpm_table.mclk_table),
- data->vbios_boot_state.mclk_bootup_value,
- (uint32_t *)&(table->MemoryBootLevel));
+ result = phm_find_boot_level(&(data->dpm_table.mclk_table),
+ data->vbios_boot_state.mclk_bootup_value,
+ (uint32_t *)&(table->MemoryBootLevel));
+ 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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] drm/amd/pm/powerplay/smumgr/fiji_smumgr: Add error check in fiji_populate_smc_boot_level()
2025-04-15 10:08 [PATCH v2] drm/amd/pm/powerplay/smumgr/fiji_smumgr: Add error check in fiji_populate_smc_boot_level() Wentao Liang
@ 2025-04-15 11:55 ` Markus Elfring
2025-04-16 23:03 ` Alex Deucher
1 sibling, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2025-04-15 11:55 UTC (permalink / raw)
To: vulab, amd-gfx, dri-devel
Cc: stable, LKML, Alex Deucher, Christian König, David Airlie,
Kenneth Feng, Simona Vetter, Xinhui Pan
> The return value of fiji_populate_smc_boot_level() is needs to be checked.
should?
> An error handling is also needed 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().
Can you propose in a nicer way to complete the error handling?
Regards,
Markus
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] drm/amd/pm/powerplay/smumgr/fiji_smumgr: Add error check in fiji_populate_smc_boot_level()
2025-04-15 10:08 [PATCH v2] drm/amd/pm/powerplay/smumgr/fiji_smumgr: Add error check in fiji_populate_smc_boot_level() Wentao Liang
2025-04-15 11:55 ` Markus Elfring
@ 2025-04-16 23:03 ` Alex Deucher
2025-04-17 8:45 ` Feng, Kenneth
1 sibling, 1 reply; 4+ messages in thread
From: Alex Deucher @ 2025-04-16 23:03 UTC (permalink / raw)
To: Wentao Liang
Cc: kenneth.feng, alexander.deucher, christian.koenig, Xinhui.Pan,
airlied, simona, amd-gfx, dri-devel, linux-kernel, stable
On Tue, Apr 15, 2025 at 6:23 AM Wentao Liang <vulab@iscas.ac.cn> wrote:
>
> The return value of fiji_populate_smc_boot_level() is needs to be checked.
> An error handling is also needed 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: dcaf3483ae46 ("drm/amd/pm/powerplay/smumgr/fiji_smumgr: Remove unused variable 'result'")
> Cc: stable@vger.kernel.org # v5.11+
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@iscas.ac.cn>
> ---
> v2: Fix error code.
>
> .../drm/amd/pm/powerplay/smumgr/fiji_smumgr.c | 23 ++++++++++++++-----
> 1 file changed, 17 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/pm/powerplay/smumgr/fiji_smumgr.c b/drivers/gpu/drm/amd/pm/powerplay/smumgr/fiji_smumgr.c
> index 5e43ad2b2956..78ba22f249b2 100644
> --- a/drivers/gpu/drm/amd/pm/powerplay/smumgr/fiji_smumgr.c
> +++ b/drivers/gpu/drm/amd/pm/powerplay/smumgr/fiji_smumgr.c
> @@ -1600,19 +1600,30 @@ static int fiji_populate_smc_uvd_level(struct pp_hwmgr *hwmgr,
> static int fiji_populate_smc_boot_level(struct pp_hwmgr *hwmgr,
> struct SMU73_Discrete_DpmTable *table)
> {
> + int result = 0;
> struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend);
>
> table->GraphicsBootLevel = 0;
> table->MemoryBootLevel = 0;
>
> /* find boot level from dpm table */
> - phm_find_boot_level(&(data->dpm_table.sclk_table),
> - data->vbios_boot_state.sclk_bootup_value,
> - (uint32_t *)&(table->GraphicsBootLevel));
> + result = phm_find_boot_level(&(data->dpm_table.sclk_table),
> + data->vbios_boot_state.sclk_bootup_value,
> + (uint32_t *)&(table->GraphicsBootLevel));
> + 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;
> + }
>
> - phm_find_boot_level(&(data->dpm_table.mclk_table),
> - data->vbios_boot_state.mclk_bootup_value,
> - (uint32_t *)&(table->MemoryBootLevel));
> + result = phm_find_boot_level(&(data->dpm_table.mclk_table),
> + data->vbios_boot_state.mclk_bootup_value,
> + (uint32_t *)&(table->MemoryBootLevel));
> + 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
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH v2] drm/amd/pm/powerplay/smumgr/fiji_smumgr: Add error check in fiji_populate_smc_boot_level()
2025-04-16 23:03 ` Alex Deucher
@ 2025-04-17 8:45 ` Feng, Kenneth
0 siblings, 0 replies; 4+ messages in thread
From: Feng, Kenneth @ 2025-04-17 8:45 UTC (permalink / raw)
To: Alex Deucher, Wentao Liang
Cc: Deucher, Alexander, Koenig, Christian, Xinhui.Pan@amd.com,
airlied@gmail.com, simona@ffwll.ch, amd-gfx@lists.freedesktop.org,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
[AMD Official Use Only - AMD Internal Distribution Only]
-----Original Message-----
From: Alex Deucher <alexdeucher@gmail.com>
Sent: Thursday, April 17, 2025 7:03 AM
To: Wentao Liang <vulab@iscas.ac.cn>
Cc: Feng, Kenneth <Kenneth.Feng@amd.com>; Deucher, Alexander <Alexander.Deucher@amd.com>; Koenig, Christian <Christian.Koenig@amd.com>; Xinhui.Pan@amd.com; airlied@gmail.com; simona@ffwll.ch; amd-gfx@lists.freedesktop.org; dri-devel@lists.freedesktop.org; linux-kernel@vger.kernel.org; stable@vger.kernel.org
Subject: Re: [PATCH v2] drm/amd/pm/powerplay/smumgr/fiji_smumgr: Add error check in fiji_populate_smc_boot_level()
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
On Tue, Apr 15, 2025 at 6:23 AM Wentao Liang <vulab@iscas.ac.cn> wrote:
>
> The return value of fiji_populate_smc_boot_level() is needs to be checked.
> An error handling is also needed 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: dcaf3483ae46 ("drm/amd/pm/powerplay/smumgr/fiji_smumgr: Remove
> unused variable 'result'")
> Cc: stable@vger.kernel.org # v5.11+
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.
In production, VBIOS makes sure that the bootup clock values match the ones in pptable. So the error can't happen in reality. And the result is overridden to 0 anyway, on tonga as well.
Thanks.
Kenneth Feng
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
> v2: Fix error code.
>
> .../drm/amd/pm/powerplay/smumgr/fiji_smumgr.c | 23
> ++++++++++++++-----
> 1 file changed, 17 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/pm/powerplay/smumgr/fiji_smumgr.c
> b/drivers/gpu/drm/amd/pm/powerplay/smumgr/fiji_smumgr.c
> index 5e43ad2b2956..78ba22f249b2 100644
> --- a/drivers/gpu/drm/amd/pm/powerplay/smumgr/fiji_smumgr.c
> +++ b/drivers/gpu/drm/amd/pm/powerplay/smumgr/fiji_smumgr.c
> @@ -1600,19 +1600,30 @@ static int fiji_populate_smc_uvd_level(struct
> pp_hwmgr *hwmgr, static int fiji_populate_smc_boot_level(struct pp_hwmgr *hwmgr,
> struct SMU73_Discrete_DpmTable *table) {
> + int result = 0;
> struct smu7_hwmgr *data = (struct smu7_hwmgr
> *)(hwmgr->backend);
>
> table->GraphicsBootLevel = 0;
> table->MemoryBootLevel = 0;
>
> /* find boot level from dpm table */
> - phm_find_boot_level(&(data->dpm_table.sclk_table),
> - data->vbios_boot_state.sclk_bootup_value,
> - (uint32_t *)&(table->GraphicsBootLevel));
> + result = phm_find_boot_level(&(data->dpm_table.sclk_table),
> + data->vbios_boot_state.sclk_bootup_value,
> + (uint32_t *)&(table->GraphicsBootLevel));
> + 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;
> + }
>
> - phm_find_boot_level(&(data->dpm_table.mclk_table),
> - data->vbios_boot_state.mclk_bootup_value,
> - (uint32_t *)&(table->MemoryBootLevel));
> + result = phm_find_boot_level(&(data->dpm_table.mclk_table),
> + data->vbios_boot_state.mclk_bootup_value,
> + (uint32_t *)&(table->MemoryBootLevel));
> + 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
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-04-17 8:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-15 10:08 [PATCH v2] drm/amd/pm/powerplay/smumgr/fiji_smumgr: Add error check in fiji_populate_smc_boot_level() Wentao Liang
2025-04-15 11:55 ` Markus Elfring
2025-04-16 23:03 ` Alex Deucher
2025-04-17 8:45 ` Feng, Kenneth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox