Commit e738c2f0 authored by Darren Powell's avatar Darren Powell Committed by Alex Deucher

amdgpu/pm: Replace smu12/13 usage of sprintf with sysfs_emit

 initial modification of files
  renoir_ppt.c
  aldebaran_ppt.c
  yellow_carp_ppt.c

=== Test ===
AMDGPU_PCI_ADDR=`lspci -nn | grep "VGA\|Display" | cut -d " " -f 1`
AMDGPU_HWMON=`ls -la /sys/class/hwmon | grep $AMDGPU_PCI_ADDR | awk '{print $9}'`
HWMON_DIR=/sys/class/hwmon/${AMDGPU_HWMON}
LOGFILE=pp_printf.test.log

lspci -nn | grep "VGA\|Display"  > $LOGFILE
FILES="pp_dpm_sclk
pp_power_profile_mode "

for f in $FILES
do
  echo === $f === >> $LOGFILE
  cat $HWMON_DIR/device/$f >> $LOGFILE
done
cat $LOGFILE
Signed-off-by: default avatarDarren Powell <darren.powell@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent fe14c285
...@@ -510,16 +510,16 @@ static int renoir_print_clk_levels(struct smu_context *smu, ...@@ -510,16 +510,16 @@ static int renoir_print_clk_levels(struct smu_context *smu,
0, &max); 0, &max);
if (ret) if (ret)
return ret; return ret;
size += sprintf(buf + size, "OD_RANGE\nSCLK: %10uMhz %10uMhz\n", min, max); size += sysfs_emit_at(buf, size, "OD_RANGE\nSCLK: %10uMhz %10uMhz\n", min, max);
} }
break; break;
case SMU_OD_SCLK: case SMU_OD_SCLK:
if (smu_dpm_ctx->dpm_level == AMD_DPM_FORCED_LEVEL_MANUAL) { if (smu_dpm_ctx->dpm_level == AMD_DPM_FORCED_LEVEL_MANUAL) {
min = (smu->gfx_actual_hard_min_freq > 0) ? smu->gfx_actual_hard_min_freq : smu->gfx_default_hard_min_freq; min = (smu->gfx_actual_hard_min_freq > 0) ? smu->gfx_actual_hard_min_freq : smu->gfx_default_hard_min_freq;
max = (smu->gfx_actual_soft_max_freq > 0) ? smu->gfx_actual_soft_max_freq : smu->gfx_default_soft_max_freq; max = (smu->gfx_actual_soft_max_freq > 0) ? smu->gfx_actual_soft_max_freq : smu->gfx_default_soft_max_freq;
size += sprintf(buf + size, "OD_SCLK\n"); size += sysfs_emit_at(buf, size, "OD_SCLK\n");
size += sprintf(buf + size, "0:%10uMhz\n", min); size += sysfs_emit_at(buf, size, "0:%10uMhz\n", min);
size += sprintf(buf + size, "1:%10uMhz\n", max); size += sysfs_emit_at(buf, size, "1:%10uMhz\n", max);
} }
break; break;
case SMU_GFXCLK: case SMU_GFXCLK:
...@@ -536,12 +536,12 @@ static int renoir_print_clk_levels(struct smu_context *smu, ...@@ -536,12 +536,12 @@ static int renoir_print_clk_levels(struct smu_context *smu,
else else
i = 1; i = 1;
size += sprintf(buf + size, "0: %uMhz %s\n", min, size += sysfs_emit_at(buf, size, "0: %uMhz %s\n", min,
i == 0 ? "*" : ""); i == 0 ? "*" : "");
size += sprintf(buf + size, "1: %uMhz %s\n", size += sysfs_emit_at(buf, size, "1: %uMhz %s\n",
i == 1 ? cur_value : RENOIR_UMD_PSTATE_GFXCLK, i == 1 ? cur_value : RENOIR_UMD_PSTATE_GFXCLK,
i == 1 ? "*" : ""); i == 1 ? "*" : "");
size += sprintf(buf + size, "2: %uMhz %s\n", max, size += sysfs_emit_at(buf, size, "2: %uMhz %s\n", max,
i == 2 ? "*" : ""); i == 2 ? "*" : "");
} }
return size; return size;
...@@ -588,14 +588,14 @@ static int renoir_print_clk_levels(struct smu_context *smu, ...@@ -588,14 +588,14 @@ static int renoir_print_clk_levels(struct smu_context *smu,
return ret; return ret;
if (!value) if (!value)
continue; continue;
size += sprintf(buf + size, "%d: %uMhz %s\n", i, value, size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", i, value,
cur_value == value ? "*" : ""); cur_value == value ? "*" : "");
if (cur_value == value) if (cur_value == value)
cur_value_match_level = true; cur_value_match_level = true;
} }
if (!cur_value_match_level) if (!cur_value_match_level)
size += sprintf(buf + size, " %uMhz *\n", cur_value); size += sysfs_emit_at(buf, size, " %uMhz *\n", cur_value);
break; break;
default: default:
...@@ -1118,7 +1118,7 @@ static int renoir_get_power_profile_mode(struct smu_context *smu, ...@@ -1118,7 +1118,7 @@ static int renoir_get_power_profile_mode(struct smu_context *smu,
if (workload_type < 0) if (workload_type < 0)
continue; continue;
size += sprintf(buf + size, "%2d %14s%s\n", size += sysfs_emit_at(buf, size, "%2d %14s%s\n",
i, profile_name[i], (i == smu->power_profile_mode) ? "*" : " "); i, profile_name[i], (i == smu->power_profile_mode) ? "*" : " ");
} }
......
...@@ -735,14 +735,14 @@ static int aldebaran_print_clk_levels(struct smu_context *smu, ...@@ -735,14 +735,14 @@ static int aldebaran_print_clk_levels(struct smu_context *smu,
uint32_t min_clk, max_clk; uint32_t min_clk, max_clk;
if (amdgpu_ras_intr_triggered()) if (amdgpu_ras_intr_triggered())
return snprintf(buf, PAGE_SIZE, "unavailable\n"); return sysfs_emit(buf, "unavailable\n");
dpm_context = smu_dpm->dpm_context; dpm_context = smu_dpm->dpm_context;
switch (type) { switch (type) {
case SMU_OD_SCLK: case SMU_OD_SCLK:
size = sprintf(buf, "%s:\n", "GFXCLK"); size = sysfs_emit(buf, "%s:\n", "GFXCLK");
fallthrough; fallthrough;
case SMU_SCLK: case SMU_SCLK:
ret = aldebaran_get_current_clk_freq_by_table(smu, SMU_GFXCLK, &now); ret = aldebaran_get_current_clk_freq_by_table(smu, SMU_GFXCLK, &now);
...@@ -779,8 +779,7 @@ static int aldebaran_print_clk_levels(struct smu_context *smu, ...@@ -779,8 +779,7 @@ static int aldebaran_print_clk_levels(struct smu_context *smu,
*/ */
if (display_levels == clocks.num_levels) { if (display_levels == clocks.num_levels) {
for (i = 0; i < clocks.num_levels; i++) for (i = 0; i < clocks.num_levels; i++)
size += sprintf( size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", i,
buf + size, "%d: %uMhz %s\n", i,
freq_values[i], freq_values[i],
(clocks.num_levels == 1) ? (clocks.num_levels == 1) ?
"*" : "*" :
...@@ -790,14 +789,14 @@ static int aldebaran_print_clk_levels(struct smu_context *smu, ...@@ -790,14 +789,14 @@ static int aldebaran_print_clk_levels(struct smu_context *smu,
"")); ""));
} else { } else {
for (i = 0; i < display_levels; i++) for (i = 0; i < display_levels; i++)
size += sprintf(buf + size, "%d: %uMhz %s\n", i, size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", i,
freq_values[i], i == 1 ? "*" : ""); freq_values[i], i == 1 ? "*" : "");
} }
break; break;
case SMU_OD_MCLK: case SMU_OD_MCLK:
size = sprintf(buf, "%s:\n", "MCLK"); size = sysfs_emit(buf, "%s:\n", "MCLK");
fallthrough; fallthrough;
case SMU_MCLK: case SMU_MCLK:
ret = aldebaran_get_current_clk_freq_by_table(smu, SMU_UCLK, &now); ret = aldebaran_get_current_clk_freq_by_table(smu, SMU_UCLK, &now);
...@@ -814,7 +813,7 @@ static int aldebaran_print_clk_levels(struct smu_context *smu, ...@@ -814,7 +813,7 @@ static int aldebaran_print_clk_levels(struct smu_context *smu,
} }
for (i = 0; i < clocks.num_levels; i++) for (i = 0; i < clocks.num_levels; i++)
size += sprintf(buf + size, "%d: %uMhz %s\n", size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n",
i, clocks.data[i].clocks_in_khz / 1000, i, clocks.data[i].clocks_in_khz / 1000,
(clocks.num_levels == 1) ? "*" : (clocks.num_levels == 1) ? "*" :
(aldebaran_freqs_in_same_level( (aldebaran_freqs_in_same_level(
...@@ -837,7 +836,7 @@ static int aldebaran_print_clk_levels(struct smu_context *smu, ...@@ -837,7 +836,7 @@ static int aldebaran_print_clk_levels(struct smu_context *smu,
} }
for (i = 0; i < clocks.num_levels; i++) for (i = 0; i < clocks.num_levels; i++)
size += sprintf(buf + size, "%d: %uMhz %s\n", size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n",
i, clocks.data[i].clocks_in_khz / 1000, i, clocks.data[i].clocks_in_khz / 1000,
(clocks.num_levels == 1) ? "*" : (clocks.num_levels == 1) ? "*" :
(aldebaran_freqs_in_same_level( (aldebaran_freqs_in_same_level(
...@@ -860,7 +859,7 @@ static int aldebaran_print_clk_levels(struct smu_context *smu, ...@@ -860,7 +859,7 @@ static int aldebaran_print_clk_levels(struct smu_context *smu,
} }
for (i = 0; i < single_dpm_table->count; i++) for (i = 0; i < single_dpm_table->count; i++)
size += sprintf(buf + size, "%d: %uMhz %s\n", size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n",
i, single_dpm_table->dpm_levels[i].value, i, single_dpm_table->dpm_levels[i].value,
(clocks.num_levels == 1) ? "*" : (clocks.num_levels == 1) ? "*" :
(aldebaran_freqs_in_same_level( (aldebaran_freqs_in_same_level(
...@@ -883,7 +882,7 @@ static int aldebaran_print_clk_levels(struct smu_context *smu, ...@@ -883,7 +882,7 @@ static int aldebaran_print_clk_levels(struct smu_context *smu,
} }
for (i = 0; i < single_dpm_table->count; i++) for (i = 0; i < single_dpm_table->count; i++)
size += sprintf(buf + size, "%d: %uMhz %s\n", size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n",
i, single_dpm_table->dpm_levels[i].value, i, single_dpm_table->dpm_levels[i].value,
(clocks.num_levels == 1) ? "*" : (clocks.num_levels == 1) ? "*" :
(aldebaran_freqs_in_same_level( (aldebaran_freqs_in_same_level(
...@@ -906,7 +905,7 @@ static int aldebaran_print_clk_levels(struct smu_context *smu, ...@@ -906,7 +905,7 @@ static int aldebaran_print_clk_levels(struct smu_context *smu,
} }
for (i = 0; i < single_dpm_table->count; i++) for (i = 0; i < single_dpm_table->count; i++)
size += sprintf(buf + size, "%d: %uMhz %s\n", size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n",
i, single_dpm_table->dpm_levels[i].value, i, single_dpm_table->dpm_levels[i].value,
(clocks.num_levels == 1) ? "*" : (clocks.num_levels == 1) ? "*" :
(aldebaran_freqs_in_same_level( (aldebaran_freqs_in_same_level(
......
...@@ -572,7 +572,7 @@ static int yellow_carp_get_power_profile_mode(struct smu_context *smu, ...@@ -572,7 +572,7 @@ static int yellow_carp_get_power_profile_mode(struct smu_context *smu,
if (workload_type < 0) if (workload_type < 0)
continue; continue;
size += sprintf(buf + size, "%2d %14s%s\n", size += sysfs_emit_at(buf, size, "%2d %14s%s\n",
i, profile_name[i], (i == smu->power_profile_mode) ? "*" : " "); i, profile_name[i], (i == smu->power_profile_mode) ? "*" : " ");
} }
...@@ -1054,15 +1054,15 @@ static int yellow_carp_print_clk_levels(struct smu_context *smu, ...@@ -1054,15 +1054,15 @@ static int yellow_carp_print_clk_levels(struct smu_context *smu,
switch (clk_type) { switch (clk_type) {
case SMU_OD_SCLK: case SMU_OD_SCLK:
size = sprintf(buf, "%s:\n", "OD_SCLK"); size = sysfs_emit(buf, "%s:\n", "OD_SCLK");
size += sprintf(buf + size, "0: %10uMhz\n", size += sysfs_emit_at(buf, size, "0: %10uMhz\n",
(smu->gfx_actual_hard_min_freq > 0) ? smu->gfx_actual_hard_min_freq : smu->gfx_default_hard_min_freq); (smu->gfx_actual_hard_min_freq > 0) ? smu->gfx_actual_hard_min_freq : smu->gfx_default_hard_min_freq);
size += sprintf(buf + size, "1: %10uMhz\n", size += sysfs_emit_at(buf, size, "1: %10uMhz\n",
(smu->gfx_actual_soft_max_freq > 0) ? smu->gfx_actual_soft_max_freq : smu->gfx_default_soft_max_freq); (smu->gfx_actual_soft_max_freq > 0) ? smu->gfx_actual_soft_max_freq : smu->gfx_default_soft_max_freq);
break; break;
case SMU_OD_RANGE: case SMU_OD_RANGE:
size = sprintf(buf, "%s:\n", "OD_RANGE"); size = sysfs_emit(buf, "%s:\n", "OD_RANGE");
size += sprintf(buf + size, "SCLK: %7uMhz %10uMhz\n", size += sysfs_emit_at(buf, size, "SCLK: %7uMhz %10uMhz\n",
smu->gfx_default_hard_min_freq, smu->gfx_default_soft_max_freq); smu->gfx_default_hard_min_freq, smu->gfx_default_soft_max_freq);
break; break;
case SMU_SOCCLK: case SMU_SOCCLK:
...@@ -1083,7 +1083,7 @@ static int yellow_carp_print_clk_levels(struct smu_context *smu, ...@@ -1083,7 +1083,7 @@ static int yellow_carp_print_clk_levels(struct smu_context *smu,
if (ret) if (ret)
goto print_clk_out; goto print_clk_out;
size += sprintf(buf + size, "%d: %uMhz %s\n", i, value, size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", i, value,
cur_value == value ? "*" : ""); cur_value == value ? "*" : "");
} }
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment