Commit 850d64a4 authored by Prakash, Prashanth's avatar Prakash, Prashanth Committed by Rafael J. Wysocki

ACPI / CPPC: acquire pcc_lock only while accessing PCC subspace

We need to acquire pcc_lock only when we are accessing registers
that are in the PCC subspsace.
Signed-off-by: default avatarPrashanth Prakash <pprakash@codeaurora.org>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 5bbb86aa
...@@ -763,7 +763,7 @@ int cppc_get_perf_caps(int cpunum, struct cppc_perf_caps *perf_caps) ...@@ -763,7 +763,7 @@ int cppc_get_perf_caps(int cpunum, struct cppc_perf_caps *perf_caps)
struct cpc_register_resource *highest_reg, *lowest_reg, *ref_perf, struct cpc_register_resource *highest_reg, *lowest_reg, *ref_perf,
*nom_perf; *nom_perf;
u64 high, low, ref, nom; u64 high, low, ref, nom;
int ret = 0; int ret = 0, regs_in_pcc = 0;
if (!cpc_desc) { if (!cpc_desc) {
pr_debug("No CPC descriptor for CPU:%d\n", cpunum); pr_debug("No CPC descriptor for CPU:%d\n", cpunum);
...@@ -775,13 +775,13 @@ int cppc_get_perf_caps(int cpunum, struct cppc_perf_caps *perf_caps) ...@@ -775,13 +775,13 @@ int cppc_get_perf_caps(int cpunum, struct cppc_perf_caps *perf_caps)
ref_perf = &cpc_desc->cpc_regs[REFERENCE_PERF]; ref_perf = &cpc_desc->cpc_regs[REFERENCE_PERF];
nom_perf = &cpc_desc->cpc_regs[NOMINAL_PERF]; nom_perf = &cpc_desc->cpc_regs[NOMINAL_PERF];
spin_lock(&pcc_lock);
/* Are any of the regs PCC ?*/ /* Are any of the regs PCC ?*/
if ((highest_reg->cpc_entry.reg.space_id == ACPI_ADR_SPACE_PLATFORM_COMM) || if ((highest_reg->cpc_entry.reg.space_id == ACPI_ADR_SPACE_PLATFORM_COMM) ||
(lowest_reg->cpc_entry.reg.space_id == ACPI_ADR_SPACE_PLATFORM_COMM) || (lowest_reg->cpc_entry.reg.space_id == ACPI_ADR_SPACE_PLATFORM_COMM) ||
(ref_perf->cpc_entry.reg.space_id == ACPI_ADR_SPACE_PLATFORM_COMM) || (ref_perf->cpc_entry.reg.space_id == ACPI_ADR_SPACE_PLATFORM_COMM) ||
(nom_perf->cpc_entry.reg.space_id == ACPI_ADR_SPACE_PLATFORM_COMM)) { (nom_perf->cpc_entry.reg.space_id == ACPI_ADR_SPACE_PLATFORM_COMM)) {
spin_lock(&pcc_lock);
regs_in_pcc = 1;
/* Ring doorbell once to update PCC subspace */ /* Ring doorbell once to update PCC subspace */
if (send_pcc_cmd(CMD_READ) < 0) { if (send_pcc_cmd(CMD_READ) < 0) {
ret = -EIO; ret = -EIO;
...@@ -808,7 +808,8 @@ int cppc_get_perf_caps(int cpunum, struct cppc_perf_caps *perf_caps) ...@@ -808,7 +808,8 @@ int cppc_get_perf_caps(int cpunum, struct cppc_perf_caps *perf_caps)
ret = -EFAULT; ret = -EFAULT;
out_err: out_err:
spin_unlock(&pcc_lock); if (regs_in_pcc)
spin_unlock(&pcc_lock);
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(cppc_get_perf_caps); EXPORT_SYMBOL_GPL(cppc_get_perf_caps);
...@@ -825,7 +826,7 @@ int cppc_get_perf_ctrs(int cpunum, struct cppc_perf_fb_ctrs *perf_fb_ctrs) ...@@ -825,7 +826,7 @@ int cppc_get_perf_ctrs(int cpunum, struct cppc_perf_fb_ctrs *perf_fb_ctrs)
struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpunum); struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpunum);
struct cpc_register_resource *delivered_reg, *reference_reg; struct cpc_register_resource *delivered_reg, *reference_reg;
u64 delivered, reference; u64 delivered, reference;
int ret = 0; int ret = 0, regs_in_pcc = 0;
if (!cpc_desc) { if (!cpc_desc) {
pr_debug("No CPC descriptor for CPU:%d\n", cpunum); pr_debug("No CPC descriptor for CPU:%d\n", cpunum);
...@@ -835,11 +836,11 @@ int cppc_get_perf_ctrs(int cpunum, struct cppc_perf_fb_ctrs *perf_fb_ctrs) ...@@ -835,11 +836,11 @@ int cppc_get_perf_ctrs(int cpunum, struct cppc_perf_fb_ctrs *perf_fb_ctrs)
delivered_reg = &cpc_desc->cpc_regs[DELIVERED_CTR]; delivered_reg = &cpc_desc->cpc_regs[DELIVERED_CTR];
reference_reg = &cpc_desc->cpc_regs[REFERENCE_CTR]; reference_reg = &cpc_desc->cpc_regs[REFERENCE_CTR];
spin_lock(&pcc_lock);
/* Are any of the regs PCC ?*/ /* Are any of the regs PCC ?*/
if ((delivered_reg->cpc_entry.reg.space_id == ACPI_ADR_SPACE_PLATFORM_COMM) || if ((delivered_reg->cpc_entry.reg.space_id == ACPI_ADR_SPACE_PLATFORM_COMM) ||
(reference_reg->cpc_entry.reg.space_id == ACPI_ADR_SPACE_PLATFORM_COMM)) { (reference_reg->cpc_entry.reg.space_id == ACPI_ADR_SPACE_PLATFORM_COMM)) {
spin_lock(&pcc_lock);
regs_in_pcc = 1;
/* Ring doorbell once to update PCC subspace */ /* Ring doorbell once to update PCC subspace */
if (send_pcc_cmd(CMD_READ) < 0) { if (send_pcc_cmd(CMD_READ) < 0) {
ret = -EIO; ret = -EIO;
...@@ -865,7 +866,8 @@ int cppc_get_perf_ctrs(int cpunum, struct cppc_perf_fb_ctrs *perf_fb_ctrs) ...@@ -865,7 +866,8 @@ int cppc_get_perf_ctrs(int cpunum, struct cppc_perf_fb_ctrs *perf_fb_ctrs)
perf_fb_ctrs->prev_reference = reference; perf_fb_ctrs->prev_reference = reference;
out_err: out_err:
spin_unlock(&pcc_lock); if (regs_in_pcc)
spin_unlock(&pcc_lock);
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(cppc_get_perf_ctrs); EXPORT_SYMBOL_GPL(cppc_get_perf_ctrs);
...@@ -890,10 +892,9 @@ int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls) ...@@ -890,10 +892,9 @@ int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls)
desired_reg = &cpc_desc->cpc_regs[DESIRED_PERF]; desired_reg = &cpc_desc->cpc_regs[DESIRED_PERF];
spin_lock(&pcc_lock);
/* If this is PCC reg, check if channel is free before writing */ /* If this is PCC reg, check if channel is free before writing */
if (desired_reg->cpc_entry.reg.space_id == ACPI_ADR_SPACE_PLATFORM_COMM) { if (desired_reg->cpc_entry.reg.space_id == ACPI_ADR_SPACE_PLATFORM_COMM) {
spin_lock(&pcc_lock);
ret = check_pcc_chan(); ret = check_pcc_chan();
if (ret) if (ret)
goto busy_channel; goto busy_channel;
...@@ -912,7 +913,8 @@ int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls) ...@@ -912,7 +913,8 @@ int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls)
ret = -EIO; ret = -EIO;
} }
busy_channel: busy_channel:
spin_unlock(&pcc_lock); if (desired_reg->cpc_entry.reg.space_id == ACPI_ADR_SPACE_PLATFORM_COMM)
spin_unlock(&pcc_lock);
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(cppc_set_perf); EXPORT_SYMBOL_GPL(cppc_set_perf);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment