ACPI: CPPC: Introduce cppc_get_nominal_perf()
On some systems the nominal_perf value retrieved via CPPC is just a constant and fetching it doesn't require accessing any registers, so if it is the only CPPC capability that's needed, it is wasteful to run cppc_get_perf_caps() in order to get just that value alone, especially when this is done for CPUs other than the one running the code. For this reason, introduce cppc_get_nominal_perf() allowing nominal_perf to be obtained individually, by generalizing the existing cppc_get_desired_perf() (and renaming it) so it can be used to retrieve any specific CPPC capability value. While at it, clean up the cppc_get_desired_perf() kerneldoc comment a bit. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
parent
27de8d5970
commit
0654cf05d1
2 changed files with 36 additions and 16 deletions
|
@ -1008,23 +1008,14 @@ static int cpc_write(int cpu, struct cpc_register_resource *reg_res, u64 val)
|
||||||
return ret_val;
|
return ret_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
static int cppc_get_perf(int cpunum, enum cppc_regs reg_idx, u64 *perf)
|
||||||
* cppc_get_desired_perf - Get the value of desired performance register.
|
|
||||||
* @cpunum: CPU from which to get desired performance.
|
|
||||||
* @desired_perf: address of a variable to store the returned desired performance
|
|
||||||
*
|
|
||||||
* Return: 0 for success, -EIO otherwise.
|
|
||||||
*/
|
|
||||||
int cppc_get_desired_perf(int cpunum, u64 *desired_perf)
|
|
||||||
{
|
{
|
||||||
struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpunum);
|
struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpunum);
|
||||||
int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpunum);
|
struct cpc_register_resource *reg = &cpc_desc->cpc_regs[reg_idx];
|
||||||
struct cpc_register_resource *desired_reg;
|
|
||||||
struct cppc_pcc_data *pcc_ss_data = NULL;
|
|
||||||
|
|
||||||
desired_reg = &cpc_desc->cpc_regs[DESIRED_PERF];
|
if (CPC_IN_PCC(reg)) {
|
||||||
|
int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpunum);
|
||||||
if (CPC_IN_PCC(desired_reg)) {
|
struct cppc_pcc_data *pcc_ss_data = NULL;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (pcc_ss_id < 0)
|
if (pcc_ss_id < 0)
|
||||||
|
@ -1035,7 +1026,7 @@ int cppc_get_desired_perf(int cpunum, u64 *desired_perf)
|
||||||
down_write(&pcc_ss_data->pcc_lock);
|
down_write(&pcc_ss_data->pcc_lock);
|
||||||
|
|
||||||
if (send_pcc_cmd(pcc_ss_id, CMD_READ) >= 0)
|
if (send_pcc_cmd(pcc_ss_id, CMD_READ) >= 0)
|
||||||
cpc_read(cpunum, desired_reg, desired_perf);
|
cpc_read(cpunum, reg, perf);
|
||||||
else
|
else
|
||||||
ret = -EIO;
|
ret = -EIO;
|
||||||
|
|
||||||
|
@ -1044,12 +1035,36 @@ int cppc_get_desired_perf(int cpunum, u64 *desired_perf)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
cpc_read(cpunum, desired_reg, desired_perf);
|
cpc_read(cpunum, reg, perf);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cppc_get_desired_perf - Get the desired performance register value.
|
||||||
|
* @cpunum: CPU from which to get desired performance.
|
||||||
|
* @desired_perf: Return address.
|
||||||
|
*
|
||||||
|
* Return: 0 for success, -EIO otherwise.
|
||||||
|
*/
|
||||||
|
int cppc_get_desired_perf(int cpunum, u64 *desired_perf)
|
||||||
|
{
|
||||||
|
return cppc_get_perf(cpunum, DESIRED_PERF, desired_perf);
|
||||||
|
}
|
||||||
EXPORT_SYMBOL_GPL(cppc_get_desired_perf);
|
EXPORT_SYMBOL_GPL(cppc_get_desired_perf);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cppc_get_nominal_perf - Get the nominal performance register value.
|
||||||
|
* @cpunum: CPU from which to get nominal performance.
|
||||||
|
* @nominal_perf: Return address.
|
||||||
|
*
|
||||||
|
* Return: 0 for success, -EIO otherwise.
|
||||||
|
*/
|
||||||
|
int cppc_get_nominal_perf(int cpunum, u64 *nominal_perf)
|
||||||
|
{
|
||||||
|
return cppc_get_perf(cpunum, NOMINAL_PERF, nominal_perf);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cppc_get_perf_caps - Get a CPU's performance capabilities.
|
* cppc_get_perf_caps - Get a CPU's performance capabilities.
|
||||||
* @cpunum: CPU from which to get capabilities info.
|
* @cpunum: CPU from which to get capabilities info.
|
||||||
|
|
|
@ -135,6 +135,7 @@ struct cppc_cpudata {
|
||||||
|
|
||||||
#ifdef CONFIG_ACPI_CPPC_LIB
|
#ifdef CONFIG_ACPI_CPPC_LIB
|
||||||
extern int cppc_get_desired_perf(int cpunum, u64 *desired_perf);
|
extern int cppc_get_desired_perf(int cpunum, u64 *desired_perf);
|
||||||
|
extern int cppc_get_nominal_perf(int cpunum, u64 *nominal_perf);
|
||||||
extern int cppc_get_perf_ctrs(int cpu, struct cppc_perf_fb_ctrs *perf_fb_ctrs);
|
extern int cppc_get_perf_ctrs(int cpu, struct cppc_perf_fb_ctrs *perf_fb_ctrs);
|
||||||
extern int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls);
|
extern int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls);
|
||||||
extern int cppc_get_perf_caps(int cpu, struct cppc_perf_caps *caps);
|
extern int cppc_get_perf_caps(int cpu, struct cppc_perf_caps *caps);
|
||||||
|
@ -149,6 +150,10 @@ static inline int cppc_get_desired_perf(int cpunum, u64 *desired_perf)
|
||||||
{
|
{
|
||||||
return -ENOTSUPP;
|
return -ENOTSUPP;
|
||||||
}
|
}
|
||||||
|
static inline int cppc_get_nominal_perf(int cpunum, u64 *nominal_perf)
|
||||||
|
{
|
||||||
|
return -ENOTSUPP;
|
||||||
|
}
|
||||||
static inline int cppc_get_perf_ctrs(int cpu, struct cppc_perf_fb_ctrs *perf_fb_ctrs)
|
static inline int cppc_get_perf_ctrs(int cpu, struct cppc_perf_fb_ctrs *perf_fb_ctrs)
|
||||||
{
|
{
|
||||||
return -ENOTSUPP;
|
return -ENOTSUPP;
|
||||||
|
|
Loading…
Add table
Reference in a new issue