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)

Signed-off-by: Asad Kamal <[email protected]>
---
 drivers/gpu/drm/amd/pm/amdgpu_pm.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c 
b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
index 60db9b66d08c..03c95621fe2c 100644
--- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
@@ -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:
-- 
2.46.0

Reply via email to