Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ACPI: PPTT: Leave the table mapped for the runtime usage

Currently, everytime an information needs to be fetched from the PPTT,
the table is mapped via acpi_get_table() and unmapped after the use via
acpi_put_table() which is fine. However we do this at runtime especially
when the CPU is hotplugged out and plugged in back since we re-populate
the cache topology and other information.

However, with the support to fetch LLC information from the PPTT in the
cpuhotplug path which is executed in the atomic context, it is preferred
to avoid mapping and unmapping of the PPTT for every single use as the
acpi_get_table() might sleep waiting for a mutex.

In order to avoid the same, the table is needs to just mapped once on
the boot CPU and is never unmapped allowing it to be used at runtime
with out the hassle of mapping and unmapping the table.

Reported-by: Guenter Roeck <linux@roeck-us.net>
Cc: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

--

Hi Rafael,

Sorry to bother you again on this PPTT changes. Guenter reported an issue
with lockdep enabled in -next that include my cacheinfo/arch_topology changes
to utilise LLC from PPTT in the CPU hotplug path.

Please ack the change once you are happy so that I can get it merged with
other fixes via Greg's tree.

Regards,
Sudeep

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://lore.kernel.org/r/20220720-arch_topo_fixes-v3-2-43d696288e84@arm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Sudeep Holla and committed by
Greg Kroah-Hartman
0c80f9e1 11969d69

+47 -55
+47 -55
drivers/acpi/pptt.c
··· 533 533 return -ENOENT; 534 534 } 535 535 536 + 537 + static struct acpi_table_header *acpi_get_pptt(void) 538 + { 539 + static struct acpi_table_header *pptt; 540 + acpi_status status; 541 + 542 + /* 543 + * PPTT will be used at runtime on every CPU hotplug in path, so we 544 + * don't need to call acpi_put_table() to release the table mapping. 545 + */ 546 + if (!pptt) { 547 + status = acpi_get_table(ACPI_SIG_PPTT, 0, &pptt); 548 + if (ACPI_FAILURE(status)) 549 + acpi_pptt_warn_missing(); 550 + } 551 + 552 + return pptt; 553 + } 554 + 536 555 static int find_acpi_cpu_topology_tag(unsigned int cpu, int level, int flag) 537 556 { 538 557 struct acpi_table_header *table; 539 - acpi_status status; 540 558 int retval; 541 559 542 - status = acpi_get_table(ACPI_SIG_PPTT, 0, &table); 543 - if (ACPI_FAILURE(status)) { 544 - acpi_pptt_warn_missing(); 560 + table = acpi_get_pptt(); 561 + if (!table) 545 562 return -ENOENT; 546 - } 563 + 547 564 retval = topology_get_acpi_cpu_tag(table, cpu, level, flag); 548 565 pr_debug("Topology Setup ACPI CPU %d, level %d ret = %d\n", 549 566 cpu, level, retval); 550 - acpi_put_table(table); 551 567 552 568 return retval; 553 569 } ··· 584 568 static int check_acpi_cpu_flag(unsigned int cpu, int rev, u32 flag) 585 569 { 586 570 struct acpi_table_header *table; 587 - acpi_status status; 588 571 u32 acpi_cpu_id = get_acpi_id_for_cpu(cpu); 589 572 struct acpi_pptt_processor *cpu_node = NULL; 590 573 int ret = -ENOENT; 591 574 592 - status = acpi_get_table(ACPI_SIG_PPTT, 0, &table); 593 - if (ACPI_FAILURE(status)) { 594 - acpi_pptt_warn_missing(); 595 - return ret; 596 - } 575 + table = acpi_get_pptt(); 576 + if (!table) 577 + return -ENOENT; 597 578 598 579 if (table->revision >= rev) 599 580 cpu_node = acpi_find_processor_node(table, acpi_cpu_id); 600 581 601 582 if (cpu_node) 602 583 ret = (cpu_node->flags & flag) != 0; 603 - 604 - acpi_put_table(table); 605 584 606 585 return ret; 607 586 } ··· 616 605 u32 acpi_cpu_id; 617 606 struct acpi_table_header *table; 618 607 int number_of_levels = 0; 619 - acpi_status status; 608 + 609 + table = acpi_get_pptt(); 610 + if (!table) 611 + return -ENOENT; 620 612 621 613 pr_debug("Cache Setup find last level CPU=%d\n", cpu); 622 614 623 615 acpi_cpu_id = get_acpi_id_for_cpu(cpu); 624 - status = acpi_get_table(ACPI_SIG_PPTT, 0, &table); 625 - if (ACPI_FAILURE(status)) { 626 - acpi_pptt_warn_missing(); 627 - } else { 628 - number_of_levels = acpi_find_cache_levels(table, acpi_cpu_id); 629 - acpi_put_table(table); 630 - } 616 + number_of_levels = acpi_find_cache_levels(table, acpi_cpu_id); 631 617 pr_debug("Cache Setup find last level level=%d\n", number_of_levels); 632 618 633 619 return number_of_levels; ··· 646 638 int cache_setup_acpi(unsigned int cpu) 647 639 { 648 640 struct acpi_table_header *table; 649 - acpi_status status; 641 + 642 + table = acpi_get_pptt(); 643 + if (!table) 644 + return -ENOENT; 650 645 651 646 pr_debug("Cache Setup ACPI CPU %d\n", cpu); 652 647 653 - status = acpi_get_table(ACPI_SIG_PPTT, 0, &table); 654 - if (ACPI_FAILURE(status)) { 655 - acpi_pptt_warn_missing(); 656 - return -ENOENT; 657 - } 658 - 659 648 cache_setup_acpi_cpu(table, cpu); 660 - acpi_put_table(table); 661 649 662 - return status; 650 + return 0; 663 651 } 664 652 665 653 /** ··· 734 730 int find_acpi_cpu_topology_cluster(unsigned int cpu) 735 731 { 736 732 struct acpi_table_header *table; 737 - acpi_status status; 738 733 struct acpi_pptt_processor *cpu_node, *cluster_node; 739 734 u32 acpi_cpu_id; 740 735 int retval; 741 736 int is_thread; 742 737 743 - status = acpi_get_table(ACPI_SIG_PPTT, 0, &table); 744 - if (ACPI_FAILURE(status)) { 745 - acpi_pptt_warn_missing(); 738 + table = acpi_get_pptt(); 739 + if (!table) 746 740 return -ENOENT; 747 - } 748 741 749 742 acpi_cpu_id = get_acpi_id_for_cpu(cpu); 750 743 cpu_node = acpi_find_processor_node(table, acpi_cpu_id); 751 - if (cpu_node == NULL || !cpu_node->parent) { 752 - retval = -ENOENT; 753 - goto put_table; 754 - } 744 + if (!cpu_node || !cpu_node->parent) 745 + return -ENOENT; 755 746 756 747 is_thread = cpu_node->flags & ACPI_PPTT_ACPI_PROCESSOR_IS_THREAD; 757 748 cluster_node = fetch_pptt_node(table, cpu_node->parent); 758 - if (cluster_node == NULL) { 759 - retval = -ENOENT; 760 - goto put_table; 761 - } 749 + if (!cluster_node) 750 + return -ENOENT; 751 + 762 752 if (is_thread) { 763 - if (!cluster_node->parent) { 764 - retval = -ENOENT; 765 - goto put_table; 766 - } 753 + if (!cluster_node->parent) 754 + return -ENOENT; 755 + 767 756 cluster_node = fetch_pptt_node(table, cluster_node->parent); 768 - if (cluster_node == NULL) { 769 - retval = -ENOENT; 770 - goto put_table; 771 - } 757 + if (!cluster_node) 758 + return -ENOENT; 772 759 } 773 760 if (cluster_node->flags & ACPI_PPTT_ACPI_PROCESSOR_ID_VALID) 774 761 retval = cluster_node->acpi_processor_id; 775 762 else 776 763 retval = ACPI_PTR_DIFF(cluster_node, table); 777 - 778 - put_table: 779 - acpi_put_table(table); 780 764 781 765 return retval; 782 766 }