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

amdgpu/pm: Replace print_clock_levels with emit_clock_levels for aldebaran

Replace print_clock_levels with emit_clock_levels for aldebaran
  * replace .print_clk_levels with .emit_clk_levels in aldebaran_ppt_funcs
  * added extra parameter int *offset
  * removed var size, uses arg *offset instead
  * removed call to smu_cmn_get_sysfs_buf
  * errors are returned to caller
  * returns 0 on success
additional incidental changes
  * changed type of vars i, now to remove comparing mismatch types
  * renamed var s/now/cur_value/
  * switch statement default now returns -EINVAL
  * RAS Recovery returns -EBUSY

Based on
  commit b06b48d7 ("amdgpu/pm: Implement emit_clk_levels for navi10")
Signed-off-by: default avatarDarren Powell <darren.powell@amd.com>
Reviewed-by: default avatarLijo Lazar <lijo.lazar@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 869df143
...@@ -736,25 +736,23 @@ static int aldebaran_get_current_clk_freq_by_table(struct smu_context *smu, ...@@ -736,25 +736,23 @@ static int aldebaran_get_current_clk_freq_by_table(struct smu_context *smu,
value); value);
} }
static int aldebaran_print_clk_levels(struct smu_context *smu, static int aldebaran_emit_clk_levels(struct smu_context *smu,
enum smu_clk_type type, char *buf) enum smu_clk_type type, char *buf, int *offset)
{ {
int i, now, size = 0;
int ret = 0; int ret = 0;
struct smu_umd_pstate_table *pstate_table = &smu->pstate_table; struct smu_umd_pstate_table *pstate_table = &smu->pstate_table;
struct pp_clock_levels_with_latency clocks; struct pp_clock_levels_with_latency clocks;
struct smu_13_0_dpm_table *single_dpm_table; struct smu_13_0_dpm_table *single_dpm_table;
struct smu_dpm_context *smu_dpm = &smu->smu_dpm; struct smu_dpm_context *smu_dpm = &smu->smu_dpm;
struct smu_13_0_dpm_context *dpm_context = NULL; struct smu_13_0_dpm_context *dpm_context = NULL;
uint32_t i;
int display_levels; int display_levels;
uint32_t freq_values[3] = {0}; uint32_t freq_values[3] = {0};
uint32_t min_clk, max_clk; uint32_t min_clk, max_clk, cur_value = 0;
smu_cmn_get_sysfs_buf(&buf, &size);
if (amdgpu_ras_intr_triggered()) { if (amdgpu_ras_intr_triggered()) {
size += sysfs_emit_at(buf, size, "unavailable\n"); *offset += sysfs_emit_at(buf, *offset, "unavailable\n");
return size; return -EBUSY;
} }
dpm_context = smu_dpm->dpm_context; dpm_context = smu_dpm->dpm_context;
...@@ -762,10 +760,10 @@ static int aldebaran_print_clk_levels(struct smu_context *smu, ...@@ -762,10 +760,10 @@ static int aldebaran_print_clk_levels(struct smu_context *smu,
switch (type) { switch (type) {
case SMU_OD_SCLK: case SMU_OD_SCLK:
size += sysfs_emit_at(buf, size, "%s:\n", "GFXCLK"); *offset += sysfs_emit_at(buf, *offset, "%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, &cur_value);
if (ret) { if (ret) {
dev_err(smu->adev->dev, "Attempt to get current gfx clk Failed!"); dev_err(smu->adev->dev, "Attempt to get current gfx clk Failed!");
return ret; return ret;
...@@ -787,29 +785,29 @@ static int aldebaran_print_clk_levels(struct smu_context *smu, ...@@ -787,29 +785,29 @@ static int aldebaran_print_clk_levels(struct smu_context *smu,
freq_values[1] = max_clk; freq_values[1] = max_clk;
/* fine-grained dpm has only 2 levels */ /* fine-grained dpm has only 2 levels */
if (now > min_clk && now < max_clk) { if (cur_value > min_clk && cur_value < max_clk) {
display_levels++; display_levels++;
freq_values[2] = max_clk; freq_values[2] = max_clk;
freq_values[1] = now; freq_values[1] = cur_value;
} }
for (i = 0; i < display_levels; i++) for (i = 0; i < display_levels; i++)
size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", i, *offset += sysfs_emit_at(buf, *offset, "%d: %uMhz %s\n", i,
freq_values[i], freq_values[i],
(display_levels == 1) ? (display_levels == 1) ?
"*" : "*" :
(aldebaran_freqs_in_same_level( (aldebaran_freqs_in_same_level(
freq_values[i], now) ? freq_values[i], cur_value) ?
"*" : "*" :
"")); ""));
break; break;
case SMU_OD_MCLK: case SMU_OD_MCLK:
size += sysfs_emit_at(buf, size, "%s:\n", "MCLK"); *offset += sysfs_emit_at(buf, *offset, "%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, &cur_value);
if (ret) { if (ret) {
dev_err(smu->adev->dev, "Attempt to get current mclk Failed!"); dev_err(smu->adev->dev, "Attempt to get current mclk Failed!");
return ret; return ret;
...@@ -823,16 +821,16 @@ static int aldebaran_print_clk_levels(struct smu_context *smu, ...@@ -823,16 +821,16 @@ 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 += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", *offset += sysfs_emit_at(buf, *offset, "%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(
clocks.data[i].clocks_in_khz / 1000, clocks.data[i].clocks_in_khz / 1000,
now) ? "*" : "")); cur_value) ? "*" : ""));
break; break;
case SMU_SOCCLK: case SMU_SOCCLK:
ret = aldebaran_get_current_clk_freq_by_table(smu, SMU_SOCCLK, &now); ret = aldebaran_get_current_clk_freq_by_table(smu, SMU_SOCCLK, &cur_value);
if (ret) { if (ret) {
dev_err(smu->adev->dev, "Attempt to get current socclk Failed!"); dev_err(smu->adev->dev, "Attempt to get current socclk Failed!");
return ret; return ret;
...@@ -846,16 +844,16 @@ static int aldebaran_print_clk_levels(struct smu_context *smu, ...@@ -846,16 +844,16 @@ 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 += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", *offset += sysfs_emit_at(buf, *offset, "%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(
clocks.data[i].clocks_in_khz / 1000, clocks.data[i].clocks_in_khz / 1000,
now) ? "*" : "")); cur_value) ? "*" : ""));
break; break;
case SMU_FCLK: case SMU_FCLK:
ret = aldebaran_get_current_clk_freq_by_table(smu, SMU_FCLK, &now); ret = aldebaran_get_current_clk_freq_by_table(smu, SMU_FCLK, &cur_value);
if (ret) { if (ret) {
dev_err(smu->adev->dev, "Attempt to get current fclk Failed!"); dev_err(smu->adev->dev, "Attempt to get current fclk Failed!");
return ret; return ret;
...@@ -869,16 +867,16 @@ static int aldebaran_print_clk_levels(struct smu_context *smu, ...@@ -869,16 +867,16 @@ 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 += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", *offset += sysfs_emit_at(buf, *offset, "%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(
clocks.data[i].clocks_in_khz / 1000, clocks.data[i].clocks_in_khz / 1000,
now) ? "*" : "")); cur_value) ? "*" : ""));
break; break;
case SMU_VCLK: case SMU_VCLK:
ret = aldebaran_get_current_clk_freq_by_table(smu, SMU_VCLK, &now); ret = aldebaran_get_current_clk_freq_by_table(smu, SMU_VCLK, &cur_value);
if (ret) { if (ret) {
dev_err(smu->adev->dev, "Attempt to get current vclk Failed!"); dev_err(smu->adev->dev, "Attempt to get current vclk Failed!");
return ret; return ret;
...@@ -892,16 +890,16 @@ static int aldebaran_print_clk_levels(struct smu_context *smu, ...@@ -892,16 +890,16 @@ 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 += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", *offset += sysfs_emit_at(buf, *offset, "%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(
clocks.data[i].clocks_in_khz / 1000, clocks.data[i].clocks_in_khz / 1000,
now) ? "*" : "")); cur_value) ? "*" : ""));
break; break;
case SMU_DCLK: case SMU_DCLK:
ret = aldebaran_get_current_clk_freq_by_table(smu, SMU_DCLK, &now); ret = aldebaran_get_current_clk_freq_by_table(smu, SMU_DCLK, &cur_value);
if (ret) { if (ret) {
dev_err(smu->adev->dev, "Attempt to get current dclk Failed!"); dev_err(smu->adev->dev, "Attempt to get current dclk Failed!");
return ret; return ret;
...@@ -915,19 +913,20 @@ static int aldebaran_print_clk_levels(struct smu_context *smu, ...@@ -915,19 +913,20 @@ 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 += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", *offset += sysfs_emit_at(buf, *offset, "%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(
clocks.data[i].clocks_in_khz / 1000, clocks.data[i].clocks_in_khz / 1000,
now) ? "*" : "")); cur_value) ? "*" : ""));
break; break;
default: default:
return -EINVAL;
break; break;
} }
return size; return 0;
} }
static int aldebaran_upload_dpm_level(struct smu_context *smu, static int aldebaran_upload_dpm_level(struct smu_context *smu,
...@@ -2071,7 +2070,7 @@ static const struct pptable_funcs aldebaran_ppt_funcs = { ...@@ -2071,7 +2070,7 @@ static const struct pptable_funcs aldebaran_ppt_funcs = {
.set_default_dpm_table = aldebaran_set_default_dpm_table, .set_default_dpm_table = aldebaran_set_default_dpm_table,
.populate_umd_state_clk = aldebaran_populate_umd_state_clk, .populate_umd_state_clk = aldebaran_populate_umd_state_clk,
.get_thermal_temperature_range = aldebaran_get_thermal_temperature_range, .get_thermal_temperature_range = aldebaran_get_thermal_temperature_range,
.print_clk_levels = aldebaran_print_clk_levels, .emit_clk_levels = aldebaran_emit_clk_levels,
.force_clk_levels = aldebaran_force_clk_levels, .force_clk_levels = aldebaran_force_clk_levels,
.read_sensor = aldebaran_read_sensor, .read_sensor = aldebaran_read_sensor,
.set_performance_level = aldebaran_set_performance_level, .set_performance_level = aldebaran_set_performance_level,
......
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