Skip to content

Commit 4d0f1ce

Browse files
jpemartinsBoris Ostrovsky
authored andcommitted
xen/acpi: upload _PSD info for non Dom0 CPUs too
All uploaded PM data from non-dom0 CPUs takes the info from vCPU 0 and changing only the acpi_id. For processors which P-state coordination type is HW_ALL (0xFD) it is OK to upload bogus P-state dependency information (_PSD), because Xen will ignore any cpufreq domains created for past CPUs. Albeit for platforms which expose coordination types as SW_ANY or SW_ALL, this will have some unintended side effects. Effectively, it will look at the P-state domain existence and *if it already exists* it will skip the acpi-cpufreq initialization and thus inherit the policy from the first CPU in the cpufreq domain. This will finally lead to the original cpu not changing target freq to P0 other than the first in the domain. Which will make turbo boost not getting enabled (e.g. for 'performance' governor) for all cpus. This patch fixes that, by also evaluating _PSD when we enumerate all ACPI processors and thus always uploading the correct info to Xen. We export acpi_processor_get_psd() for that this purpose, but change signature to not assume an existent of acpi_processor given that ACPI isn't creating an acpi_processor for non-dom0 CPUs. Signed-off-by: Joao Martins <[email protected]> Reviewed-by: Boris Ostrovsky <[email protected]> Acked-by: Rafael J. Wysocki <[email protected]> Signed-off-by: Boris Ostrovsky <[email protected]>
1 parent 36104cb commit 4d0f1ce

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

drivers/acpi/processor_perflib.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -533,17 +533,16 @@ int acpi_processor_notify_smm(struct module *calling_module)
533533

534534
EXPORT_SYMBOL(acpi_processor_notify_smm);
535535

536-
static int acpi_processor_get_psd(struct acpi_processor *pr)
536+
int acpi_processor_get_psd(acpi_handle handle, struct acpi_psd_package *pdomain)
537537
{
538538
int result = 0;
539539
acpi_status status = AE_OK;
540540
struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
541541
struct acpi_buffer format = {sizeof("NNNNN"), "NNNNN"};
542542
struct acpi_buffer state = {0, NULL};
543543
union acpi_object *psd = NULL;
544-
struct acpi_psd_package *pdomain;
545544

546-
status = acpi_evaluate_object(pr->handle, "_PSD", NULL, &buffer);
545+
status = acpi_evaluate_object(handle, "_PSD", NULL, &buffer);
547546
if (ACPI_FAILURE(status)) {
548547
return -ENODEV;
549548
}
@@ -561,8 +560,6 @@ static int acpi_processor_get_psd(struct acpi_processor *pr)
561560
goto end;
562561
}
563562

564-
pdomain = &(pr->performance->domain_info);
565-
566563
state.length = sizeof(struct acpi_psd_package);
567564
state.pointer = pdomain;
568565

@@ -597,6 +594,7 @@ static int acpi_processor_get_psd(struct acpi_processor *pr)
597594
kfree(buffer.pointer);
598595
return result;
599596
}
597+
EXPORT_SYMBOL(acpi_processor_get_psd);
600598

601599
int acpi_processor_preregister_performance(
602600
struct acpi_processor_performance __percpu *performance)
@@ -645,7 +643,8 @@ int acpi_processor_preregister_performance(
645643

646644
pr->performance = per_cpu_ptr(performance, i);
647645
cpumask_set_cpu(i, pr->performance->shared_cpu_map);
648-
if (acpi_processor_get_psd(pr)) {
646+
pdomain = &(pr->performance->domain_info);
647+
if (acpi_processor_get_psd(pr->handle, pdomain)) {
649648
retval = -EINVAL;
650649
continue;
651650
}

drivers/xen/xen-acpi-processor.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ static unsigned long *acpi_ids_done;
5353
static unsigned long *acpi_id_present;
5454
/* And if there is an _CST definition (or a PBLK) for the ACPI IDs */
5555
static unsigned long *acpi_id_cst_present;
56+
/* Which ACPI P-State dependencies for a enumerated processor */
57+
static struct acpi_psd_package *acpi_psd;
5658

5759
static int push_cxx_to_hypervisor(struct acpi_processor *_pr)
5860
{
@@ -372,6 +374,13 @@ read_acpi_id(acpi_handle handle, u32 lvl, void *context, void **rv)
372374

373375
pr_debug("ACPI CPU%u w/ PBLK:0x%lx\n", acpi_id, (unsigned long)pblk);
374376

377+
/* It has P-state dependencies */
378+
if (!acpi_processor_get_psd(handle, &acpi_psd[acpi_id])) {
379+
pr_debug("ACPI CPU%u w/ PST:coord_type = %llu domain = %llu\n",
380+
acpi_id, acpi_psd[acpi_id].coord_type,
381+
acpi_psd[acpi_id].domain);
382+
}
383+
375384
status = acpi_evaluate_object(handle, "_CST", NULL, &buffer);
376385
if (ACPI_FAILURE(status)) {
377386
if (!pblk)
@@ -405,6 +414,14 @@ static int check_acpi_ids(struct acpi_processor *pr_backup)
405414
return -ENOMEM;
406415
}
407416

417+
acpi_psd = kcalloc(nr_acpi_bits, sizeof(struct acpi_psd_package),
418+
GFP_KERNEL);
419+
if (!acpi_psd) {
420+
kfree(acpi_id_present);
421+
kfree(acpi_id_cst_present);
422+
return -ENOMEM;
423+
}
424+
408425
acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT,
409426
ACPI_UINT32_MAX,
410427
read_acpi_id, NULL, NULL, NULL);
@@ -417,6 +434,12 @@ static int check_acpi_ids(struct acpi_processor *pr_backup)
417434
pr_backup->acpi_id = i;
418435
/* Mask out C-states if there are no _CST or PBLK */
419436
pr_backup->flags.power = test_bit(i, acpi_id_cst_present);
437+
/* num_entries is non-zero if we evaluated _PSD */
438+
if (acpi_psd[i].num_entries) {
439+
memcpy(&pr_backup->performance->domain_info,
440+
&acpi_psd[i],
441+
sizeof(struct acpi_psd_package));
442+
}
420443
(void)upload_pm_data(pr_backup);
421444
}
422445
}
@@ -566,6 +589,7 @@ static void __exit xen_acpi_processor_exit(void)
566589
kfree(acpi_ids_done);
567590
kfree(acpi_id_present);
568591
kfree(acpi_id_cst_present);
592+
kfree(acpi_psd);
569593
for_each_possible_cpu(i)
570594
acpi_processor_unregister_performance(i);
571595

include/acpi/processor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ int acpi_processor_pstate_control(void);
254254
/* note: this locks both the calling module and the processor module
255255
if a _PPC object exists, rmmod is disallowed then */
256256
int acpi_processor_notify_smm(struct module *calling_module);
257+
int acpi_processor_get_psd(acpi_handle handle,
258+
struct acpi_psd_package *pdomain);
257259

258260
/* parsing the _P* objects. */
259261
extern int acpi_processor_get_performance_info(struct acpi_processor *pr);

0 commit comments

Comments
 (0)