Commit b0e0503c authored by Lijo Lazar's avatar Lijo Lazar Committed by Alex Deucher
Browse files

drm/amd/pm: Use emit_clk_levels in SMUv14.0.0



Move to emit_clk_levels from print_clk_levels

Signed-off-by: default avatarLijo Lazar <lijo.lazar@amd.com>
Reviewed-by: default avatarHawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 5478777f
Loading
Loading
Loading
Loading
+12 −12
Original line number Diff line number Diff line
@@ -1129,16 +1129,14 @@ static int smu_v14_0_common_get_dpm_level_count(struct smu_context *smu,
	return 0;
}

static int smu_v14_0_0_print_clk_levels(struct smu_context *smu,
					enum smu_clk_type clk_type, char *buf)
static int smu_v14_0_0_emit_clk_levels(struct smu_context *smu,
				       enum smu_clk_type clk_type, char *buf,
				       int *offset)
{
	int i, idx, ret = 0, size = 0, start_offset = 0;
	int i, idx, ret = 0, size = *offset, start_offset = *offset;
	uint32_t cur_value = 0, value = 0, count = 0;
	uint32_t min, max;

	smu_cmn_get_sysfs_buf(&buf, &size);
	start_offset = size;

	switch (clk_type) {
	case SMU_OD_SCLK:
		size += sysfs_emit_at(buf, size, "%s:\n", "OD_SCLK");
@@ -1162,17 +1160,17 @@ static int smu_v14_0_0_print_clk_levels(struct smu_context *smu,
	case SMU_FCLK:
		ret = smu_v14_0_0_get_current_clk_freq(smu, clk_type, &cur_value);
		if (ret)
			break;
			return ret;

		ret = smu_v14_0_common_get_dpm_level_count(smu, clk_type, &count);
		if (ret)
			break;
			return ret;

		for (i = 0; i < count; i++) {
			idx = (clk_type == SMU_MCLK) ? (count - i - 1) : i;
			ret = smu_v14_0_common_get_dpm_freq_by_index(smu, clk_type, idx, &value);
			if (ret)
				break;
				return ret;

			size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", i, value,
					      cur_value == value ? "*" : "");
@@ -1182,7 +1180,7 @@ static int smu_v14_0_0_print_clk_levels(struct smu_context *smu,
	case SMU_SCLK:
		ret = smu_v14_0_0_get_current_clk_freq(smu, clk_type, &cur_value);
		if (ret)
			break;
			return ret;
		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;
		if (cur_value  == max)
@@ -1203,7 +1201,9 @@ static int smu_v14_0_0_print_clk_levels(struct smu_context *smu,
		break;
	}

	return size - start_offset;
	*offset += size - start_offset;

	return 0;
}

static int smu_v14_0_0_set_soft_freq_limited_range(struct smu_context *smu,
@@ -1689,7 +1689,7 @@ static const struct pptable_funcs smu_v14_0_0_ppt_funcs = {
	.get_dpm_ultimate_freq = smu_v14_0_common_get_dpm_ultimate_freq,
	.set_soft_freq_limited_range = smu_v14_0_0_set_soft_freq_limited_range,
	.od_edit_dpm_table = smu_v14_0_od_edit_dpm_table,
	.print_clk_levels = smu_v14_0_0_print_clk_levels,
	.emit_clk_levels = smu_v14_0_0_emit_clk_levels,
	.force_clk_levels = smu_v14_0_0_force_clk_levels,
	.set_performance_level = smu_v14_0_common_set_performance_level,
	.set_fine_grain_gfx_freq_parameters = smu_v14_0_common_set_fine_grain_gfx_freq_parameters,