aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoao Martins <joao.m.martins@oracle.com>2018-03-15 10:22:05 -0400
committerBoris Ostrovsky <boris.ostrovsky@oracle.com>2018-03-21 08:29:13 -0400
commit4d0f1ce6955913c490263359eadd392574cf9fe3 (patch)
tree4fc49d915e85b9c66764232442d93eba4aa7f4ec
parent36104cb9012a82e73c32a3b709257766b16bcd1d (diff)
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 <joao.m.martins@oracle.com> Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
-rw-r--r--drivers/acpi/processor_perflib.c11
-rw-r--r--drivers/xen/xen-acpi-processor.c24
-rw-r--r--include/acpi/processor.h2
3 files changed, 31 insertions, 6 deletions
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index c7cf48ad5cb9..a651ab3490d8 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -533,7 +533,7 @@ int acpi_processor_notify_smm(struct module *calling_module)
533 533
534EXPORT_SYMBOL(acpi_processor_notify_smm); 534EXPORT_SYMBOL(acpi_processor_notify_smm);
535 535
536static int acpi_processor_get_psd(struct acpi_processor *pr) 536int acpi_processor_get_psd(acpi_handle handle, struct acpi_psd_package *pdomain)
537{ 537{
538 int result = 0; 538 int result = 0;
539 acpi_status status = AE_OK; 539 acpi_status status = AE_OK;
@@ -541,9 +541,8 @@ static int acpi_processor_get_psd(struct acpi_processor *pr)
541 struct acpi_buffer format = {sizeof("NNNNN"), "NNNNN"}; 541 struct acpi_buffer format = {sizeof("NNNNN"), "NNNNN"};
542 struct acpi_buffer state = {0, NULL}; 542 struct acpi_buffer state = {0, NULL};
543 union acpi_object *psd = NULL; 543 union acpi_object *psd = NULL;
544 struct acpi_psd_package *pdomain;
545 544
546 status = acpi_evaluate_object(pr->handle, "_PSD", NULL, &buffer); 545 status = acpi_evaluate_object(handle, "_PSD", NULL, &buffer);
547 if (ACPI_FAILURE(status)) { 546 if (ACPI_FAILURE(status)) {
548 return -ENODEV; 547 return -ENODEV;
549 } 548 }
@@ -561,8 +560,6 @@ static int acpi_processor_get_psd(struct acpi_processor *pr)
561 goto end; 560 goto end;
562 } 561 }
563 562
564 pdomain = &(pr->performance->domain_info);
565
566 state.length = sizeof(struct acpi_psd_package); 563 state.length = sizeof(struct acpi_psd_package);
567 state.pointer = pdomain; 564 state.pointer = pdomain;
568 565
@@ -597,6 +594,7 @@ end:
597 kfree(buffer.pointer); 594 kfree(buffer.pointer);
598 return result; 595 return result;
599} 596}
597EXPORT_SYMBOL(acpi_processor_get_psd);
600 598
601int acpi_processor_preregister_performance( 599int acpi_processor_preregister_performance(
602 struct acpi_processor_performance __percpu *performance) 600 struct acpi_processor_performance __percpu *performance)
@@ -645,7 +643,8 @@ int acpi_processor_preregister_performance(
645 643
646 pr->performance = per_cpu_ptr(performance, i); 644 pr->performance = per_cpu_ptr(performance, i);
647 cpumask_set_cpu(i, pr->performance->shared_cpu_map); 645 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)) {
649 retval = -EINVAL; 648 retval = -EINVAL;
650 continue; 649 continue;
651 } 650 }
diff --git a/drivers/xen/xen-acpi-processor.c b/drivers/xen/xen-acpi-processor.c
index 23e391d3ec01..c80195e8fbd1 100644
--- a/drivers/xen/xen-acpi-processor.c
+++ b/drivers/xen/xen-acpi-processor.c
@@ -53,6 +53,8 @@ static unsigned long *acpi_ids_done;
53static unsigned long *acpi_id_present; 53static unsigned long *acpi_id_present;
54/* And if there is an _CST definition (or a PBLK) for the ACPI IDs */ 54/* And if there is an _CST definition (or a PBLK) for the ACPI IDs */
55static unsigned long *acpi_id_cst_present; 55static unsigned long *acpi_id_cst_present;
56/* Which ACPI P-State dependencies for a enumerated processor */
57static struct acpi_psd_package *acpi_psd;
56 58
57static int push_cxx_to_hypervisor(struct acpi_processor *_pr) 59static int push_cxx_to_hypervisor(struct acpi_processor *_pr)
58{ 60{
@@ -372,6 +374,13 @@ read_acpi_id(acpi_handle handle, u32 lvl, void *context, void **rv)
372 374
373 pr_debug("ACPI CPU%u w/ PBLK:0x%lx\n", acpi_id, (unsigned long)pblk); 375 pr_debug("ACPI CPU%u w/ PBLK:0x%lx\n", acpi_id, (unsigned long)pblk);
374 376
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
375 status = acpi_evaluate_object(handle, "_CST", NULL, &buffer); 384 status = acpi_evaluate_object(handle, "_CST", NULL, &buffer);
376 if (ACPI_FAILURE(status)) { 385 if (ACPI_FAILURE(status)) {
377 if (!pblk) 386 if (!pblk)
@@ -405,6 +414,14 @@ static int check_acpi_ids(struct acpi_processor *pr_backup)
405 return -ENOMEM; 414 return -ENOMEM;
406 } 415 }
407 416
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
408 acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT, 425 acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT,
409 ACPI_UINT32_MAX, 426 ACPI_UINT32_MAX,
410 read_acpi_id, NULL, NULL, NULL); 427 read_acpi_id, NULL, NULL, NULL);
@@ -417,6 +434,12 @@ upload:
417 pr_backup->acpi_id = i; 434 pr_backup->acpi_id = i;
418 /* Mask out C-states if there are no _CST or PBLK */ 435 /* Mask out C-states if there are no _CST or PBLK */
419 pr_backup->flags.power = test_bit(i, acpi_id_cst_present); 436 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 }
420 (void)upload_pm_data(pr_backup); 443 (void)upload_pm_data(pr_backup);
421 } 444 }
422 } 445 }
@@ -566,6 +589,7 @@ static void __exit xen_acpi_processor_exit(void)
566 kfree(acpi_ids_done); 589 kfree(acpi_ids_done);
567 kfree(acpi_id_present); 590 kfree(acpi_id_present);
568 kfree(acpi_id_cst_present); 591 kfree(acpi_id_cst_present);
592 kfree(acpi_psd);
569 for_each_possible_cpu(i) 593 for_each_possible_cpu(i)
570 acpi_processor_unregister_performance(i); 594 acpi_processor_unregister_performance(i);
571 595
diff --git a/include/acpi/processor.h b/include/acpi/processor.h
index d591bb77f592..40a916efd7c0 100644
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -254,6 +254,8 @@ int acpi_processor_pstate_control(void);
254/* note: this locks both the calling module and the processor module 254/* note: this locks both the calling module and the processor module
255 if a _PPC object exists, rmmod is disallowed then */ 255 if a _PPC object exists, rmmod is disallowed then */
256int acpi_processor_notify_smm(struct module *calling_module); 256int acpi_processor_notify_smm(struct module *calling_module);
257int acpi_processor_get_psd(acpi_handle handle,
258 struct acpi_psd_package *pdomain);
257 259
258/* parsing the _P* objects. */ 260/* parsing the _P* objects. */
259extern int acpi_processor_get_performance_info(struct acpi_processor *pr); 261extern int acpi_processor_get_performance_info(struct acpi_processor *pr);