summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarren Powell <darren.powell@amd.com>2023-04-04 00:14:27 -0400
committerAlex Deucher <alexander.deucher@amd.com>2023-09-06 14:34:05 -0400
commit14bf1c475f7fa1d6627746e7940d65d5456ab2b7 (patch)
treed54ab095c04558a81d95dd1a2f6651b14d461671
parentd62846f778f5dc4c521c4b1532ecf3f2d7fd78d9 (diff)
amdgpu/pm: Optimize emit_clock_levels for aldebaran - part 3
split switch statement into two and consolidate the common code for printing most of the types of clock speeds Signed-off-by: Darren Powell <darren.powell@amd.com> Reviewed-by: Lijo Lazar <lijo.lazar@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c82
1 files changed, 27 insertions, 55 deletions
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c
index 5582caef834a..23820204efd7 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c
@@ -788,17 +788,6 @@ static int aldebaran_emit_clk_levels(struct smu_context *smu,
freq_values[2] = max_clk;
freq_values[1] = cur_value;
}
-
- for (i = 0; i < display_levels; i++) {
- clock_mhz = freq_values[i];
- freq_match = aldebaran_freqs_in_same_level(clock_mhz, cur_value);
- freq_match |= (display_levels == 1);
-
- *offset += sysfs_emit_at(buf, *offset, "%d: %uMhz %s\n", i,
- clock_mhz,
- (freq_match) ? "*" : "");
- }
-
break;
case SMU_OD_MCLK:
@@ -813,16 +802,6 @@ static int aldebaran_emit_clk_levels(struct smu_context *smu,
single_dpm_table = &(dpm_context->dpm_tables.uclk_table);
aldebaran_get_clk_table(smu, &clocks, single_dpm_table);
-
- for (i = 0; i < clocks.num_levels; i++) {
- clock_mhz = clocks.data[i].clocks_in_khz / 1000;
- freq_match = aldebaran_freqs_in_same_level(clock_mhz, cur_value);
- freq_match |= (clocks.num_levels == 1);
-
- *offset += sysfs_emit_at(buf, *offset, "%d: %uMhz %s\n",
- i, clock_mhz,
- (freq_match) ? "*" : "");
- }
break;
case SMU_SOCCLK:
@@ -834,16 +813,6 @@ static int aldebaran_emit_clk_levels(struct smu_context *smu,
single_dpm_table = &(dpm_context->dpm_tables.soc_table);
aldebaran_get_clk_table(smu, &clocks, single_dpm_table);
-
- for (i = 0; i < clocks.num_levels; i++) {
- clock_mhz = clocks.data[i].clocks_in_khz / 1000;
- freq_match = aldebaran_freqs_in_same_level(clock_mhz, cur_value);
- freq_match |= (clocks.num_levels == 1);
-
- *offset += sysfs_emit_at(buf, *offset, "%d: %uMhz %s\n",
- i, clock_mhz,
- (freq_match) ? "*" : "");
- }
break;
case SMU_FCLK:
@@ -855,16 +824,6 @@ static int aldebaran_emit_clk_levels(struct smu_context *smu,
single_dpm_table = &(dpm_context->dpm_tables.fclk_table);
aldebaran_get_clk_table(smu, &clocks, single_dpm_table);
-
- for (i = 0; i < clocks.num_levels; i++) {
- clock_mhz = clocks.data[i].clocks_in_khz / 1000;
- freq_match = aldebaran_freqs_in_same_level(clock_mhz, cur_value);
- freq_match |= (clocks.num_levels == 1);
-
- *offset += sysfs_emit_at(buf, *offset, "%d: %uMhz %s\n",
- i, clock_mhz,
- (freq_match) ? "*" : "");
- }
break;
case SMU_VCLK:
@@ -876,16 +835,6 @@ static int aldebaran_emit_clk_levels(struct smu_context *smu,
single_dpm_table = &(dpm_context->dpm_tables.vclk_table);
aldebaran_get_clk_table(smu, &clocks, single_dpm_table);
-
- for (i = 0; i < clocks.num_levels; i++) {
- clock_mhz = clocks.data[i].clocks_in_khz / 1000;
- freq_match = aldebaran_freqs_in_same_level(clock_mhz, cur_value);
- freq_match |= (clocks.num_levels == 1);
-
- *offset += sysfs_emit_at(buf, *offset, "%d: %uMhz %s\n",
- i, clock_mhz,
- (freq_match) ? "*" : "");
- }
break;
case SMU_DCLK:
@@ -897,21 +846,44 @@ static int aldebaran_emit_clk_levels(struct smu_context *smu,
single_dpm_table = &(dpm_context->dpm_tables.dclk_table);
aldebaran_get_clk_table(smu, &clocks, single_dpm_table);
+ break;
+
+ default:
+ return -EINVAL;
+ }
+ switch (type) {
+ case SMU_OD_SCLK:
+ case SMU_SCLK:
+ for (i = 0; i < display_levels; i++) {
+ clock_mhz = freq_values[i];
+ freq_match = aldebaran_freqs_in_same_level(clock_mhz, cur_value);
+ freq_match |= (display_levels == 1);
+
+ *offset += sysfs_emit_at(buf, *offset, "%d: %uMhz %s\n", i,
+ clock_mhz,
+ (freq_match) ? "*" : "");
+ }
+ break;
+
+ case SMU_OD_MCLK:
+ case SMU_MCLK:
+ case SMU_SOCCLK:
+ case SMU_FCLK:
+ case SMU_VCLK:
+ case SMU_DCLK:
for (i = 0; i < clocks.num_levels; i++) {
clock_mhz = clocks.data[i].clocks_in_khz / 1000;
freq_match = aldebaran_freqs_in_same_level(clock_mhz, cur_value);
freq_match |= (clocks.num_levels == 1);
*offset += sysfs_emit_at(buf, *offset, "%d: %uMhz %s\n",
- i, clock_mhz,
- (freq_match) ? "*" : "");
+ i, clock_mhz,
+ (freq_match) ? "*" : "");
}
break;
-
default:
return -EINVAL;
- break;
}
return 0;