drm/amd/pm: Stop pp_od_clk_voltage emit at PAGE_SIZE
Subsystems (3)
PATCH v2 1/1 drm/amd/pm: Stop pp_od_clk_voltage emit at PAGE_SIZE
Stop appending OD sections in amdgpu_get_pp_od_clk_voltage() once the sysfs page is full, instead of checking every sysfs_emit_at() in SMU helpers
v2: Drop the prior series that checked sysfs_emit_at() return values in every SMU *_emit_clk_levels() helper and smu_cmn_print_*(). (Kevin)
--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +12 -3
@@ -866,11 +866,15 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev,if (ret)return ret; -for (clk_index =0 ; clk_index <ARRAY_SIZE (od_clocks) ; clk_index++) { +for (clk_index =0 ; clk_index <ARRAY_SIZE (od_clocks); clk_index++) { +if (size >=PAGE_SIZE ) +break ;amdgpu_dpm_emit_clock_levels (adev, od_clocks[clk_index], buf, &size); } -if (size ==0 ) +if (size >=PAGE_SIZE ) + size =PAGE_SIZE ; +else if (size ==0 ) size =sysfs_emit (buf,"\n" );amdgpu_pm_put_access (adev);
@@ -3915,12 +3919,17 @@ static int amdgpu_retrieve_od_settings(struct amdgpu_device *adev,if (ret)return ret; +if (size >=PAGE_SIZE ) + goto out_pm_put; + ret =amdgpu_dpm_emit_clock_levels (adev, od_type, buf, &size);if (ret) { size = ret; goto out_pm_put; } -if (size ==0 ) +if (size >=PAGE_SIZE ) + size =PAGE_SIZE ; +else if (size ==0 ) size =sysfs_emit (buf,"\n" ); out_pm_put:
Signature · 1 line
2.46.0
AMD General
Hi Asad,
Your patch doesn't seem to resolve the issue you're facing; I think the correct logic should check the return value and the size variable What's your opinion?
Here is the pseudocode:
ret = amdgpu_dpm_emit_clock_levels(adev, od_clocks[clk_index], buf, &size); if (ret < 0) {
continue; // for next clock item.
} else if (ret == 0) {
// Check ret and size/PAGE_SIZE here to meet the requirements
} else { // go out to return.
}
Best Regards,
Kevin
Quoted 71 lines
-----Original Message-----
From: Kamal, Asad <[email protected]>
Sent: Friday, May 29, 2026 11:54 PM
To: [email protected]
Cc: Lazar, Lijo <[email protected]>; Zhang, Hawking <[email protected]>; Ma, Le <[email protected]>; Zhang, Morris <[email protected]>; Deucher, Alexander <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Kamal, Asad <[email protected]>
Subject: [PATCH v2] drm/amd/pm: Stoppp_od_clk_voltageemit atPAGE_SIZEStop appending OD sections in
amdgpu_get_pp_od_clk_voltage()once the sysfs page is full, instead of checking everysysfs_emit_at()in SMU helpersv2: Drop the prior series that checked
sysfs_emit_at()return values in every SMU*_emit_clk_levels()helper and smu_cmn_print_*().
(Kevin)Signed-off-by Asad Kamal <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_pm.c +6
-2@@ -866,11 +866,15 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev, if (ret) return ret; -for (clk_index =0 ; clk_index <ARRAY_SIZE (od_clocks) ; clk_index++) { +for (clk_index =0 ; clk_index <ARRAY_SIZE (od_clocks); clk_index++) { +if (size >=PAGE_SIZE ) +break ;amdgpu_dpm_emit_clock_levels (adev, od_clocks[clk_index], buf, &size); } -if (size ==0 ) +if (size >=PAGE_SIZE ) + size =PAGE_SIZE ; +else if (size ==0 ) size =sysfs_emit (buf,"\n" );amdgpu_pm_put_access(adev);drivers/gpu/drm/amd/pm/amdgpu_pm.c +6
-1@@ -3915,12 +3919,17 @@ static int amdgpu_retrieve_od_settings(struct amdgpu_device *adev, if (ret) return ret; +if (size >=PAGE_SIZE ) + goto out_pm_put; + ret =amdgpu_dpm_emit_clock_levels (adev, od_type, buf, &size);if (ret) { size = ret; goto out_pm_put; } -if (size ==0 ) +if (size >=PAGE_SIZE ) + size =PAGE_SIZE ; +else if (size ==0 ) size =sysfs_emit (buf,"\n" );
out_pm_put:
--
2.46.0
Quoted 6 lines · Yang(Kevin)
AMD General
Hi Asad,
Your patch doesn't seem to resolve the issue you're facing; I think the correct logic should check the return value and the size variable What's your opinion?
I think stop printing if buffer is full seems sufficient.
The expectation is that size out param shouldn't be updated if the function returns failure.
Thanks,
Lijo
Quoted 85 lines
Here is the pseudocode:
ret =amdgpu_dpm_emit_clock_levels(adev, od_clocks[clk_index], buf, &size); if (ret < 0) {
continue; // for next clock item.} else if (ret == 0) { // Check ret and size/PAGE_SIZE here to meet the requirements } else {// go out to return.
}
Best Regards,
KevinQuoted 71 lines
-----Original Message-----
From: Kamal, Asad <[email protected]>
Sent: Friday, May 29, 2026 11:54 PM
To: [email protected]
Cc: Lazar, Lijo <[email protected]>; Zhang, Hawking <[email protected]>; Ma, Le <[email protected]>; Zhang, Morris <[email protected]>; Deucher, Alexander <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Kamal, Asad <[email protected]>
Subject: [PATCH v2] drm/amd/pm: Stoppp_od_clk_voltageemit atPAGE_SIZEStop appending OD sections in
amdgpu_get_pp_od_clk_voltage()once the sysfs page is full, instead of checking everysysfs_emit_at()in SMU helpersv2: Drop the prior series that checked
sysfs_emit_at()return values in every SMU*_emit_clk_levels()helper and smu_cmn_print_*().
(Kevin)Signed-off-by Asad Kamal <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_pm.c +6
-2@@ -866,11 +866,15 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev, if (ret) return ret; -for (clk_index =0 ; clk_index <ARRAY_SIZE (od_clocks) ; clk_index++) { +for (clk_index =0 ; clk_index <ARRAY_SIZE (od_clocks); clk_index++) { +if (size >=PAGE_SIZE ) +break ;amdgpu_dpm_emit_clock_levels (adev, od_clocks[clk_index], buf, &size); } -if (size ==0 ) +if (size >=PAGE_SIZE ) + size =PAGE_SIZE ; +else if (size ==0 ) size =sysfs_emit (buf,"\n" );amdgpu_pm_put_access(adev);drivers/gpu/drm/amd/pm/amdgpu_pm.c +6
-1@@ -3915,12 +3919,17 @@ static int amdgpu_retrieve_od_settings(struct amdgpu_device *adev, if (ret) return ret; +if (size >=PAGE_SIZE ) + goto out_pm_put; + ret =amdgpu_dpm_emit_clock_levels (adev, od_type, buf, &size);if (ret) { size = ret; goto out_pm_put; } -if (size ==0 ) +if (size >=PAGE_SIZE ) + size =PAGE_SIZE ; +else if (size ==0 ) size =sysfs_emit (buf,"\n" );
out_pm_put:
--
2.46.0
Wang, Yang(Kevin)
Reviewed-byAMD General
After per discussed , the patch is
Best Regards,
Kevin
________________________________
From: Lazar, Lijo <[email protected]>
Sent: Monday, June 1, 2026 5:57 PM
To: Wang, Yang(Kevin) <[email protected]>; Kamal, Asad <[email protected]>; [email protected] <[email protected]>
Cc: Zhang, Hawking <[email protected]>; Ma, Le <[email protected]>; Zhang, Morris <[email protected]>; Deucher, Alexander <[email protected]>
Subject: Re: [PATCH v2] drm/amd/pm: Stop pp_od_clk_voltage emit at PAGE_SIZE
Quoted 6 lines · Yang(Kevin)
AMD General
Hi Asad,
Your patch doesn't seem to resolve the issue you're facing; I think the correct logic should check the return value and the size variable What's your opinion?
I think stop printing if buffer is full seems sufficient.
The expectation is that size out param shouldn't be updated if the function returns failure.
Thanks,
Lijo
Quoted 85 lines
Here is the pseudocode:
ret =amdgpu_dpm_emit_clock_levels(adev, od_clocks[clk_index], buf, &size); if (ret < 0) {
continue; // for next clock item.} else if (ret == 0) { // Check ret and size/PAGE_SIZE here to meet the requirements } else {// go out to return.
}
Best Regards,
KevinQuoted 71 lines
-----Original Message-----
From: Kamal, Asad <[email protected]>
Sent: Friday, May 29, 2026 11:54 PM
To: [email protected]
Cc: Lazar, Lijo <[email protected]>; Zhang, Hawking <[email protected]>; Ma, Le <[email protected]>; Zhang, Morris <[email protected]>; Deucher, Alexander <[email protected]>; Wang, Yang(Kevin) <[email protected]>; Kamal, Asad <[email protected]>
Subject: [PATCH v2] drm/amd/pm: Stoppp_od_clk_voltageemit atPAGE_SIZEStop appending OD sections in
amdgpu_get_pp_od_clk_voltage()once the sysfs page is full, instead of checking everysysfs_emit_at()in SMU helpersv2: Drop the prior series that checked
sysfs_emit_at()return values in every SMU*_emit_clk_levels()helper and smu_cmn_print_*().
(Kevin)Signed-off-by Asad Kamal <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_pm.c +6
-2@@ -866,11 +866,15 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev, if (ret) return ret; -for (clk_index =0 ; clk_index <ARRAY_SIZE (od_clocks) ; clk_index++) { +for (clk_index =0 ; clk_index <ARRAY_SIZE (od_clocks); clk_index++) { +if (size >=PAGE_SIZE ) +break ;amdgpu_dpm_emit_clock_levels (adev, od_clocks[clk_index], buf, &size); } -if (size ==0 ) +if (size >=PAGE_SIZE ) + size =PAGE_SIZE ; +else if (size ==0 ) size =sysfs_emit (buf,"\n" );amdgpu_pm_put_access(adev);drivers/gpu/drm/amd/pm/amdgpu_pm.c +6
-1@@ -3915,12 +3919,17 @@ static int amdgpu_retrieve_od_settings(struct amdgpu_device *adev, if (ret) return ret; +if (size >=PAGE_SIZE ) + goto out_pm_put; + ret =amdgpu_dpm_emit_clock_levels (adev, od_type, buf, &size);if (ret) { size = ret; goto out_pm_put; } -if (size ==0 ) +if (size >=PAGE_SIZE ) + size =PAGE_SIZE ; +else if (size ==0 ) size =sysfs_emit (buf,"\n" );
out_pm_put:
--
2.46.0