Commit cdfdec6f authored by Ilya Zlobintsev's avatar Ilya Zlobintsev Committed by Alex Deucher
Browse files

drm/amd/pm: Avoid writing nulls into `pp_od_clk_voltage`



Calling `smu_cmn_get_sysfs_buf` aligns the
offset used by `sysfs_emit_at` to the current page boundary, which was
previously directly returned from the various `print_clk_levels`
implementations to be added to the buffer position.
Instead, only the relative offset showing how much was written
to the buffer should be returned, regardless of how it was changed
for alignment purposes.

Reviewed-by: default avatarLijo Lazar <lijo.lazar@amd.com>
Signed-off-by: default avatarIlya Zlobintsev <ilya.zlobintsev@gmail.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 8c62f75c
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -291,11 +291,12 @@ static int cyan_skillfish_print_clk_levels(struct smu_context *smu,
					enum smu_clk_type clk_type,
					char *buf)
{
	int ret = 0, size = 0;
	int ret = 0, size = 0, start_offset = 0;
	uint32_t cur_value = 0;
	int i;

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

	switch (clk_type) {
	case SMU_OD_SCLK:
@@ -353,7 +354,7 @@ static int cyan_skillfish_print_clk_levels(struct smu_context *smu,
		return ret;
	}

	return size;
	return size - start_offset;
}

static bool cyan_skillfish_is_dpm_running(struct smu_context *smu)
+8 −7
Original line number Diff line number Diff line
@@ -1469,7 +1469,7 @@ static int navi10_print_clk_levels(struct smu_context *smu,
			enum smu_clk_type clk_type, char *buf)
{
	uint16_t *curve_settings;
	int i, levels, size = 0, ret = 0;
	int i, levels, size = 0, ret = 0, start_offset = 0;
	uint32_t cur_value = 0, value = 0, count = 0;
	uint32_t freq_values[3] = {0};
	uint32_t mark_index = 0;
@@ -1484,6 +1484,7 @@ static int navi10_print_clk_levels(struct smu_context *smu,
	uint32_t min_value, max_value;

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

	switch (clk_type) {
	case SMU_GFXCLK:
@@ -1497,11 +1498,11 @@ static int navi10_print_clk_levels(struct smu_context *smu,
	case SMU_DCEFCLK:
		ret = navi10_get_current_clk_freq_by_table(smu, clk_type, &cur_value);
		if (ret)
			return size;
			return size - start_offset;

		ret = smu_v11_0_get_dpm_level_count(smu, clk_type, &count);
		if (ret)
			return size;
			return size - start_offset;

		ret = navi10_is_support_fine_grained_dpm(smu, clk_type);
		if (ret < 0)
@@ -1511,7 +1512,7 @@ static int navi10_print_clk_levels(struct smu_context *smu,
			for (i = 0; i < count; i++) {
				ret = smu_v11_0_get_dpm_freq_by_index(smu, clk_type, i, &value);
				if (ret)
					return size;
					return size - start_offset;

				size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", i, value,
						cur_value == value ? "*" : "");
@@ -1519,10 +1520,10 @@ static int navi10_print_clk_levels(struct smu_context *smu,
		} else {
			ret = smu_v11_0_get_dpm_freq_by_index(smu, clk_type, 0, &freq_values[0]);
			if (ret)
				return size;
				return size - start_offset;
			ret = smu_v11_0_get_dpm_freq_by_index(smu, clk_type, count - 1, &freq_values[2]);
			if (ret)
				return size;
				return size - start_offset;

			freq_values[1] = cur_value;
			mark_index = cur_value == freq_values[0] ? 0 :
@@ -1653,7 +1654,7 @@ static int navi10_print_clk_levels(struct smu_context *smu,
		break;
	}

	return size;
	return size - start_offset;
}

static int navi10_force_clk_levels(struct smu_context *smu,
+3 −2
Original line number Diff line number Diff line
@@ -1281,7 +1281,7 @@ static int sienna_cichlid_print_clk_levels(struct smu_context *smu,
	struct smu_11_0_7_overdrive_table *od_settings = smu->od_settings;
	OverDriveTable_t *od_table =
		(OverDriveTable_t *)table_context->overdrive_table;
	int i, size = 0, ret = 0;
	int i, size = 0, ret = 0, start_offset = 0;
	uint32_t cur_value = 0, value = 0, count = 0;
	uint32_t freq_values[3] = {0};
	uint32_t mark_index = 0;
@@ -1289,6 +1289,7 @@ static int sienna_cichlid_print_clk_levels(struct smu_context *smu,
	uint32_t min_value, max_value;

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

	switch (clk_type) {
	case SMU_GFXCLK:
@@ -1434,7 +1435,7 @@ static int sienna_cichlid_print_clk_levels(struct smu_context *smu,
	}

print_clk_out:
	return size;
	return size - start_offset;
}

static int sienna_cichlid_force_clk_levels(struct smu_context *smu,
+6 −4
Original line number Diff line number Diff line
@@ -565,7 +565,7 @@ static int vangogh_print_legacy_clk_levels(struct smu_context *smu,
	DpmClocks_t *clk_table = smu->smu_table.clocks_table;
	SmuMetrics_legacy_t metrics;
	struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm);
	int i, idx, size = 0, ret = 0;
	int i, idx, size = 0, ret = 0, start_offset = 0;
	uint32_t cur_value = 0, value = 0, count = 0;
	bool cur_value_match_level = false;

@@ -576,6 +576,7 @@ static int vangogh_print_legacy_clk_levels(struct smu_context *smu,
		return ret;

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

	switch (clk_type) {
	case SMU_OD_SCLK:
@@ -658,7 +659,7 @@ static int vangogh_print_legacy_clk_levels(struct smu_context *smu,
		break;
	}

	return size;
	return size - start_offset;
}

static int vangogh_print_clk_levels(struct smu_context *smu,
@@ -666,7 +667,7 @@ static int vangogh_print_clk_levels(struct smu_context *smu,
{
	DpmClocks_t *clk_table = smu->smu_table.clocks_table;
	SmuMetrics_t metrics;
	int i, idx, size = 0, ret = 0;
	int i, idx, size = 0, ret = 0, start_offset = 0;
	uint32_t cur_value = 0, value = 0, count = 0;
	bool cur_value_match_level = false;
	uint32_t min, max;
@@ -678,6 +679,7 @@ static int vangogh_print_clk_levels(struct smu_context *smu,
		return ret;

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

	switch (clk_type) {
	case SMU_OD_SCLK:
@@ -779,7 +781,7 @@ static int vangogh_print_clk_levels(struct smu_context *smu,
		break;
	}

	return size;
	return size - start_offset;
}

static int vangogh_common_print_clk_levels(struct smu_context *smu,
+4 −3
Original line number Diff line number Diff line
@@ -494,7 +494,7 @@ static int renoir_set_fine_grain_gfx_freq_parameters(struct smu_context *smu)
static int renoir_print_clk_levels(struct smu_context *smu,
			enum smu_clk_type clk_type, char *buf)
{
	int i, idx, size = 0, ret = 0;
	int i, idx, size = 0, ret = 0, start_offset = 0;
	uint32_t cur_value = 0, value = 0, count = 0, min = 0, max = 0;
	SmuMetrics_t metrics;
	bool cur_value_match_level = false;
@@ -506,6 +506,7 @@ static int renoir_print_clk_levels(struct smu_context *smu,
		return ret;

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

	switch (clk_type) {
	case SMU_OD_RANGE:
@@ -550,7 +551,7 @@ static int renoir_print_clk_levels(struct smu_context *smu,
			size += sysfs_emit_at(buf, size, "2: %uMhz %s\n", max,
					i == 2 ? "*" : "");
		}
		return size;
		return size - start_offset;
	case SMU_SOCCLK:
		count = NUM_SOCCLK_DPM_LEVELS;
		cur_value = metrics.ClockFrequency[CLOCK_SOCCLK];
@@ -607,7 +608,7 @@ static int renoir_print_clk_levels(struct smu_context *smu,
		break;
	}

	return size;
	return size - start_offset;
}

static enum amd_pm_state_type renoir_get_current_power_state(struct smu_context *smu)
Loading