drm/amd/pm: fix smu v13 soft clock frequency setting issue
Subsystems (3)
PATCH 1/2 drm/amd/pm: fix smu v13 soft clock frequency setting issue
resolve the issue where some freq frequencies cannot be set correctly due to insufficient floating-point precision.
--- drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h | 1 + drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 2 ++ 2 files changed, 3 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h +1 -0
@@ -55,6 +55,7 @@#define SMUQ10_TO_UINT (x) ((x) >> 10)#define SMUQ10_FRAC (x) ((x) & 0x3ff)#define SMUQ10_ROUND (x) ((SMUQ10_TO_UINT(x)) + ((SMUQ10_FRAC(x)) >= 0x200)) +#define SMU_V13_SOFT_FREQ_ROUND (x) ((x) + 1)extern const int pmfw_decoded_link_speed[5 ];extern const int pmfw_decoded_link_width[7 ];
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +2 -0
@@ -1554,6 +1554,7 @@ int smu_v13_0_set_soft_freq_limited_range(struct smu_context *smu,return clk_id;if (max >0 ) { + max =SMU_V13_SOFT_FREQ_ROUND (max);if (automatic) param = (uint32_t )((clk_id <<16 ) |0xffff );else
@@ -1565,6 +1566,7 @@ int smu_v13_0_set_soft_freq_limited_range(struct smu_context *smu, }if (min >0 ) { + min =SMU_V13_SOFT_FREQ_ROUND (min);if (automatic) param = (uint32_t )((clk_id <<16 ) |0 );else
Signature · 1 line
2.34.1
PATCH 2/2 drm/amd/pm: fix smu v14 soft clock frequency setting issue
resolve the issue where some freq frequencies cannot be set correctly due to insufficient floating-point precision.
--- drivers/gpu/drm/amd/pm/swsmu/inc/smu_v14_0.h | 1 + drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0.c | 2 ++ 2 files changed, 3 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/inc/smu_v14_0.h +1 -0
@@ -56,6 +56,7 @@ extern const int decoded_link_width[8];#define DECODE_GEN_SPEED (gen_speed_idx) (decoded_link_speed[gen_speed_idx])#define DECODE_LANE_WIDTH (lane_width_idx) (decoded_link_width[lane_width_idx]) +#define SMU_V14_SOFT_FREQ_ROUND (x) ((x) + 1)struct smu_14_0_max_sustainable_clocks {uint32_t display_clock;
drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0.c +2 -0
@@ -1177,6 +1177,7 @@ int smu_v14_0_set_soft_freq_limited_range(struct smu_context *smu,return clk_id;if (max >0 ) { + max =SMU_V14_SOFT_FREQ_ROUND (max);if (automatic) param = (uint32_t )((clk_id <<16 ) |0xffff );else
@@ -1188,6 +1189,7 @@ int smu_v14_0_set_soft_freq_limited_range(struct smu_context *smu, }if (min >0 ) { + min =SMU_V14_SOFT_FREQ_ROUND (min);if (automatic) param = (uint32_t )((clk_id <<16 ) |0 );else
Signature · 1 line
2.34.1
Quoted 26 lines · Yang Wang
resolve the issue where some freq frequencies cannot be set correctly due to insufficient floating-point precision.
Signed-off-by Yang Wang <[email protected]>--- drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h | 1 + drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 2 ++ 2 files changed, 3 insertions(+)drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h +1
-0@@ -55,6 +55,7 @@#define SMUQ10_TO_UINT (x) ((x) >> 10)#define SMUQ10_FRAC (x) ((x) & 0x3ff)#define SMUQ10_ROUND (x) ((SMUQ10_TO_UINT(x)) + ((SMUQ10_FRAC(x)) >= 0x200)) +#define SMU_V13_SOFT_FREQ_ROUND (x) ((x) + 1)extern const int pmfw_decoded_link_speed[5 ];extern const int pmfw_decoded_link_width[7 ];drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +0
-0
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c int smu_v13_0_set_soft_freq_limited_range(struct smu_context *smu, · line 1557
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +1
-0@@ -1554,6 +1554,7 @@ int smu_v13_0_set_soft_freq_limited_range(struct smu_context *smu,return clk_id;if (max >0 ) { + max =SMU_V13_SOFT_FREQ_ROUND (max);
Looks more like a firmware issue. Isn't firmware supposed to round it to the closest DPM level frequency?
Thanks,
Lijo
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +1
-0if (automatic) param = (uint32_t )((clk_id <<16 ) |0xffff );else @@ -1565,6 +1566,7 @@ int smu_v13_0_set_soft_freq_limited_range(struct smu_context *smu, }if (min >0 ) { + min =SMU_V13_SOFT_FREQ_ROUND (min);if (automatic) param = (uint32_t )((clk_id <<16 ) |0 );else
Alex Deucher
Reviewed-byQuoted 32 lines · Lijo
Quoted 28 lines · Yang Wang
resolve the issue where some freq frequencies cannot be set correctly due to insufficient floating-point precision.
Signed-off-by Yang Wang <[email protected]>--- drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h | 1 + drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 2 ++ 2 files changed, 3 insertions(+)drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h +1
-0@@ -55,6 +55,7 @@#define SMUQ10_TO_UINT (x) ((x) >> 10)#define SMUQ10_FRAC (x) ((x) & 0x3ff)#define SMUQ10_ROUND (x) ((SMUQ10_TO_UINT(x)) + ((SMUQ10_FRAC(x)) >= 0x200)) +#define SMU_V13_SOFT_FREQ_ROUND (x) ((x) + 1)extern const int pmfw_decoded_link_speed[5 ];extern const int pmfw_decoded_link_width[7 ];drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +0
-0@@ -1554,6 +1554,7 @@ int smu_v13_0_set_soft_freq_limited_range(struct smu_context *smu,return clk_id;
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c int smu_v13_0_set_soft_freq_limited_range(struct smu_context *smu, · line 1557
Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +1
-0if (max >0 ) { + max =SMU_V13_SOFT_FREQ_ROUND (max);Looks more like a firmware issue. Isn't firmware supposed to round it to the closest DPM level frequency?
Arguably yes, but at this point, it's easier to fix in the driver for existing programs considering all of the firmware out in the wild.
Alex
Quoted 4 lines
Thanks,
Lijo
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c int smu_v13_0_set_soft_freq_limited_range(struct smu_context *smu, · line 1569
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +1
-0if (automatic) param = (uint32_t )((clk_id <<16 ) |0xffff );else @@ -1565,6 +1566,7 @@ int smu_v13_0_set_soft_freq_limited_range(struct smu_context *smu, }if (min >0 ) { + min =SMU_V13_SOFT_FREQ_ROUND (min);
Does min need this too or just max? Same question on smu14. With that clarified the patch is:
Alex
Quoted 4 lines
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +0
-0if (automatic) param = (uint32_t )((clk_id <<16 ) |0 );else
Quoted 33 lines · Alex Deucher
Quoted 32 lines · Lijo
Quoted 28 lines · Yang Wang
resolve the issue where some freq frequencies cannot be set correctly due to insufficient floating-point precision.
Signed-off-by Yang Wang <[email protected]>--- drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h | 1 + drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 2 ++ 2 files changed, 3 insertions(+)drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h +1
-0@@ -55,6 +55,7 @@#define SMUQ10_TO_UINT (x) ((x) >> 10)#define SMUQ10_FRAC (x) ((x) & 0x3ff)#define SMUQ10_ROUND (x) ((SMUQ10_TO_UINT(x)) + ((SMUQ10_FRAC(x)) >= 0x200)) +#define SMU_V13_SOFT_FREQ_ROUND (x) ((x) + 1)extern const int pmfw_decoded_link_speed[5 ];extern const int pmfw_decoded_link_width[7 ];drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +0
-0@@ -1554,6 +1554,7 @@ int smu_v13_0_set_soft_freq_limited_range(struct smu_context *smu,return clk_id;
Quoted 9 lines
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c int smu_v13_0_set_soft_freq_limited_range(struct smu_context *smu, · line 1557
Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +1
-0if (max >0 ) { + max =SMU_V13_SOFT_FREQ_ROUND (max);Looks more like a firmware issue. Isn't firmware supposed to round it to the closest DPM level frequency?
Arguably yes, but at this point, it's easier to fix in the driver for existing programs considering all of the firmware out in the wild.
The question then is will just (x + 1) alone get to the right frequency? Or should the logic be like what firmware is expected to do to find the nearest dpm frequency?
Thanks,
Lijo
Quoted 26 lines
Alex
Quoted 4 lines
Thanks,
LijoQuoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c int smu_v13_0_set_soft_freq_limited_range(struct smu_context *smu, · line 1569
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +1
-0if (automatic) param = (uint32_t )((clk_id <<16 ) |0xffff );else @@ -1565,6 +1566,7 @@ int smu_v13_0_set_soft_freq_limited_range(struct smu_context *smu, }if (min >0 ) { + min =SMU_V13_SOFT_FREQ_ROUND (min);Does min need this too or just max? Same question on smu14. With that clarified the patch is:
Reviewed-by Alex Deucher <[email protected]>Alex
Quoted 4 lines
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +0
-0if (automatic) param = (uint32_t )((clk_id <<16 ) |0 );else
Quoted 43 lines · Lijo
Quoted 39 lines · Alex Deucher
Quoted 37 lines · Lijo
Quoted 26 lines · Yang Wang
resolve the issue where some freq frequencies cannot be set correctly due to insufficient floating-point precision.
Signed-off-by Yang Wang <[email protected]>--- drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h | 1 + drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 2 ++ 2 files changed, 3 insertions(+)drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h +1
-0@@ -55,6 +55,7 @@#define SMUQ10_TO_UINT (x) ((x) >> 10)#define SMUQ10_FRAC (x) ((x) & 0x3ff)#define SMUQ10_ROUND (x) ((SMUQ10_TO_UINT(x)) + ((SMUQ10_FRAC(x)) >= 0x200)) +#define SMU_V13_SOFT_FREQ_ROUND (x) ((x) + 1)extern const int pmfw_decoded_link_speed[5 ];extern const int pmfw_decoded_link_width[7 ];drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +0
-0drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c int smu_v13_0_set_soft_freq_limited_range(struct smu_context *smu, · line 1557
Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +1
-0@@ -1554,6 +1554,7 @@ int smu_v13_0_set_soft_freq_limited_range(struct smu_context *smu,return clk_id;if (max >0 ) { + max =SMU_V13_SOFT_FREQ_ROUND (max);Looks more like a firmware issue. Isn't firmware supposed to round it to the closest DPM level frequency?
Quoted 7 lines
Quoted 3 lines
Arguably yes, but at this point, it's easier to fix in the driver for existing programs considering all of the firmware out in the wild.
The question then is will just (x + 1) alone get to the right frequency? Or should the logic be like what firmware is expected to do to find the nearest dpm frequency?
According to the PMFW team, yes. I think the issue is the int to float conversion rounds up rather than down.
Alex
Quoted 31 lines
Thanks,
LijoQuoted 26 lines
Alex
Quoted 4 lines
Thanks,
LijoQuoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c int smu_v13_0_set_soft_freq_limited_range(struct smu_context *smu, · line 1569
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +1
-0if (automatic) param = (uint32_t )((clk_id <<16 ) |0xffff );else @@ -1565,6 +1566,7 @@ int smu_v13_0_set_soft_freq_limited_range(struct smu_context *smu, }if (min >0 ) { + min =SMU_V13_SOFT_FREQ_ROUND (min);Does min need this too or just max? Same question on smu14. With that clarified the patch is:
Reviewed-by Alex Deucher <[email protected]>Alex
Quoted 4 lines
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +0
-0if (automatic) param = (uint32_t )((clk_id <<16 ) |0 );else
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 1 line
Does min need this too or just max? Same question on smu14.
Yes, after confirmed with PMFW team that only 'max' needs to patch this convert, the PMFW will clamp the input value to align the internal fmin/fmax value. And this change will be corrected before submitting this patch.
Best Regards,
Kevin
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Friday, January 23, 2026 01:22
To: Alex Deucher <[email protected]>
Cc: Wang, Yang(Kevin) <[email protected]>; [email protected]; Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH 1/2] drm/amd/pm: fix smu v13 soft clock frequency setting issue
Quoted 36 lines · Alex Deucher
Quoted 35 lines · Lijo
Quoted 31 lines · Yang Wang
resolve the issue where some freq frequencies cannot be set correctly due to insufficient floating-point precision.
Signed-off-by Yang Wang <[email protected]>--- drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h | 1 + drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 2 ++ 2 files changed, 3 insertions(+)drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h +1
-0@@ -55,6 +55,7 @@#define SMUQ10_TO_UINT (x) ((x) >> 10)#define SMUQ10_FRAC (x) ((x) & 0x3ff)#define SMUQ10_ROUND (x) ((SMUQ10_TO_UINT(x)) + ((SMUQ10_FRAC(x)) >= 0x200)) +#define SMU_V13_SOFT_FREQ_ROUND (x) ((x) + 1)extern const int pmfw_decoded_link_speed[5 ];extern const int pmfw_decoded_link_width[7]; diff --git
a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.cb/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c
index51f96fdcec24..e27ea0879429100644drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +0
-0@@ -1554,6 +1554,7 @@ int smu_v13_0_set_soft_freq_limited_range(struct smu_context *smu,return clk_id;
Quoted 9 lines
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c int smu_v13_0_set_soft_freq_limited_range(struct smu_context *smu, · line 1557
Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +1
-0if (max >0 ) { + max =SMU_V13_SOFT_FREQ_ROUND (max);Looks more like a firmware issue. Isn't firmware supposed to round it to the closest DPM level frequency?
Arguably yes, but at this point, it's easier to fix in the driver for existing programs considering all of the firmware out in the wild.
The question then is will just (x + 1) alone get to the right frequency?
Or should the logic be like what firmware is expected to do to find the nearest dpm frequency?
Thanks,
Lijo
Quoted 26 lines
Alex
Quoted 4 lines
Thanks,
LijoQuoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c int smu_v13_0_set_soft_freq_limited_range(struct smu_context *smu, · line 1569
Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +1
-0if (automatic) param = (uint32_t )((clk_id <<16 ) |0xffff );else @@ -1565,6 +1566,7 @@ int smu_v13_0_set_soft_freq_limited_range(struct smu_context *smu, }if (min >0 ) { + min =SMU_V13_SOFT_FREQ_ROUND (min);Does min need this too or just max? Same question on smu14. With that clarified the patch is:
Reviewed-by Alex Deucher <[email protected]>Alex
Quoted 4 lines
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +0
-0if (automatic) param = (uint32_t )((clk_id <<16 ) |0 );else