Thread (50 messages) 50 messages, 7 authors, 2021-11-12

Re: [PATCH v3 05/21] ACPI: CPPC: add cppc enable register function

From: Huang Rui <ray.huang@amd.com>
Date: 2021-11-01 09:22:26
Also in: lkml

On Fri, Oct 29, 2021 at 10:15:35PM +0800, Limonciello, Mario wrote:
On 10/29/2021 08:02, Huang Rui wrote:
quoted
From: Jinzhou Su <redacted>

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-pstate
function instead of legacy ACPI P-States.

Signed-off-by: Jinzhou Su <redacted>
Signed-off-by: Huang Rui <ray.huang@amd.com>
---
  drivers/acpi/cppc_acpi.c | 45 ++++++++++++++++++++++++++++++++++++++++
  include/acpi/cppc_acpi.h |  5 +++++
  2 files changed, 50 insertions(+)
diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
index c9169c221209..2d2297ef5bf9 100644
--- a/drivers/acpi/cppc_acpi.c
+++ b/drivers/acpi/cppc_acpi.c
@@ -1275,6 +1275,51 @@ int cppc_get_perf_ctrs(int cpunum, struct cppc_perf_fb_ctrs *perf_fb_ctrs)
  }
  EXPORT_SYMBOL_GPL(cppc_get_perf_ctrs);
  
+/**
+ * cppc_set_enable - Set to enable CPPC on the processor by writing the
+ * Continuous Performance Control package EnableRegister feild.
s/feild/field/
quoted
+ * @cpu: CPU for which to enable CPPC register.
+ * @enable: 0 - disable, 1 - enable CPPC feature on the processor.
+ *
+ * Return: 0 for success, -ERRNO or -EIO otherwise.
+ */
+int cppc_set_enable(int cpu, bool enable)
+{
+	int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpu);
+	struct cpc_register_resource *enable_reg;
+	struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpu);
+	struct cppc_pcc_data *pcc_ss_data = NULL;
+	int ret = -EINVAL;
+
+	if (!cpc_desc) {
+		pr_debug("No CPC descriptor for CPU:%d\n", cpu);
+		return -EINVAL;
+	}
Can this actually happen or is just an extra safety check?
Don't you block running based on acpi_cpc_valid?
It's a helper function in cppc lib, is this possible called on other driver
might not be protected by acpi_cpc_valid in future?

Thanks,
Ray
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help