From: Penny Zheng <Penny.Zheng@amd.com>
To: <jbeulich@suse.com>, Juergen Gross <jgross@suse.com>,
Stefano Stabellini <sstabellini@kernel.org>,
Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Cc: Ray Huang <Ray.Huang@amd.com>,
Jason Andryuk <jason.andryuk@amd.com>,
Penny Zheng <Penny.Zheng@amd.com>,
<xen-devel@lists.xenproject.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH v3 3/5] acpi/cppc: extract _cpc entry parsing logic
Date: Thu, 6 Mar 2025 19:08:22 +0800 [thread overview]
Message-ID: <20250306110824.1506699-4-Penny.Zheng@amd.com> (raw)
In-Reply-To: <20250306110824.1506699-1-Penny.Zheng@amd.com>
When running as Xen dom0 PVH guest, MADT table is customized
and may have the "wrong" UID processor number, which is
inconsistent with the UID in Processor entry in native DSDT.
As a result, during ACPI boot-up for dom0, linux fails to set
up proper processor logical id <-> physical id map(acpi_map_cpuid).
Furthermore, It leads to that some ACPI processor feature data,
like per-cpu cpc_desc structure, failed to be correctly stored.
In order to re-parse _CPC entry later for delivering correct data
in performance hypercall, firstly, we extract parsing logic from
acpi_cppc_processor_probe() and export it as a new function
acpi_cppc_processor_parse().
Also, replace logical processor id with ACPI ID, to show correct print
info in Xen dom0 PVH guest.
Signed-off-by: Penny Zheng <Penny.Zheng@amd.com>
---
v2 -> v3:
- no change
---
drivers/acpi/cppc_acpi.c | 93 +++++++++++++++++++++++-----------------
1 file changed, 53 insertions(+), 40 deletions(-)
diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
index f193e713825a..7832bebeb953 100644
--- a/drivers/acpi/cppc_acpi.c
+++ b/drivers/acpi/cppc_acpi.c
@@ -671,19 +671,11 @@ static int pcc_data_alloc(int pcc_ss_id)
* )
*/
-/**
- * acpi_cppc_processor_probe - Search for per CPU _CPC objects.
- * @pr: Ptr to acpi_processor containing this CPU's logical ID.
- *
- * Return: 0 for success or negative value for err.
- */
-int acpi_cppc_processor_probe(struct acpi_processor *pr)
+static int acpi_cppc_processor_parse(struct acpi_processor *pr, struct cpc_desc *cpc_ptr)
{
struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL};
union acpi_object *out_obj, *cpc_obj;
- struct cpc_desc *cpc_ptr;
struct cpc_reg *gas_t;
- struct device *cpu_dev;
acpi_handle handle = pr->handle;
unsigned int num_ent, i, cpc_rev;
int pcc_subspace_id = -1;
@@ -702,31 +694,24 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)
status = acpi_evaluate_object_typed(handle, "_CPC", NULL, &output,
ACPI_TYPE_PACKAGE);
if (ACPI_FAILURE(status)) {
- ret = -ENODEV;
- goto out_buf_free;
+ return -ENODEV;
}
out_obj = (union acpi_object *) output.pointer;
- cpc_ptr = kzalloc(sizeof(struct cpc_desc), GFP_KERNEL);
- if (!cpc_ptr) {
- ret = -ENOMEM;
- goto out_buf_free;
- }
-
/* First entry is NumEntries. */
cpc_obj = &out_obj->package.elements[0];
if (cpc_obj->type == ACPI_TYPE_INTEGER) {
num_ent = cpc_obj->integer.value;
if (num_ent <= 1) {
pr_debug("Unexpected _CPC NumEntries value (%d) for CPU:%d\n",
- num_ent, pr->id);
- goto out_free;
+ num_ent, pr->acpi_id);
+ goto out_pointer;
}
} else {
pr_debug("Unexpected _CPC NumEntries entry type (%d) for CPU:%d\n",
- cpc_obj->type, pr->id);
- goto out_free;
+ cpc_obj->type, pr->acpi_id);
+ goto out_pointer;
}
/* Second entry should be revision. */
@@ -735,14 +720,14 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)
cpc_rev = cpc_obj->integer.value;
} else {
pr_debug("Unexpected _CPC Revision entry type (%d) for CPU:%d\n",
- cpc_obj->type, pr->id);
- goto out_free;
+ cpc_obj->type, pr->acpi_id);
+ goto out_pointer;
}
if (cpc_rev < CPPC_V2_REV) {
pr_debug("Unsupported _CPC Revision (%d) for CPU:%d\n", cpc_rev,
- pr->id);
- goto out_free;
+ pr->acpi_id);
+ goto out_pointer;
}
/*
@@ -754,8 +739,8 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)
(cpc_rev == CPPC_V3_REV && num_ent != CPPC_V3_NUM_ENT) ||
(cpc_rev > CPPC_V3_REV && num_ent <= CPPC_V3_NUM_ENT)) {
pr_debug("Unexpected number of _CPC return package entries (%d) for CPU:%d\n",
- num_ent, pr->id);
- goto out_free;
+ num_ent, pr->acpi_id);
+ goto out_pointer;
}
if (cpc_rev > CPPC_V3_REV) {
num_ent = CPPC_V3_NUM_ENT;
@@ -789,7 +774,7 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)
goto out_free;
} else if (pcc_subspace_id != gas_t->access_width) {
pr_debug("Mismatched PCC ids in _CPC for CPU:%d\n",
- pr->id);
+ pr->acpi_id);
goto out_free;
}
} else if (gas_t->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) {
@@ -844,7 +829,7 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)
memcpy(&cpc_ptr->cpc_regs[i-2].cpc_entry.reg, gas_t, sizeof(*gas_t));
} else {
pr_debug("Invalid entry type (%d) in _CPC for CPU:%d\n",
- i, pr->id);
+ i, pr->acpi_id);
goto out_free;
}
}
@@ -860,6 +845,45 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)
cpc_ptr->cpc_regs[i].cpc_entry.int_value = 0;
}
+ pr_debug("Parsed _CPC entry for CPU: %d\n", pr->acpi_id);
+ kfree(output.pointer);
+ return 0;
+
+ out_free:
+ /* Free all the mapped sys mem areas for this CPU */
+ for (i = 2; i < cpc_ptr->num_entries; i++) {
+ void __iomem *addr = cpc_ptr->cpc_regs[i-2].sys_mem_vaddr;
+
+ if (addr)
+ iounmap(addr);
+ }
+ out_pointer:
+ kfree(output.pointer);
+ return ret;
+}
+
+/**
+ * acpi_cppc_processor_probe - Search for per CPU _CPC objects.
+ * @pr: Ptr to acpi_processor containing this CPU's logical ID.
+ *
+ * Return: 0 for success or negative value for err.
+ */
+int acpi_cppc_processor_probe(struct acpi_processor *pr)
+{
+ acpi_handle handle = pr->handle;
+ struct cpc_desc *cpc_ptr;
+ struct device *cpu_dev;
+ int pcc_subspace_id = -1;
+ int ret = -ENODATA;
+
+ cpc_ptr = kzalloc(sizeof(struct cpc_desc), GFP_KERNEL);
+ if (!cpc_ptr)
+ return -ENOMEM;
+
+ ret = acpi_cppc_processor_parse(pr, cpc_ptr);
+ if (ret)
+ goto out_free;
+ pcc_subspace_id = per_cpu(cpu_pcc_subspace_idx, pr->id);
/* Store CPU Logical ID */
cpc_ptr->cpu_id = pr->id;
@@ -901,21 +925,10 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)
goto out_free;
}
- kfree(output.pointer);
return 0;
out_free:
- /* Free all the mapped sys mem areas for this CPU */
- for (i = 2; i < cpc_ptr->num_entries; i++) {
- void __iomem *addr = cpc_ptr->cpc_regs[i-2].sys_mem_vaddr;
-
- if (addr)
- iounmap(addr);
- }
kfree(cpc_ptr);
-
-out_buf_free:
- kfree(output.pointer);
return ret;
}
EXPORT_SYMBOL_GPL(acpi_cppc_processor_probe);
--
2.34.1
next prev parent reply other threads:[~2025-03-06 11:08 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-06 11:08 [PATCH v3 0/5] xen/acpi: introduce cppc performance hypercall Penny Zheng
2025-03-06 11:08 ` [PATCH v3 1/5] xen/acpi: upload power and performance related data from a PVH dom0 Penny Zheng
2025-03-25 16:17 ` Jan Beulich
2025-03-25 16:49 ` Jason Andryuk
2025-03-25 21:11 ` Elliott Mitchell
2025-03-06 11:08 ` [PATCH v3 2/5] xen: introduces XEN_PM_PSD sub-hypercall for solely delivery of _PSD info Penny Zheng
2025-03-06 11:08 ` Penny Zheng [this message]
2025-03-06 11:08 ` [PATCH v3 4/5] xen/cppc: get xen-required cppc perf caps data Penny Zheng
2025-03-06 11:08 ` [PATCH v3 5/5] xen/cppc: introduce cppc data upload sub-hypercall Penny Zheng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250306110824.1506699-4-Penny.Zheng@amd.com \
--to=penny.zheng@amd.com \
--cc=Ray.Huang@amd.com \
--cc=jason.andryuk@amd.com \
--cc=jbeulich@suse.com \
--cc=jgross@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleksandr_tyshchenko@epam.com \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®