]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amd/pm: Use emit_clk_levels in SMUv13.0.6
authorLijo Lazar <lijo.lazar@amd.com>
Wed, 26 Nov 2025 07:44:45 +0000 (13:14 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 8 Dec 2025 19:14:01 +0000 (14:14 -0500)
Move to emit_clk_levels from print_clk_levels

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@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 a3ceecbe5d684b033b1701a0e223999523ef7f38..7ba299d5d7cabb49bad083ad09735f644ef9dfd8 100644 (file)
@@ -1453,10 +1453,11 @@ static int smu_v13_0_6_print_clks(struct smu_context *smu, char *buf, int size,
        return size;
 }
 
-static int smu_v13_0_6_print_clk_levels(struct smu_context *smu,
-                                       enum smu_clk_type type, char *buf)
+static int smu_v13_0_6_emit_clk_levels(struct smu_context *smu,
+                                      enum smu_clk_type type, char *buf,
+                                      int *offset)
 {
-       int now, size = 0, start_offset = 0;
+       int now, size = *offset, start_offset = *offset;
        int ret = 0;
        struct smu_umd_pstate_table *pstate_table = &smu->pstate_table;
        struct smu_13_0_dpm_table *single_dpm_table;
@@ -1464,12 +1465,9 @@ static int smu_v13_0_6_print_clk_levels(struct smu_context *smu,
        struct smu_13_0_dpm_context *dpm_context = NULL;
        uint32_t min_clk, max_clk;
 
-       smu_cmn_get_sysfs_buf(&buf, &size);
-       start_offset = size;
-
        if (amdgpu_ras_intr_triggered()) {
-               size += sysfs_emit_at(buf, size, "unavailable\n");
-               return size - start_offset;
+               sysfs_emit_at(buf, size, "unavailable\n");
+               return -EBUSY;
        }
 
        dpm_context = smu_dpm->dpm_context;
@@ -1546,7 +1544,7 @@ static int smu_v13_0_6_print_clk_levels(struct smu_context *smu,
                if (ret < 0)
                        return ret;
 
-               size += ret;
+               size = ret;
                break;
        case SMU_SOCCLK:
                ret = smu_v13_0_6_get_current_clk_freq_by_table(smu, SMU_SOCCLK,
@@ -1564,7 +1562,7 @@ static int smu_v13_0_6_print_clk_levels(struct smu_context *smu,
                if (ret < 0)
                        return ret;
 
-               size += ret;
+               size = ret;
                break;
        case SMU_FCLK:
                ret = smu_v13_0_6_get_current_clk_freq_by_table(smu, SMU_FCLK,
@@ -1582,7 +1580,7 @@ static int smu_v13_0_6_print_clk_levels(struct smu_context *smu,
                if (ret < 0)
                        return ret;
 
-               size += ret;
+               size = ret;
                break;
        case SMU_VCLK:
                ret = smu_v13_0_6_get_current_clk_freq_by_table(smu, SMU_VCLK,
@@ -1600,7 +1598,7 @@ static int smu_v13_0_6_print_clk_levels(struct smu_context *smu,
                if (ret < 0)
                        return ret;
 
-               size += ret;
+               size = ret;
                break;
        case SMU_DCLK:
                ret = smu_v13_0_6_get_current_clk_freq_by_table(smu, SMU_DCLK,
@@ -1618,13 +1616,15 @@ static int smu_v13_0_6_print_clk_levels(struct smu_context *smu,
                if (ret < 0)
                        return ret;
 
-               size += ret;
+               size = ret;
                break;
        default:
                break;
        }
 
-       return size - start_offset;
+       *offset += size - start_offset;
+
+       return 0;
 }
 
 static int smu_v13_0_6_upload_dpm_level(struct smu_context *smu, bool max,
@@ -4020,7 +4020,7 @@ static const struct pptable_funcs smu_v13_0_6_ppt_funcs = {
        /* dpm/clk tables */
        .set_default_dpm_table = smu_v13_0_6_set_default_dpm_table,
        .populate_umd_state_clk = smu_v13_0_6_populate_umd_state_clk,
-       .print_clk_levels = smu_v13_0_6_print_clk_levels,
+       .emit_clk_levels = smu_v13_0_6_emit_clk_levels,
        .force_clk_levels = smu_v13_0_6_force_clk_levels,
        .read_sensor = smu_v13_0_6_read_sensor,
        .set_performance_level = smu_v13_0_6_set_performance_level,