Commit 4cb738ab authored by Evan Quan's avatar Evan Quan Committed by Alex Deucher
Browse files

drm/amd/powerplay: drop unused code around power limit



Drop unused APIs, variables and argument.

Signed-off-by: default avatarEvan Quan <evan.quan@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 5213e49d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2739,7 +2739,7 @@ static ssize_t amdgpu_hwmon_show_power_cap_max(struct device *dev,
		return r;

	if (is_support_sw_smu(adev)) {
		smu_get_power_limit(&adev->smu, &limit, true, true);
		smu_get_power_limit(&adev->smu, &limit, true);
		size = snprintf(buf, PAGE_SIZE, "%u\n", limit * 1000000);
	} else if (adev->powerplay.pp_funcs && adev->powerplay.pp_funcs->get_power_limit) {
		adev->powerplay.pp_funcs->get_power_limit(adev->powerplay.pp_handle, &limit, true);
@@ -2771,7 +2771,7 @@ static ssize_t amdgpu_hwmon_show_power_cap(struct device *dev,
		return r;

	if (is_support_sw_smu(adev)) {
		smu_get_power_limit(&adev->smu, &limit, false,  true);
		smu_get_power_limit(&adev->smu, &limit, false);
		size = snprintf(buf, PAGE_SIZE, "%u\n", limit * 1000000);
	} else if (adev->powerplay.pp_funcs && adev->powerplay.pp_funcs->get_power_limit) {
		adev->powerplay.pp_funcs->get_power_limit(adev->powerplay.pp_handle, &limit, false);
+7 −13
Original line number Diff line number Diff line
@@ -2210,24 +2210,18 @@ int smu_set_fan_speed_rpm(struct smu_context *smu, uint32_t speed)

int smu_get_power_limit(struct smu_context *smu,
			uint32_t *limit,
			bool def,
			bool lock_needed)
			bool max_setting)
{
	int ret = 0;

	if (lock_needed) {
	if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
		return -EOPNOTSUPP;

	mutex_lock(&smu->mutex);
	}

	*limit = (def ? smu->max_power_limit : smu->current_power_limit);
	*limit = (max_setting ? smu->max_power_limit : smu->current_power_limit);

	if (lock_needed)
	mutex_unlock(&smu->mutex);

	return ret;
	return 0;
}

int smu_set_power_limit(struct smu_context *smu, uint32_t limit)
+0 −35
Original line number Diff line number Diff line
@@ -2411,13 +2411,6 @@ static bool arcturus_is_baco_supported(struct smu_context *smu)
	return (val & RCC_BIF_STRAP0__STRAP_PX_CAPABLE_MASK) ? true : false;
}

static uint32_t arcturus_get_pptable_power_limit(struct smu_context *smu)
{
	PPTable_t *pptable = smu->smu_table.driver_pptable;

	return pptable->SocketPowerLimitAc[PPT_THROTTLER_PPT0];
}

static int arcturus_set_df_cstate(struct smu_context *smu,
				  enum pp_df_cstate state)
{
@@ -2544,33 +2537,6 @@ static int arcturus_set_thermal_range(struct smu_context *smu,
	return 0;
}

static uint32_t atcturus_get_max_power_limit(struct smu_context *smu) {
	uint32_t od_limit, max_power_limit;
	struct smu_11_0_powerplay_table *powerplay_table = NULL;
	struct smu_table_context *table_context = &smu->smu_table;
	powerplay_table = table_context->power_play_table;

	max_power_limit = arcturus_get_pptable_power_limit(smu);

	if (!max_power_limit) {
		// If we couldn't get the table limit, fall back on first-read value
		if (!smu->default_power_limit)
			smu->default_power_limit = smu->power_limit;
		max_power_limit = smu->default_power_limit;
	}

	if (smu->od_enabled) {
		od_limit = le32_to_cpu(powerplay_table->overdrive_table.max[SMU_11_0_ODSETTING_POWERPERCENTAGE]);

		dev_dbg(smu->adev->dev, "ODSETTING_POWERPERCENTAGE: %d (default: %d)\n", od_limit, smu->default_power_limit);

		max_power_limit *= (100 + od_limit);
		max_power_limit /= 100;
	}

	return max_power_limit;
}

static const struct pptable_funcs arcturus_ppt_funcs = {
	/* translate smu index into arcturus specific index */
	.get_smu_msg_index = arcturus_get_smu_msg_index,
@@ -2662,7 +2628,6 @@ static const struct pptable_funcs arcturus_ppt_funcs = {
	.allow_xgmi_power_down = arcturus_allow_xgmi_power_down,
	.log_thermal_throttling_event = arcturus_log_thermal_throttling_event,
	.set_thermal_range = arcturus_set_thermal_range,
	.get_max_power_limit = atcturus_get_max_power_limit,
};

void arcturus_set_ppt_funcs(struct smu_context *smu)
+1 −5
Original line number Diff line number Diff line
@@ -380,8 +380,6 @@ struct smu_context
	uint32_t pstate_mclk;

	bool od_enabled;
	uint32_t power_limit;
	uint32_t default_power_limit;
	uint32_t current_power_limit;
	uint32_t max_power_limit;

@@ -573,7 +571,6 @@ struct pptable_funcs {
	int (*set_power_source)(struct smu_context *smu, enum smu_power_src_type power_src);
	void (*log_thermal_throttling_event)(struct smu_context *smu);
	int (*set_thermal_range)(struct smu_context *smu, struct smu_temperature_range range);
	uint32_t (*get_max_power_limit)(struct smu_context *smu);
};

typedef enum {
@@ -616,8 +613,7 @@ int smu_set_fan_speed_rpm(struct smu_context *smu, uint32_t speed);

int smu_get_power_limit(struct smu_context *smu,
			uint32_t *limit,
			bool def,
			bool lock_needed);
			bool max_setting);

int smu_set_power_limit(struct smu_context *smu, uint32_t limit);
int smu_print_clk_levels(struct smu_context *smu, enum smu_clk_type clk_type, char *buf);
+0 −34
Original line number Diff line number Diff line
@@ -1916,12 +1916,6 @@ static int navi10_display_disable_memory_clock_switch(struct smu_context *smu,
	return ret;
}

static uint32_t navi10_get_pptable_power_limit(struct smu_context *smu)
{
	PPTable_t *pptable = smu->smu_table.driver_pptable;
	return pptable->SocketPowerLimitAc[PPT_THROTTLER_PPT0];
}

static int navi10_get_power_limit(struct smu_context *smu)
{
	struct smu_11_0_powerplay_table *powerplay_table =
@@ -2380,33 +2374,6 @@ static int navi10_set_thermal_range(struct smu_context *smu,
	return 0;
}

static uint32_t navi10_get_max_power_limit(struct smu_context *smu) {
	uint32_t od_limit, max_power_limit;
	struct smu_11_0_powerplay_table *powerplay_table = NULL;
	struct smu_table_context *table_context = &smu->smu_table;
	powerplay_table = table_context->power_play_table;

	max_power_limit = navi10_get_pptable_power_limit(smu);

	if (!max_power_limit) {
		// If we couldn't get the table limit, fall back on first-read value
		if (!smu->default_power_limit)
			smu->default_power_limit = smu->power_limit;
		max_power_limit = smu->default_power_limit;
	}

	if (smu->od_enabled) {
		od_limit = le32_to_cpu(powerplay_table->overdrive_table.max[SMU_11_0_ODSETTING_POWERPERCENTAGE]);

		dev_dbg(smu->adev->dev, "ODSETTING_POWERPERCENTAGE: %d (default: %d)\n", od_limit, smu->default_power_limit);

		max_power_limit *= (100 + od_limit);
		max_power_limit /= 100;
	}

	return max_power_limit;
}

static const struct pptable_funcs navi10_ppt_funcs = {
	.tables_init = navi10_tables_init,
	.alloc_dpm_context = navi10_allocate_dpm_context,
@@ -2497,7 +2464,6 @@ static const struct pptable_funcs navi10_ppt_funcs = {
	.disable_umc_cdr_12gbps_workaround = navi10_disable_umc_cdr_12gbps_workaround,
	.set_power_source = smu_v11_0_set_power_source,
	.set_thermal_range = navi10_set_thermal_range,
	.get_max_power_limit = navi10_get_max_power_limit,
};

void navi10_set_ppt_funcs(struct smu_context *smu)
Loading