]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amd/pm: fix the issue of size calculation error for smu 13.0.6
authorYang Wang <kevinyang.wang@amd.com>
Mon, 27 Oct 2025 07:22:54 +0000 (15:22 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 4 Nov 2025 16:52:46 +0000 (11:52 -0500)
v1:
the driver should handle return value of smu_v13_0_6_printk_clk_levels()
to return the correct size for sysfs reads.

v2:
fix the issue of size calculation error in smu_v13_0_6_print_clks()

Fixes: cdfdec6f1608 ("drm/amd/pm: Avoid writing nulls into `pp_od_clk_voltage`")
Signed-off-by: Yang Wang <kevinyang.wang@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c

index e1f9aa5d6c205ee77c69c6045d49498b65c9a9d3..197fd91e1fb4b2a814c9f5ade49b8b4e663c8e02 100644 (file)
@@ -1394,7 +1394,7 @@ static int smu_v13_0_6_print_clks(struct smu_context *smu, char *buf, int size,
                return -EINVAL;
 
        if (curr_clk < SMU_13_0_6_DSCLK_THRESHOLD) {
-               size = sysfs_emit_at(buf, size, "S: %uMhz *\n", curr_clk);
+               size += sysfs_emit_at(buf, size, "S: %uMhz *\n", curr_clk);
                for (i = 0; i < clocks.num_levels; i++)
                        size += sysfs_emit_at(buf, size, "%d: %uMhz\n", i,
                                              clocks.data[i].clocks_in_khz /
@@ -1514,9 +1514,13 @@ static int smu_v13_0_6_print_clk_levels(struct smu_context *smu,
 
                single_dpm_table = &(dpm_context->dpm_tables.uclk_table);
 
-               return smu_v13_0_6_print_clks(smu, buf, size, single_dpm_table,
-                                             now, "mclk");
+               ret = smu_v13_0_6_print_clks(smu, buf, size, single_dpm_table,
+                                            now, "mclk");
+               if (ret < 0)
+                       return ret;
 
+               size += ret;
+               break;
        case SMU_SOCCLK:
                ret = smu_v13_0_6_get_current_clk_freq_by_table(smu, SMU_SOCCLK,
                                                                &now);
@@ -1528,9 +1532,13 @@ static int smu_v13_0_6_print_clk_levels(struct smu_context *smu,
 
                single_dpm_table = &(dpm_context->dpm_tables.soc_table);
 
-               return smu_v13_0_6_print_clks(smu, buf, size, single_dpm_table,
-                                             now, "socclk");
+               ret = smu_v13_0_6_print_clks(smu, buf, size, single_dpm_table,
+                                            now, "socclk");
+               if (ret < 0)
+                       return ret;
 
+               size += ret;
+               break;
        case SMU_FCLK:
                ret = smu_v13_0_6_get_current_clk_freq_by_table(smu, SMU_FCLK,
                                                                &now);
@@ -1542,9 +1550,13 @@ static int smu_v13_0_6_print_clk_levels(struct smu_context *smu,
 
                single_dpm_table = &(dpm_context->dpm_tables.fclk_table);
 
-               return smu_v13_0_6_print_clks(smu, buf, size, single_dpm_table,
-                                             now, "fclk");
+               ret = smu_v13_0_6_print_clks(smu, buf, size, single_dpm_table,
+                                            now, "fclk");
+               if (ret < 0)
+                       return ret;
 
+               size += ret;
+               break;
        case SMU_VCLK:
                ret = smu_v13_0_6_get_current_clk_freq_by_table(smu, SMU_VCLK,
                                                                &now);
@@ -1556,9 +1568,13 @@ static int smu_v13_0_6_print_clk_levels(struct smu_context *smu,
 
                single_dpm_table = &(dpm_context->dpm_tables.vclk_table);
 
-               return smu_v13_0_6_print_clks(smu, buf, size, single_dpm_table,
-                                             now, "vclk");
+               ret = smu_v13_0_6_print_clks(smu, buf, size, single_dpm_table,
+                                            now, "vclk");
+               if (ret < 0)
+                       return ret;
 
+               size += ret;
+               break;
        case SMU_DCLK:
                ret = smu_v13_0_6_get_current_clk_freq_by_table(smu, SMU_DCLK,
                                                               &now);
@@ -1570,9 +1586,13 @@ static int smu_v13_0_6_print_clk_levels(struct smu_context *smu,
 
                single_dpm_table = &(dpm_context->dpm_tables.dclk_table);
 
-               return smu_v13_0_6_print_clks(smu, buf, size, single_dpm_table,
-                                             now, "dclk");
+               ret = smu_v13_0_6_print_clks(smu, buf, size, single_dpm_table,
+                                            now, "dclk");
+               if (ret < 0)
+                       return ret;
 
+               size += ret;
+               break;
        default:
                break;
        }