Skip to content

Commit 0654cf0

Browse files
committed
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 <[email protected]>
1 parent 27de8d5 commit 0654cf0

File tree

2 files changed

+36
-16
lines changed

2 files changed

+36
-16
lines changed

drivers/acpi/cppc_acpi.c

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,23 +1008,14 @@ static int cpc_write(int cpu, struct cpc_register_resource *reg_res, u64 val)
10081008
return ret_val;
10091009
}
10101010

1011-
/**
1012-
* cppc_get_desired_perf - Get the value of desired performance register.
1013-
* @cpunum: CPU from which to get desired performance.
1014-
* @desired_perf: address of a variable to store the returned desired performance
1015-
*
1016-
* Return: 0 for success, -EIO otherwise.
1017-
*/
1018-
int cppc_get_desired_perf(int cpunum, u64 *desired_perf)
1011+
static int cppc_get_perf(int cpunum, enum cppc_regs reg_idx, u64 *perf)
10191012
{
10201013
struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpunum);
1021-
int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpunum);
1022-
struct cpc_register_resource *desired_reg;
1023-
struct cppc_pcc_data *pcc_ss_data = NULL;
1024-
1025-
desired_reg = &cpc_desc->cpc_regs[DESIRED_PERF];
1014+
struct cpc_register_resource *reg = &cpc_desc->cpc_regs[reg_idx];
10261015

1027-
if (CPC_IN_PCC(desired_reg)) {
1016+
if (CPC_IN_PCC(reg)) {
1017+
int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpunum);
1018+
struct cppc_pcc_data *pcc_ss_data = NULL;
10281019
int ret = 0;
10291020

10301021
if (pcc_ss_id < 0)
@@ -1035,7 +1026,7 @@ int cppc_get_desired_perf(int cpunum, u64 *desired_perf)
10351026
down_write(&pcc_ss_data->pcc_lock);
10361027

10371028
if (send_pcc_cmd(pcc_ss_id, CMD_READ) >= 0)
1038-
cpc_read(cpunum, desired_reg, desired_perf);
1029+
cpc_read(cpunum, reg, perf);
10391030
else
10401031
ret = -EIO;
10411032

@@ -1044,12 +1035,36 @@ int cppc_get_desired_perf(int cpunum, u64 *desired_perf)
10441035
return ret;
10451036
}
10461037

1047-
cpc_read(cpunum, desired_reg, desired_perf);
1038+
cpc_read(cpunum, reg, perf);
10481039

10491040
return 0;
10501041
}
1042+
1043+
/**
1044+
* cppc_get_desired_perf - Get the desired performance register value.
1045+
* @cpunum: CPU from which to get desired performance.
1046+
* @desired_perf: Return address.
1047+
*
1048+
* Return: 0 for success, -EIO otherwise.
1049+
*/
1050+
int cppc_get_desired_perf(int cpunum, u64 *desired_perf)
1051+
{
1052+
return cppc_get_perf(cpunum, DESIRED_PERF, desired_perf);
1053+
}
10511054
EXPORT_SYMBOL_GPL(cppc_get_desired_perf);
10521055

1056+
/**
1057+
* cppc_get_nominal_perf - Get the nominal performance register value.
1058+
* @cpunum: CPU from which to get nominal performance.
1059+
* @nominal_perf: Return address.
1060+
*
1061+
* Return: 0 for success, -EIO otherwise.
1062+
*/
1063+
int cppc_get_nominal_perf(int cpunum, u64 *nominal_perf)
1064+
{
1065+
return cppc_get_perf(cpunum, NOMINAL_PERF, nominal_perf);
1066+
}
1067+
10531068
/**
10541069
* cppc_get_perf_caps - Get a CPU's performance capabilities.
10551070
* @cpunum: CPU from which to get capabilities info.

include/acpi/cppc_acpi.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ struct cppc_cpudata {
135135

136136
#ifdef CONFIG_ACPI_CPPC_LIB
137137
extern int cppc_get_desired_perf(int cpunum, u64 *desired_perf);
138+
extern int cppc_get_nominal_perf(int cpunum, u64 *nominal_perf);
138139
extern int cppc_get_perf_ctrs(int cpu, struct cppc_perf_fb_ctrs *perf_fb_ctrs);
139140
extern int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls);
140141
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)
149150
{
150151
return -ENOTSUPP;
151152
}
153+
static inline int cppc_get_nominal_perf(int cpunum, u64 *nominal_perf)
154+
{
155+
return -ENOTSUPP;
156+
}
152157
static inline int cppc_get_perf_ctrs(int cpu, struct cppc_perf_fb_ctrs *perf_fb_ctrs)
153158
{
154159
return -ENOTSUPP;

0 commit comments

Comments
 (0)