Commit 261a5963 authored by heppen's avatar heppen
Browse files

ACPI: CPPC: Introduce new EPP capabilities and update auto selection functions

huawei inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/IB5JJG


CVE: NA

--------------------------------------------------

Maintained compatibility with existing CPPC register read/write interfaces:
- Added cppc_get_epp_caps() to read the Energy Performance Preference (EPP) register.
- Updated cppc_set_auto_sel() to cppc_set_auto_sel_caps() for better clarity and functionality.
- Modified cppc_cpufreq and cpufreq_seep to utilize the new EPP and auto selection functions.

Signed-off-by: default avatarPeng He <hepeng68@huawei.com>
parent 0cdbb920
Loading
Loading
Loading
Loading
+27 −15
Original line number Diff line number Diff line
@@ -1209,11 +1209,6 @@ static int cppc_get_perf(int cpunum, enum cppc_regs reg_idx, u64 *perf)
		return ret;
	}

	if (!CPC_SUPPORTED(reg)) {
		pr_debug("CPC register %d is not supported\n", reg_idx);
		return -EOPNOTSUPP;
	}

	cpc_read(cpunum, reg, perf);

	return 0;
@@ -1628,6 +1623,17 @@ static int cppc_set_reg(int cpu, enum cppc_regs reg_idx, u64 val)
	return cpc_write(cpu, reg, val);
}

/*
 * cppc_get_epp_caps() - Read the EPP register
 * @cpunum: CPU from which to read register.
 * @epp_val: address of a variable to store the returned EPP value.
*/
int cppc_get_epp_caps(int cpunum, u64 *epp_val)
{
	return cppc_get_reg(cpunum, ENERGY_PERF, epp_val);
}
EXPORT_SYMBOL_GPL(cppc_get_epp_caps);

/**
 * cppc_set_epp() - Write the EPP register
 * @cpu:CPU on which to write register.
@@ -1664,7 +1670,7 @@ EXPORT_SYMBOL_GPL(cppc_set_auto_act_window);
/**
 * cppc_get_auto_sel() - Read autonomous selection register.
 * @cpunum:CPU from which to read register.
 * @auto_act_window:Return address.
 * @auto_sel:Return address.
*/
int cppc_get_auto_sel(int cpunum, u64 *auto_sel)
{
@@ -1672,6 +1678,17 @@ int cppc_get_auto_sel(int cpunum, u64 *auto_sel)
}
EXPORT_SYMBOL_GPL(cppc_get_auto_sel);

/**
 * cppc_set_auto_sel_caps() - Write autonomous selection register.
 * @cpu: CPU on which to write register.
 * @enable: the desired value of autonomous selection resiter to be updated.
*/
int cppc_set_auto_sel_caps(int cpu, bool enable)
{
	return cppc_set_reg(cpu, AUTO_SEL_ENABLE, enable);
}
EXPORT_SYMBOL_GPL(cppc_set_auto_sel_caps);

/**
 * cppc_get_auto_sel_caps - Read autonomous selection register.
 * @cpunum : CPU from which to read register.
@@ -1759,17 +1776,12 @@ int cppc_set_auto_sel(int cpu, bool enable)
		/* after writing CPC, transfer the ownership of PCC to platform */
		ret = send_pcc_cmd(pcc_ss_id, CMD_WRITE);
		up_write(&pcc_ss_data->pcc_lock);

		return ret;
	}

	if (!CPC_SUPPORTED(auto_sel_reg)) {
		pr_debug("CPC register (reg_idx=%u) is not supported\n",
			 AUTO_SEL_ENABLE);
		return -EOPNOTSUPP;
	} else {
		ret = -ENOTSUPP;
		pr_debug("_CPC in PCC is not supported\n");
	}

	return cpc_write(cpu, auto_sel_reg, enable);
	return ret;
}
EXPORT_SYMBOL_GPL(cppc_set_auto_sel);

+1 −1
Original line number Diff line number Diff line
@@ -898,7 +898,7 @@ static ssize_t show_energy_perf(struct cpufreq_policy *policy, char *buf)
	u64 val;
	int ret;

	ret = cppc_get_epp_perf(policy->cpu, &val);
	ret = cppc_get_epp_caps(policy->cpu, &val);

	/* show "<unsupported>" when this register is not supported by cpc */
	if (ret == -EOPNOTSUPP)
+2 −2
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ static int cpufreq_gov_seep_start(struct cpufreq_policy *policy)
	int ret;

	/* Enable BIOS frequency Scaling */
	ret = cppc_set_auto_sel(policy->cpu, 1);
	ret = cppc_set_auto_sel_caps(policy->cpu, 1);
	if (ret)
		pr_err("Failed to enable auto_sel: %d\n", ret);
	return ret;
@@ -67,7 +67,7 @@ static void cpufreq_gov_seep_stop(struct cpufreq_policy *policy)
	int ret;

	/* Disable BIOS frequency Scaling */
	ret = cppc_set_auto_sel(policy->cpu, 0);
	ret = cppc_set_auto_sel_caps(policy->cpu, 0);
	if (ret)
		pr_err("Failed to disable auto_sel: %d\n", ret);
}
+10 −0
Original line number Diff line number Diff line
@@ -161,10 +161,12 @@ extern int cppc_get_epp_perf(int cpunum, u64 *epp_perf);
extern int cppc_set_epp_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls, bool enable);
extern int cppc_get_auto_sel_caps(int cpunum, struct cppc_perf_caps *perf_caps);
extern int cppc_set_auto_sel(int cpu, bool enable);
extern int cppc_get_epp_caps(int cpunum, u64 *epp_val);
extern int cppc_set_epp(int cpu, u64 epp_val);
extern int cppc_get_auto_act_window(int cpunum, u64 *auto_act_window);
extern int cppc_set_auto_act_window(int cpu, u64 auto_act_window);
extern int cppc_get_auto_sel(int cpunum, u64 *auto_sel);
extern int cppc_set_auto_sel_caps(int cpu, bool enable);
#else /* !CONFIG_ACPI_CPPC_LIB */
static inline int cppc_get_desired_perf(int cpunum, u64 *desired_perf)
{
@@ -238,6 +240,10 @@ static inline int cppc_get_auto_sel_caps(int cpunum, struct cppc_perf_caps *perf
{
	return -ENOTSUPP;
}
static inline int cppc_get_epp_caps(int cpunum, u64 *epp_val)
{
	return -EOPNOTSUPP;
}
static inline int cppc_set_epp(int cpu, u64 epp_val)
{
	return -EOPNOTSUPP;
@@ -254,6 +260,10 @@ static inline int cppc_get_auto_sel(int cpunum, u64 *auto_sel)
{
	return -EOPNOTSUPP;
}
static inline int cppc_set_auto_sel_caps(int cpu, bool enable)
{
	return -EOPNOTSUPP;
}

#endif /* !CONFIG_ACPI_CPPC_LIB */