[PATCH 7/8] amdgpu/pm: Optimize emit_clock_levels for aldebaran - part 2
Darren Powell
darren.powell at amd.com
Thu Apr 27 06:27:17 UTC 2023
Use variables to remove ternary expression in print statement
and improve readability. This will help to optimize the code
duplication in the switch statement
Also Changed:
replaced single_dpm_table->count as iterator in for loops
with safer clocks_num_levels value
replaced dpm_table.value usage with local var clocks_mhz
Signed-off-by: Darren Powell <darren.powell at amd.com>
---
.../drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 27 +++++++++----------
1 file changed, 13 insertions(+), 14 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 75833bc3d4c4..b315353adfdf 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c
@@ -792,12 +792,11 @@ static int aldebaran_emit_clk_levels(struct smu_context *smu,
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,
- (display_levels == 1) ?
- "*" :
- (freq_match) ? "*" : "");
+ (freq_match) ? "*" : "");
}
break;
@@ -818,10 +817,10 @@ static int aldebaran_emit_clk_levels(struct smu_context *smu,
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,
- (clocks.num_levels == 1) ? "*" :
(freq_match) ? "*" : "");
}
break;
@@ -839,10 +838,10 @@ static int aldebaran_emit_clk_levels(struct smu_context *smu,
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,
- (clocks.num_levels == 1) ? "*" :
(freq_match) ? "*" : "");
}
break;
@@ -857,13 +856,13 @@ 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 < single_dpm_table->count; i++) {
+ 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, single_dpm_table->dpm_levels[i].value,
- (clocks.num_levels == 1) ? "*" :
+ i, clock_mhz,
(freq_match) ? "*" : "");
}
break;
@@ -878,13 +877,13 @@ 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 < single_dpm_table->count; i++) {
+ 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, single_dpm_table->dpm_levels[i].value,
- (clocks.num_levels == 1) ? "*" :
+ i, clock_mhz,
(freq_match) ? "*" : "");
}
break;
@@ -899,13 +898,13 @@ 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);
- for (i = 0; i < single_dpm_table->count; i++) {
+ 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, single_dpm_table->dpm_levels[i].value,
- (clocks.num_levels == 1) ? "*" :
+ i, clock_mhz,
(freq_match) ? "*" : "");
}
break;
--
2.34.1
More information about the amd-gfx
mailing list