diff options
author | Suresh Siddha <suresh.b.siddha@intel.com> | 2011-05-18 19:31:33 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2011-05-20 07:40:52 -0400 |
commit | 31dce14a3269843f98ce1bc37d0c91b22f1991ee (patch) | |
tree | 66a02547580d22cc31648fd27169940b50c01ce4 /arch/x86/kernel/apic/io_apic.c | |
parent | 4c79185cdb1425fb74241d0be772ff1a9913091a (diff) |
x86, ioapic: Use ioapic_saved_data while enabling intr-remapping
Code flow for enabling interrupt-remapping was
allocating/freeing buffers for saving/restoring io-apic RTE's.
ioapic suspend/resume code uses boot time allocated
ioapic_saved_data that is a perfect match for reuse here.
This will remove the unnecessary allocation/free of the
temporary buffers during suspend/resume of interrupt-remapping
enabled platforms aswell as paving the way for further code
consolidation.
Tested-by: Daniel J Blueman <daniel.blueman@gmail.com>
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
Link: http://lkml.kernel.org/r/20110518233157.574469296@sbsiddha-MOBL3.sc.intel.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/apic/io_apic.c')
-rw-r--r-- | arch/x86/kernel/apic/io_apic.c | 80 |
1 files changed, 18 insertions, 62 deletions
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c index 8e771d32ada1..08b794d07a52 100644 --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c | |||
@@ -101,7 +101,7 @@ int mp_irq_entries; | |||
101 | static int nr_irqs_gsi = NR_IRQS_LEGACY; | 101 | static int nr_irqs_gsi = NR_IRQS_LEGACY; |
102 | 102 | ||
103 | /* | 103 | /* |
104 | * Saved I/O APIC state during suspend/resume. | 104 | * Saved I/O APIC state during suspend/resume, or while enabling intr-remap. |
105 | */ | 105 | */ |
106 | static struct IO_APIC_route_entry *ioapic_saved_data[MAX_IO_APICS]; | 106 | static struct IO_APIC_route_entry *ioapic_saved_data[MAX_IO_APICS]; |
107 | 107 | ||
@@ -628,74 +628,43 @@ static int __init ioapic_pirq_setup(char *str) | |||
628 | __setup("pirq=", ioapic_pirq_setup); | 628 | __setup("pirq=", ioapic_pirq_setup); |
629 | #endif /* CONFIG_X86_32 */ | 629 | #endif /* CONFIG_X86_32 */ |
630 | 630 | ||
631 | struct IO_APIC_route_entry **alloc_ioapic_entries(void) | ||
632 | { | ||
633 | int apic; | ||
634 | struct IO_APIC_route_entry **ioapic_entries; | ||
635 | |||
636 | ioapic_entries = kzalloc(sizeof(*ioapic_entries) * nr_ioapics, | ||
637 | GFP_ATOMIC); | ||
638 | if (!ioapic_entries) | ||
639 | return 0; | ||
640 | |||
641 | for (apic = 0; apic < nr_ioapics; apic++) { | ||
642 | ioapic_entries[apic] = | ||
643 | kzalloc(sizeof(struct IO_APIC_route_entry) * | ||
644 | nr_ioapic_registers[apic], GFP_ATOMIC); | ||
645 | if (!ioapic_entries[apic]) | ||
646 | goto nomem; | ||
647 | } | ||
648 | |||
649 | return ioapic_entries; | ||
650 | |||
651 | nomem: | ||
652 | while (--apic >= 0) | ||
653 | kfree(ioapic_entries[apic]); | ||
654 | kfree(ioapic_entries); | ||
655 | |||
656 | return 0; | ||
657 | } | ||
658 | |||
659 | /* | 631 | /* |
660 | * Saves all the IO-APIC RTE's | 632 | * Saves all the IO-APIC RTE's |
661 | */ | 633 | */ |
662 | int save_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries) | 634 | int save_ioapic_entries(void) |
663 | { | 635 | { |
664 | int apic, pin; | 636 | int apic, pin; |
665 | 637 | int err = 0; | |
666 | if (!ioapic_entries) | ||
667 | return -ENOMEM; | ||
668 | 638 | ||
669 | for (apic = 0; apic < nr_ioapics; apic++) { | 639 | for (apic = 0; apic < nr_ioapics; apic++) { |
670 | if (!ioapic_entries[apic]) | 640 | if (!ioapic_saved_data[apic]) { |
671 | return -ENOMEM; | 641 | err = -ENOMEM; |
642 | continue; | ||
643 | } | ||
672 | 644 | ||
673 | for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) | 645 | for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) |
674 | ioapic_entries[apic][pin] = | 646 | ioapic_saved_data[apic][pin] = |
675 | ioapic_read_entry(apic, pin); | 647 | ioapic_read_entry(apic, pin); |
676 | } | 648 | } |
677 | 649 | ||
678 | return 0; | 650 | return err; |
679 | } | 651 | } |
680 | 652 | ||
681 | /* | 653 | /* |
682 | * Mask all IO APIC entries. | 654 | * Mask all IO APIC entries. |
683 | */ | 655 | */ |
684 | void mask_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries) | 656 | void mask_ioapic_entries(void) |
685 | { | 657 | { |
686 | int apic, pin; | 658 | int apic, pin; |
687 | 659 | ||
688 | if (!ioapic_entries) | ||
689 | return; | ||
690 | |||
691 | for (apic = 0; apic < nr_ioapics; apic++) { | 660 | for (apic = 0; apic < nr_ioapics; apic++) { |
692 | if (!ioapic_entries[apic]) | 661 | if (!ioapic_saved_data[apic]) |
693 | break; | 662 | continue; |
694 | 663 | ||
695 | for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) { | 664 | for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) { |
696 | struct IO_APIC_route_entry entry; | 665 | struct IO_APIC_route_entry entry; |
697 | 666 | ||
698 | entry = ioapic_entries[apic][pin]; | 667 | entry = ioapic_saved_data[apic][pin]; |
699 | if (!entry.mask) { | 668 | if (!entry.mask) { |
700 | entry.mask = 1; | 669 | entry.mask = 1; |
701 | ioapic_write_entry(apic, pin, entry); | 670 | ioapic_write_entry(apic, pin, entry); |
@@ -705,36 +674,23 @@ void mask_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries) | |||
705 | } | 674 | } |
706 | 675 | ||
707 | /* | 676 | /* |
708 | * Restore IO APIC entries which was saved in ioapic_entries. | 677 | * Restore IO APIC entries which was saved in ioapic_saved_data |
709 | */ | 678 | */ |
710 | int restore_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries) | 679 | int restore_ioapic_entries(void) |
711 | { | 680 | { |
712 | int apic, pin; | 681 | int apic, pin; |
713 | 682 | ||
714 | if (!ioapic_entries) | ||
715 | return -ENOMEM; | ||
716 | |||
717 | for (apic = 0; apic < nr_ioapics; apic++) { | 683 | for (apic = 0; apic < nr_ioapics; apic++) { |
718 | if (!ioapic_entries[apic]) | 684 | if (!ioapic_saved_data[apic]) |
719 | return -ENOMEM; | 685 | continue; |
720 | 686 | ||
721 | for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) | 687 | for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) |
722 | ioapic_write_entry(apic, pin, | 688 | ioapic_write_entry(apic, pin, |
723 | ioapic_entries[apic][pin]); | 689 | ioapic_saved_data[apic][pin]); |
724 | } | 690 | } |
725 | return 0; | 691 | return 0; |
726 | } | 692 | } |
727 | 693 | ||
728 | void free_ioapic_entries(struct IO_APIC_route_entry **ioapic_entries) | ||
729 | { | ||
730 | int apic; | ||
731 | |||
732 | for (apic = 0; apic < nr_ioapics; apic++) | ||
733 | kfree(ioapic_entries[apic]); | ||
734 | |||
735 | kfree(ioapic_entries); | ||
736 | } | ||
737 | |||
738 | /* | 694 | /* |
739 | * Find the IRQ entry number of a certain pin. | 695 | * Find the IRQ entry number of a certain pin. |
740 | */ | 696 | */ |