xen/acpi: introduce cppc performance hypercall
cover xen/acpi: introduce cppc performance hypercall
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 capibility, like per-cpu cpc_desc structure, failed to be correctly stored and processed.
With upstreaming "amd-pstate CPU Performance Scaling Driver"(
https://lore.kernel.org/all/[email protected]/)
to Xen community, amd-pstate driver is supported on Xen platform. And as Xen is uncapable of parsing the ACPI dynamic table, like _CPC entry, this patch serie introduces a new sub-hypercall XEN_PM_CPPC to deliver CPPC performance capability data.
This patch serie is based on commit "xen/acpi: upload power and performance related data from a PVH dom0"(
https://patchwork.kernel.org/project/xen-devel/patch/[email protected]/),
which is still under review.
Penny Zheng (3):
acpi/cppc: extract _cpc entry parsing logic xen/cppc: get xen-required cppc perf caps data xen/cppc: introduce cppc data upload sub-hypercall
Roger Pau Monné (1):
xen/acpi: upload power and performance related data from a PVH dom0
drivers/acpi/cppc_acpi.c | 206 +++++++++++++++----- drivers/xen/pcpu.c | 3 +- drivers/xen/xen-acpi-processor.c | 320 +++++++++++++++++++++++++++++-- include/acpi/cppc_acpi.h | 5 + include/acpi/processor.h | 2 + include/xen/interface/platform.h | 11 ++ include/xen/xen.h | 2 +- 7 files changed, 477 insertions(+), 72 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/4 xen/acpi: upload power and performance related data from a PVH dom0
From: Roger Pau Monné <[email protected]>
When running as a PVH dom0 the ACPI MADT is crafted by Xen in order to report the correct numbers of vCPUs that dom0 has, so the host MADT is not provided to dom0. This creates issues when parsing the power and performance related data from ACPI dynamic tables, as the ACPI Processor UIDs found on the dynamic code are likely to not match the ones crafted by Xen in the dom0 MADT.
Xen would rely on Linux having filled at least the power and performance related data of the vCPUs on the system, and would clone that information in order to setup the remaining pCPUs on the system if dom0 vCPUs < pCPUs. However when running as PVH dom0 it's likely that none of dom0 CPUs will have the power and performance data filled, and hence the Xen ACPI Processor driver needs to fetch that information by itself.
In order to do so correctly, introduce a new helper to fetch the _CST data without taking into account the system capabilities from the CPUID output, as the capabilities reported to dom0 in CPUID might be different from the ones on the host.
Note that the newly introduced code will only fetch the _CST, _PSS, _PPC and _PCT from a single CPU, and clone that information for all the other Processors. This won't work on an heterogeneous system with Processors having different power and performance related data between them.
--- drivers/xen/pcpu.c | 3 +- drivers/xen/xen-acpi-processor.c | 231 ++++++++++++++++++++++++++++--- include/xen/xen.h | 2 +- 3 files changed, 217 insertions(+), 19 deletions(-)
drivers/xen/pcpu.c +2 -1
@@ -388,7 +388,7 @@ static int __init xen_pcpu_init(void)arch_initcall (xen_pcpu_init);#ifdef CONFIG_ACPI -bool __init xen_processor_present (uint32_t acpi_id) +bool xen_processor_present (uint32_t acpi_id) {const struct pcpu *pcpu;bool online = false;
@@ -403,6 +403,7 @@ bool __init xen_processor_present(uint32_t acpi_id)return online; } +EXPORT_SYMBOL_GPL (xen_processor_present);void xen_sanitize_proc_cap_bits (uint32_t *cap) {
drivers/xen/xen-acpi-processor.c +214 -17
309 lines not on this page · raw message
include/xen/xen.h +1 -1
@@ -81,7 +81,7 @@ static inline void xen_free_unpopulated_pages(unsigned int nr_pages,#endif #if defined(CONFIG_XEN_DOM0 ) && defined(CONFIG_ACPI ) && defined(CONFIG_X86 ) -bool __init xen_processor_present (uint32_t acpi_id); +bool xen_processor_present (uint32_t acpi_id);#else #include <linux/bug.h> static inline bool xen_processor_present (uint32_t acpi_id)
Signature · 1 line
2.34.1
Jürgen Groß
maintainerRe: [PATCH v1 1/4] xen/acpi: upload power and performance related data from a PVH dom0
Quoted 22 lines · Penny Zheng
From: Roger Pau Monné <[email protected]>
When running as a PVH dom0 the ACPI MADT is crafted by Xen in order to report the correct numbers of vCPUs that dom0 has, so the host MADT is not provided to dom0. This creates issues when parsing the power and performance related data from ACPI dynamic tables, as the ACPI Processor UIDs found on the dynamic code are likely to not match the ones crafted by Xen in the dom0 MADT.
Xen would rely on Linux having filled at least the power and performance related data of the vCPUs on the system, and would clone that information in order to setup the remaining pCPUs on the system if dom0 vCPUs < pCPUs. However when running as PVH dom0 it's likely that none of dom0 CPUs will have the power and performance data filled, and hence the Xen ACPI Processor driver needs to fetch that information by itself.
In order to do so correctly, introduce a new helper to fetch the
_CSTdata without taking into account the system capabilities from the CPUID output, as the capabilities reported to dom0 in CPUID might be different from the ones on the host.
Quoted 8 lines
Note that the newly introduced code will only fetch the
_CST,_PSS,_PPCand_PCTfrom a single CPU, and clone that information for all the other Processors. This won't work on an heterogeneous system with Processors having different power and performance related data between them.Signed-off-by Roger Pau Monné <[email protected]>Signed-off-by Jason Andryuk <[email protected]>
I think this is the V2 version of Jason's patch, of which he sent V3 just yesterday?
Please sync with him how to proceed: is his patch meant to be a prerequisite for your series or a part of it?
Juergen
Re: [PATCH v1 1/4] xen/acpi: upload power and performance related data from a PVH dom0
Quoted 29 lines · Jürgen Groß
Quoted 28 lines · Penny Zheng
From: Roger Pau Monné <[email protected]>
When running as a PVH dom0 the ACPI MADT is crafted by Xen in order to report the correct numbers of vCPUs that dom0 has, so the host MADT is not provided to dom0. This creates issues when parsing the power and performance related data from ACPI dynamic tables, as the ACPI Processor UIDs found on the dynamic code are likely to not match the ones crafted by Xen in the dom0 MADT.
Xen would rely on Linux having filled at least the power and performance related data of the vCPUs on the system, and would clone that information in order to setup the remaining pCPUs on the system if dom0 vCPUs < pCPUs. However when running as PVH dom0 it's likely that none of dom0 CPUs will have the power and performance data filled, and hence the Xen ACPI Processor driver needs to fetch that information by itself.
In order to do so correctly, introduce a new helper to fetch the
_CSTdata without taking into account the system capabilities from the CPUID output, as the capabilities reported to dom0 in CPUID might be different from the ones on the host.Note that the newly introduced code will only fetch the
_CST,_PSS,_PPCand_PCTfrom a single CPU, and clone that information for all the other Processors. This won't work on an heterogeneous system with Processors having different power and performance related data between them.
Quoted 5 lines
Quoted 2 lines
Signed-off-by Roger Pau Monné <[email protected]>Signed-off-by Jason Andryuk <[email protected]>I think this is the V2 version of Jason's patch, of which he sent V3 just yesterday?
Penny's patch has some of the changes I made, but then I made an additional change and didn't tell her about it.
Quoted 2 lines
Please sync with him how to proceed: is his patch meant to be a prerequisite for your series or a part of it?
Sorry for the confusion. Penny, I think you should just grab my v3 (https://lore.kernel.org/xen-devel/[email protected]/T/#u) and resubmit with that. It removes a BUG_ON that checkpatch complained about (which is unreachable because of an earlier NULL check).
Thanks,
Jason
RE: [PATCH v1 1/4] xen/acpi: upload power and performance related data from a PVH dom0
[AMD Official Use Only - AMD Internal Distribution Only]
Hi,
Quoted 51 lines
-----Original Message-----
From: Jason Andryuk <[email protected]>
Sent: Thursday, December 5, 2024 3:12 AM
To: Jürgen Groß <[email protected]>; Penny, Zheng <[email protected]>; Stefano Stabellini <[email protected]>; Oleksandr Tyshchenko <[email protected]>
Cc: Huang, Ray <[email protected]>; Ragiadakou, Xenia <[email protected]>; [email protected]; linux- [email protected]; Roger Pau Monné <[email protected]>
Subject: Re: [PATCH v1 1/4] xen/acpi: upload power and performance related data from a PVH dom0Quoted 29 lines · Jürgen Groß
Quoted 28 lines · Penny Zheng
From: Roger Pau Monné <[email protected]>
When running as a PVH dom0 the ACPI MADT is crafted by Xen in order to report the correct numbers of vCPUs that dom0 has, so the host MADT is not provided to dom0. This creates issues when parsing the power and performance related data from ACPI dynamic tables, as the ACPI Processor UIDs found on the dynamic code are likely to not match the ones crafted by Xen in the dom0 MADT.
Xen would rely on Linux having filled at least the power and performance related data of the vCPUs on the system, and would clone that information in order to setup the remaining pCPUs on the system if dom0 vCPUs < pCPUs. However when running as PVH dom0 it's likely that none of dom0 CPUs will have the power and performance data filled, and hence the Xen ACPI Processor driver needs to fetch that information by itself.
In order to do so correctly, introduce a new helper to fetch the
_CSTdata without taking into account the system capabilities from the CPUID output, as the capabilities reported to dom0 in CPUID might be different from the ones on the host.Note that the newly introduced code will only fetch the
_CST,_PSS,_PPCand_PCTfrom a single CPU, and clone that information for all the other Processors. This won't work on an heterogeneous system with Processors having different power and performance related data between them.Quoted 5 lines
Quoted 2 lines
Signed-off-by Roger Pau Monné <[email protected]>Signed-off-by Jason Andryuk <[email protected]>I think this is the V2 version of Jason's patch, of which he sent V3 just yesterday?
Penny's patch has some of the changes I made, but then I made an additional change and didn't tell her about it.
Quoted 9 lines
Quoted 2 lines
Please sync with him how to proceed: is his patch meant to be a prerequisite for your series or a part of it?
Sorry for the confusion. Penny, I think you should just grab my v3
(https://lore.kernel.org/xen-devel/20241203225338.1336-1-
[email protected]/T/#u)
and resubmit with that. It removes aBUG_ONthat checkpatch complained about (which is unreachable because of an earlier NULL check).
Sure, I'm downloading your version, and will rebase and push a new version here~
Quoted 2 lines
Thanks,
Jason
Mant thx,
Penny
PATCH 2/4 acpi/cppc: extract _cpc entry parsing logic
In reply to Penny ZhengWhen 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.
--- drivers/acpi/cppc_acpi.c | 95 +++++++++++++++++++++++----------------- 1 file changed, 54 insertions(+), 41 deletions(-)
drivers/acpi/cppc_acpi.c +54 -41
@@ -675,19 +675,11 @@ static int pcc_data_alloc(int pcc_ss_id)static inline void arch_init_invariance_cppc (void ) { }#endif -/** -* 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 ;
@@ -706,31 +698,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. */
@@ -739,18 +724,18 @@ 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; }/* -* Disregard _CPC if the number of entries in the return pachage is not +* Disregard _CPC if the number of entries in the return package is not * as expected, but support future revisions being proper supersets of * the v3 and only causing more entries to be returned by _CPC. */
@@ -758,8 +743,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 ;
@@ -793,7 +778,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 ) {
@@ -848,7 +833,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; } }
@@ -864,6 +849,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;
@@ -907,21 +931,10 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)arch_init_invariance_cppc (); -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);
Signature · 1 line
2.34.1
PATCH 3/4 xen/cppc: get xen-required cppc perf caps data
In reply to Penny ZhengWhen running as Xen dom0 PVH guest, processor logical id <-> physical id map could not be properly set up. So the original function cppc_get_perf_caps() fails to get correct cppc data for Xen ACPI processor.
A new function xen_processor_get_perf_caps() is introduced to get xen-required cppc perf caps data.
Also, as Xen couldn't read and process PCC-type register, this commit includes a new flag pcc_unsupported in struct acpi_processor_flags to tell whether platform supports PCC-type register.
--- drivers/acpi/cppc_acpi.c | 110 +++++++++++++++++++++++++++++++++++---- include/acpi/cppc_acpi.h | 5 ++ include/acpi/processor.h | 1 + 3 files changed, 105 insertions(+), 11 deletions(-)
drivers/acpi/cppc_acpi.c +99 -11
@@ -772,6 +772,15 @@ static int acpi_cppc_processor_parse(struct acpi_processor *pr, struct cpc_desc* so extract it only once. */ if (gas_t->space_id ==ACPI_ADR_SPACE_PLATFORM_COMM ) { +/* +* When ACPI processor represents Xen processor, PCC register type +* could not be properly read and processed right now, as logical +* processor doesn't always have 1:1 map relation to physical processor. +*/ +if (pr->flags.pcc_unsupported) { +pr_debug ("Unsupported PCC register type:%d\n" , pr->acpi_id); + goto out_free; + }if (pcc_subspace_id <0 ) { pcc_subspace_id = gas_t->access_width;if (pcc_data_alloc (pcc_subspace_id))
@@ -837,7 +846,9 @@ static int acpi_cppc_processor_parse(struct acpi_processor *pr, struct cpc_desc goto out_free; } } -per_cpu (cpu_pcc_subspace_idx, pr->id) = pcc_subspace_id; + +if (!pr->flags.pcc_unsupported) +per_cpu (cpu_pcc_subspace_idx, pr->id) = pcc_subspace_id;/* * Initialize the remaining cpc_regs as unsupported.
@@ -1018,8 +1029,7 @@ int __weak cpc_write_ffh(int cpunum, struct cpc_reg *reg, u64 val)static int cpc_read (int cpu,struct cpc_register_resource *reg_res,u64 *val) {void __iomem *vaddr =NULL ; -int size; -int pcc_ss_id =per_cpu (cpu_pcc_subspace_idx, cpu); +int size, pcc_ss_id;struct cpc_reg *reg = ®_res->cpc_entry.reg;if (reg_res->type ==ACPI_TYPE_INTEGER ) {
@@ -1044,14 +1054,17 @@ static int cpc_read(int cpu, struct cpc_register_resource *reg_res, u64 *val) *val = val_u32;return 0 ; - }else if (reg->space_id ==ACPI_ADR_SPACE_PLATFORM_COMM && pcc_ss_id >=0 ) { -/* -* For registers in PCC space, the register size is determined -* by the bit width field; the access size is used to indicate -* the PCC subspace id. -*/ - size = reg->bit_width; - vaddr =GET_PCC_VADDR (reg->address, pcc_ss_id); + }else if (reg->space_id ==ACPI_ADR_SPACE_PLATFORM_COMM ) { + pcc_ss_id =per_cpu (cpu_pcc_subspace_idx, cpu); +if (pcc_ss_id >=0 ) { +/* +* For registers in PCC space, the register size is determined +* by the bit width field; the access size is used to indicate +* the PCC subspace id. +*/ + size = reg->bit_width; + vaddr =GET_PCC_VADDR (reg->address, pcc_ss_id); + } }else if (reg->space_id ==ACPI_ADR_SPACE_SYSTEM_MEMORY ) vaddr = reg_res->sys_mem_vaddr;
@@ -1282,6 +1295,81 @@ int cppc_get_epp_perf(int cpunum, u64 *epp_perf) }EXPORT_SYMBOL_GPL (cppc_get_epp_perf); + +int xen_processor_get_perf_caps (struct acpi_processor *pr,struct cppc_perf_caps *perf_caps) +{ +struct cpc_desc *cpc_ptr; +struct cpc_register_resource *highest_reg, *lowest_reg, + *lowest_non_linear_reg, *nominal_reg, + *low_freq_reg =NULL , *nom_freq_reg =NULL ; +u64 high, low, nom, min_nonlinear, low_f =0 , nom_f =0 ; +int ret =0 ; + + 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 err; + + highest_reg = &cpc_ptr->cpc_regs[HIGHEST_PERF ]; + lowest_reg = &cpc_ptr->cpc_regs[LOWEST_PERF ]; + lowest_non_linear_reg = &cpc_ptr->cpc_regs[LOW_NON_LINEAR_PERF ]; + nominal_reg = &cpc_ptr->cpc_regs[NOMINAL_PERF ]; + low_freq_reg = &cpc_ptr->cpc_regs[LOWEST_FREQ ]; + nom_freq_reg = &cpc_ptr->cpc_regs[NOMINAL_FREQ ]; + +/* Are any of the regs PCC ?*/ +if (CPC_IN_PCC (highest_reg) ||CPC_IN_PCC (lowest_reg) || +CPC_IN_PCC (lowest_non_linear_reg) ||CPC_IN_PCC (nominal_reg) || +CPC_IN_PCC (low_freq_reg) ||CPC_IN_PCC (nom_freq_reg)) { +pr_debug ("Unsupported register type read for Xen Processor %d," +"highest_reg in PCC: %s, lowest_reg in PCC: %s," +"lowest_non_linear_reg in PCC: %s, nominal_reg in PCC: %s," +"low_freq_reg in PCC: %s, nom_freq_reg in PCC: %s\n" , + pr->acpi_id,CPC_IN_PCC (highest_reg) ?"true" :"false" , +CPC_IN_PCC (lowest_reg) ?"true" :"false" , +CPC_IN_PCC (lowest_non_linear_reg) ?"true" :"false" , +CPC_IN_PCC (nominal_reg) ?"true" :"false" , +CPC_IN_PCC (low_freq_reg) ?"true" :"false" , +CPC_IN_PCC (nom_freq_reg) ?"true" :"false" ); + goto err; + } + +cpc_read (pr->acpi_id, highest_reg, &high); + perf_caps->highest_perf = high; + +cpc_read (pr->acpi_id, lowest_reg, &low); + perf_caps->lowest_perf = low; + +cpc_read (pr->acpi_id, nominal_reg, &nom); + perf_caps->nominal_perf = nom; + +cpc_read (pr->id, lowest_non_linear_reg, &min_nonlinear); + perf_caps->lowest_nonlinear_perf = min_nonlinear; + +if (!high || !low || !nom || !min_nonlinear) +pr_warn ("CPPC: read zero cpc register value for Xen Processor %d" +"highest_reg: %llu, lowest_reg: %llu" +"nominal_reg: %llu, lowest_non_linear_reg: %llu\n" , + pr->acpi_id, high, low, nom, min_nonlinear); + +/* Read optional lowest and nominal frequencies if present */ +if (CPC_SUPPORTED (low_freq_reg)) +cpc_read (pr->acpi_id, low_freq_reg, &low_f); + +if (CPC_SUPPORTED (nom_freq_reg)) +cpc_read (pr->acpi_id, nom_freq_reg, &nom_f); + + perf_caps->lowest_freq = low_f; + perf_caps->nominal_freq = nom_f; + + err: +kfree (cpc_ptr); +return ret; +} +EXPORT_SYMBOL_GPL (xen_processor_get_perf_caps);/** * cppc_get_perf_caps - Get a CPU's performance capabilities. * @cpunum: CPU from which to get capabilities info.
include/acpi/cppc_acpi.h +5 -0
@@ -164,6 +164,7 @@ extern int cppc_set_auto_sel(int cpu, bool enable);extern int amd_get_highest_perf (unsigned int cpu,u32 *highest_perf);extern int amd_get_boost_ratio_numerator (unsigned int cpu,u64 *numerator);extern int amd_detect_prefcore (bool *detected); +extern int xen_processor_get_perf_caps (struct acpi_processor *pr,struct cppc_perf_caps *perf_caps);#else /* !CONFIG_ACPI_CPPC_LIB */ static inline int cppc_get_desired_perf (int cpunum,u64 *desired_perf) {
@@ -249,6 +250,10 @@ static inline int amd_detect_prefcore(bool *detected) {return -ENODEV ; } +static inline int xen_processor_get_perf_caps (struct acpi_processor *pr,struct cppc_perf_caps *perf_caps) +{ +return -ENOTSUPP ; +}#endif /* !CONFIG_ACPI_CPPC_LIB */ #endif /* _CPPC_ACPI_H*/
include/acpi/processor.h +1 -0
@@ -214,6 +214,7 @@ struct acpi_processor_flags { u8 bm_control:1; u8 bm_check:1; u8 has_cst:1; + u8 pcc_unsupported:1; u8 has_lpi:1; u8 power_setup_done:1; u8 bm_rld_set:1;
Signature · 1 line
2.34.1
PATCH 4/4 xen/cppc: introduce cppc data upload sub-hypercall
In reply to Penny ZhengAs Xen is uncapable of parsing the ACPI dynamic table, this commit introduces a new sub-hypercall XEN_PM_CPPC to deliver CPPC perf caps data.
--- drivers/acpi/cppc_acpi.c | 1 + drivers/xen/xen-acpi-processor.c | 89 +++++++++++++++++++++++++++++++- include/acpi/processor.h | 1 + include/xen/interface/platform.h | 11 ++++ 4 files changed, 101 insertions(+), 1 deletion(-)
drivers/acpi/cppc_acpi.c +1 -0
@@ -860,6 +860,7 @@ static int acpi_cppc_processor_parse(struct acpi_processor *pr, struct cpc_desc cpc_ptr->cpc_regs[i].cpc_entry.int_value =0 ; } + pr->flags.has_cpc =1 ;pr_debug ("Parsed _CPC entry for CPU: %d\n" , pr->acpi_id);kfree (output.pointer);return 0 ;
drivers/xen/xen-acpi-processor.c +88 -1
174 lines not on this page · raw message
include/acpi/processor.h +1 -0
@@ -214,6 +214,7 @@ struct acpi_processor_flags { u8 bm_control:1; u8 bm_check:1; u8 has_cst:1; + u8 has_cpc:1; u8 pcc_unsupported:1; u8 has_lpi:1; u8 power_setup_done:1;
include/xen/interface/platform.h +11 -0
@@ -319,6 +319,7 @@ DEFINE_GUEST_HANDLE_STRUCT(xenpf_getidletime_t);#define XEN_PM_PX 1#define XEN_PM_TX 2#define XEN_PM_PDC 3 +#define XEN_PM_CPPC 4/* Px sub info type */ #define XEN_PX_PCT 1#define XEN_PX_PSS 2
@@ -384,6 +385,15 @@ struct xen_processor_px { };DEFINE_GUEST_HANDLE_STRUCT (xen_processor_px); +struct xen_processor_cppc { +uint32_t highest_perf; +uint32_t nominal_perf; +uint32_t lowest_perf; +uint32_t lowest_nonlinear_perf; +uint32_t lowest_freq; +uint32_t nominal_freq; +}; +struct xen_psd_package {uint64_t num_entries;uint64_t revision;
@@ -412,6 +422,7 @@ struct xenpf_set_processor_pminfo {struct xen_processor_power power;/* Cx: _CST/_CSD */ struct xen_processor_performance perf;/* Px: _PPC/_PCT/_PSS/_PSD */ GUEST_HANDLE (uint32_t ) pdc; +struct xen_processor_cppc cppc_data;/* _CPC */ }; };DEFINE_GUEST_HANDLE_STRUCT (xenpf_set_processor_pminfo);
Signature · 1 line
2.34.1