Skip to content

Commit fb0b00a

Browse files
JinzhouSurafaeljw
authored andcommitted
ACPI: CPPC: Add CPPC enable register function
Add a new function to enable CPPC feature. This function will write Continuous Performance Control package EnableRegister field on the processor. CPPC EnableRegister register described in section 8.4.7.1 of ACPI 6.4: This element is optional. If supported, contains a resource descriptor with a single Register() descriptor that describes a register to which OSPM writes a One to enable CPPC on this processor. Before this register is set, the processor will be controlled by legacy mechanisms (ACPI Pstates, firmware, etc.). This register will be used for AMD processors to enable AMD P-State function instead of legacy ACPI P-States. Signed-off-by: Jinzhou Su <[email protected]> Signed-off-by: Huang Rui <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 2aeca6b commit fb0b00a

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

drivers/acpi/cppc_acpi.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,6 +1275,51 @@ int cppc_get_perf_ctrs(int cpunum, struct cppc_perf_fb_ctrs *perf_fb_ctrs)
12751275
}
12761276
EXPORT_SYMBOL_GPL(cppc_get_perf_ctrs);
12771277

1278+
/**
1279+
* cppc_set_enable - Set to enable CPPC on the processor by writing the
1280+
* Continuous Performance Control package EnableRegister field.
1281+
* @cpu: CPU for which to enable CPPC register.
1282+
* @enable: 0 - disable, 1 - enable CPPC feature on the processor.
1283+
*
1284+
* Return: 0 for success, -ERRNO or -EIO otherwise.
1285+
*/
1286+
int cppc_set_enable(int cpu, bool enable)
1287+
{
1288+
int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpu);
1289+
struct cpc_register_resource *enable_reg;
1290+
struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpu);
1291+
struct cppc_pcc_data *pcc_ss_data = NULL;
1292+
int ret = -EINVAL;
1293+
1294+
if (!cpc_desc) {
1295+
pr_debug("No CPC descriptor for CPU:%d\n", cpu);
1296+
return -EINVAL;
1297+
}
1298+
1299+
enable_reg = &cpc_desc->cpc_regs[ENABLE];
1300+
1301+
if (CPC_IN_PCC(enable_reg)) {
1302+
1303+
if (pcc_ss_id < 0)
1304+
return -EIO;
1305+
1306+
ret = cpc_write(cpu, enable_reg, enable);
1307+
if (ret)
1308+
return ret;
1309+
1310+
pcc_ss_data = pcc_data[pcc_ss_id];
1311+
1312+
down_write(&pcc_ss_data->pcc_lock);
1313+
/* after writing CPC, transfer the ownership of PCC to platfrom */
1314+
ret = send_pcc_cmd(pcc_ss_id, CMD_WRITE);
1315+
up_write(&pcc_ss_data->pcc_lock);
1316+
return ret;
1317+
}
1318+
1319+
return cpc_write(cpu, enable_reg, enable);
1320+
}
1321+
EXPORT_SYMBOL_GPL(cppc_set_enable);
1322+
12781323
/**
12791324
* cppc_set_perf - Set a CPU's performance controls.
12801325
* @cpu: CPU for which to set performance controls.

include/acpi/cppc_acpi.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ extern int cppc_get_desired_perf(int cpunum, u64 *desired_perf);
138138
extern int cppc_get_nominal_perf(int cpunum, u64 *nominal_perf);
139139
extern int cppc_get_perf_ctrs(int cpu, struct cppc_perf_fb_ctrs *perf_fb_ctrs);
140140
extern int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls);
141+
extern int cppc_set_enable(int cpu, bool enable);
141142
extern int cppc_get_perf_caps(int cpu, struct cppc_perf_caps *caps);
142143
extern bool acpi_cpc_valid(void);
143144
extern int acpi_get_psd_map(unsigned int cpu, struct cppc_cpudata *cpu_data);
@@ -162,6 +163,10 @@ static inline int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls)
162163
{
163164
return -ENOTSUPP;
164165
}
166+
static inline int cppc_set_enable(int cpu, bool enable)
167+
{
168+
return -ENOTSUPP;
169+
}
165170
static inline int cppc_get_perf_caps(int cpu, struct cppc_perf_caps *caps)
166171
{
167172
return -ENOTSUPP;

0 commit comments

Comments
 (0)