summaryrefslogtreecommitdiff
path: root/drivers/acpi
diff options
context:
space:
mode:
authorJie Zhan <zhanjie9@hisilicon.com>2025-12-23 15:21:17 +0800
committerViresh Kumar <viresh.kumar@linaro.org>2026-01-27 11:21:23 +0530
commitf9cadb3d56912a70571fdd95f426b757557c465b (patch)
tree4d4a6766513a832272b4da918a8dff93c0c8dcc5 /drivers/acpi
parente05d9e5c8b754cc7d72acd896f5f7caf6b78a973 (diff)
ACPI: CPPC: Factor out and export per-cpu cppc_perf_ctrs_in_pcc_cpu()
Factor out cppc_perf_ctrs_in_pcc_cpu() for checking whether per-cpu CPC regs are defined in PCC channels, and export it out for further use. Reviewed-by: Lifeng Zheng <zhenglifeng1@huawei.com> Reviewed-by: Pierre Gondois <pierre.gondois@arm.com> Signed-off-by: Jie Zhan <zhanjie9@hisilicon.com> Acked-by: Rafael J. Wysocki (Intel) <rafael@kernel.org> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/cppc_acpi.c48
1 files changed, 27 insertions, 21 deletions
diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
index 3bdeeee3414e..ec4966aaa8d4 100644
--- a/drivers/acpi/cppc_acpi.c
+++ b/drivers/acpi/cppc_acpi.c
@@ -1423,6 +1423,32 @@ out_err:
EXPORT_SYMBOL_GPL(cppc_get_perf_caps);
/**
+ * cppc_perf_ctrs_in_pcc_cpu - Check if any perf counters of a CPU are in PCC.
+ * @cpu: CPU on which to check perf counters.
+ *
+ * Return: true if any of the counters are in PCC regions, false otherwise
+ */
+bool cppc_perf_ctrs_in_pcc_cpu(unsigned int cpu)
+{
+ struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpu);
+ struct cpc_register_resource *ref_perf_reg;
+
+ /*
+ * If reference perf register is not supported then we should use the
+ * nominal perf value
+ */
+ ref_perf_reg = &cpc_desc->cpc_regs[REFERENCE_PERF];
+ if (!CPC_SUPPORTED(ref_perf_reg))
+ ref_perf_reg = &cpc_desc->cpc_regs[NOMINAL_PERF];
+
+ return CPC_IN_PCC(&cpc_desc->cpc_regs[DELIVERED_CTR]) ||
+ CPC_IN_PCC(&cpc_desc->cpc_regs[REFERENCE_CTR]) ||
+ CPC_IN_PCC(&cpc_desc->cpc_regs[CTR_WRAP_TIME]) ||
+ CPC_IN_PCC(ref_perf_reg);
+}
+EXPORT_SYMBOL_GPL(cppc_perf_ctrs_in_pcc_cpu);
+
+/**
* cppc_perf_ctrs_in_pcc - Check if any perf counters are in a PCC region.
*
* CPPC has flexibility about how CPU performance counters are accessed.
@@ -1436,27 +1462,7 @@ bool cppc_perf_ctrs_in_pcc(void)
int cpu;
for_each_online_cpu(cpu) {
- struct cpc_register_resource *ref_perf_reg;
- struct cpc_desc *cpc_desc;
-
- cpc_desc = per_cpu(cpc_desc_ptr, cpu);
-
- if (CPC_IN_PCC(&cpc_desc->cpc_regs[DELIVERED_CTR]) ||
- CPC_IN_PCC(&cpc_desc->cpc_regs[REFERENCE_CTR]) ||
- CPC_IN_PCC(&cpc_desc->cpc_regs[CTR_WRAP_TIME]))
- return true;
-
-
- ref_perf_reg = &cpc_desc->cpc_regs[REFERENCE_PERF];
-
- /*
- * If reference perf register is not supported then we should
- * use the nominal perf value
- */
- if (!CPC_SUPPORTED(ref_perf_reg))
- ref_perf_reg = &cpc_desc->cpc_regs[NOMINAL_PERF];
-
- if (CPC_IN_PCC(ref_perf_reg))
+ if (cppc_perf_ctrs_in_pcc_cpu(cpu))
return true;
}