diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-08-20 03:07:45 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-10-16 10:52:55 -0400 |
commit | 54168ed7f2a4f3fc2780e645124ae952598da601 (patch) | |
tree | 7f9693848afeeebb1d4383a2b1e7f2b0e01da85b | |
parent | 047c8fdb8718890e3340073b178d0859d0c7f91f (diff) |
x86: make io_apic_32.c the same as io_apic_64.c
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | arch/x86/kernel/io_apic_32.c | 1441 |
1 files changed, 1064 insertions, 377 deletions
diff --git a/arch/x86/kernel/io_apic_32.c b/arch/x86/kernel/io_apic_32.c index 3ed36041c81e..fba6d6ee3480 100644 --- a/arch/x86/kernel/io_apic_32.c +++ b/arch/x86/kernel/io_apic_32.c | |||
@@ -35,7 +35,7 @@ | |||
35 | #include <linux/htirq.h> | 35 | #include <linux/htirq.h> |
36 | #include <linux/freezer.h> | 36 | #include <linux/freezer.h> |
37 | #include <linux/kthread.h> | 37 | #include <linux/kthread.h> |
38 | #include <linux/jiffies.h> /* time_after() */ | 38 | #include <linux/jiffies.h> /* time_after() */ |
39 | #ifdef CONFIG_ACPI | 39 | #ifdef CONFIG_ACPI |
40 | #include <acpi/acpi_bus.h> | 40 | #include <acpi/acpi_bus.h> |
41 | #endif | 41 | #endif |
@@ -64,8 +64,8 @@ | |||
64 | #define __apicdebuginit(type) static type __init | 64 | #define __apicdebuginit(type) static type __init |
65 | 65 | ||
66 | /* | 66 | /* |
67 | * Is the SiS APIC rmw bug present ? | 67 | * Is the SiS APIC rmw bug present ? |
68 | * -1 = don't know, 0 = no, 1 = yes | 68 | * -1 = don't know, 0 = no, 1 = yes |
69 | */ | 69 | */ |
70 | int sis_apic_bug = -1; | 70 | int sis_apic_bug = -1; |
71 | 71 | ||
@@ -102,7 +102,7 @@ DECLARE_BITMAP(mp_bus_not_pci, MAX_MP_BUSSES); | |||
102 | 102 | ||
103 | int skip_ioapic_setup; | 103 | int skip_ioapic_setup; |
104 | 104 | ||
105 | static int __init parse_noapic(char *arg) | 105 | static int __init parse_noapic(char *str) |
106 | { | 106 | { |
107 | /* disable IO-APIC */ | 107 | /* disable IO-APIC */ |
108 | disable_ioapic_setup(); | 108 | disable_ioapic_setup(); |
@@ -188,7 +188,7 @@ static void __init init_work(void *data) | |||
188 | irq_cfgx[legacy_count - 1].next = NULL; | 188 | irq_cfgx[legacy_count - 1].next = NULL; |
189 | } | 189 | } |
190 | 190 | ||
191 | #define for_each_irq_cfg(cfg) \ | 191 | #define for_each_irq_cfg(cfg) \ |
192 | for (cfg = irq_cfgx; cfg; cfg = cfg->next) | 192 | for (cfg = irq_cfgx; cfg; cfg = cfg->next) |
193 | 193 | ||
194 | DEFINE_DYN_ARRAY(irq_cfgx, sizeof(struct irq_cfg), nr_irq_cfg, PAGE_SIZE, init_work); | 194 | DEFINE_DYN_ARRAY(irq_cfgx, sizeof(struct irq_cfg), nr_irq_cfg, PAGE_SIZE, init_work); |
@@ -262,7 +262,6 @@ static struct irq_cfg *irq_cfg_alloc(unsigned int irq) | |||
262 | irq_cfgx = cfg; | 262 | irq_cfgx = cfg; |
263 | cfg->irq = irq; | 263 | cfg->irq = irq; |
264 | printk(KERN_DEBUG "found new irq_cfg for irq %d\n", cfg->irq); | 264 | printk(KERN_DEBUG "found new irq_cfg for irq %d\n", cfg->irq); |
265 | |||
266 | #ifdef CONFIG_HAVE_SPARSE_IRQ_DEBUG | 265 | #ifdef CONFIG_HAVE_SPARSE_IRQ_DEBUG |
267 | { | 266 | { |
268 | /* dump the results */ | 267 | /* dump the results */ |
@@ -384,9 +383,9 @@ static inline void io_apic_write(unsigned int apic, unsigned int reg, unsigned i | |||
384 | */ | 383 | */ |
385 | static inline void io_apic_modify(unsigned int apic, unsigned int reg, unsigned int value) | 384 | static inline void io_apic_modify(unsigned int apic, unsigned int reg, unsigned int value) |
386 | { | 385 | { |
387 | volatile struct io_apic __iomem *io_apic = io_apic_base(apic); | 386 | struct io_apic __iomem *io_apic = io_apic_base(apic); |
388 | if (sis_apic_bug) | 387 | if (sis_apic_bug) |
389 | writel(reg, &io_apic->index); | 388 | writel(reg, &io_apic->index); |
390 | writel(value, &io_apic->data); | 389 | writel(value, &io_apic->data); |
391 | } | 390 | } |
392 | 391 | ||
@@ -494,11 +493,20 @@ static void __target_IO_APIC_irq(unsigned int irq, unsigned int dest, u8 vector) | |||
494 | 493 | ||
495 | apic = entry->apic; | 494 | apic = entry->apic; |
496 | pin = entry->pin; | 495 | pin = entry->pin; |
496 | #ifdef CONFIG_INTR_REMAP | ||
497 | /* | ||
498 | * With interrupt-remapping, destination information comes | ||
499 | * from interrupt-remapping table entry. | ||
500 | */ | ||
501 | if (!irq_remapped(irq)) | ||
502 | io_apic_write(apic, 0x11 + pin*2, dest); | ||
503 | #else | ||
497 | io_apic_write(apic, 0x11 + pin*2, dest); | 504 | io_apic_write(apic, 0x11 + pin*2, dest); |
505 | #endif | ||
498 | reg = io_apic_read(apic, 0x10 + pin*2); | 506 | reg = io_apic_read(apic, 0x10 + pin*2); |
499 | reg &= ~IO_APIC_REDIR_VECTOR_MASK; | 507 | reg &= ~IO_APIC_REDIR_VECTOR_MASK; |
500 | reg |= vector; | 508 | reg |= vector; |
501 | io_apic_modify(apic, 0x10 + pin *2, reg); | 509 | io_apic_modify(apic, 0x10 + pin*2, reg); |
502 | if (!entry->next) | 510 | if (!entry->next) |
503 | break; | 511 | break; |
504 | entry = entry->next; | 512 | entry = entry->next; |
@@ -513,6 +521,7 @@ static void set_ioapic_affinity_irq(unsigned int irq, cpumask_t mask) | |||
513 | unsigned long flags; | 521 | unsigned long flags; |
514 | unsigned int dest; | 522 | unsigned int dest; |
515 | cpumask_t tmp; | 523 | cpumask_t tmp; |
524 | struct irq_desc *desc; | ||
516 | 525 | ||
517 | cpus_and(tmp, mask, cpu_online_map); | 526 | cpus_and(tmp, mask, cpu_online_map); |
518 | if (cpus_empty(tmp)) | 527 | if (cpus_empty(tmp)) |
@@ -529,12 +538,12 @@ static void set_ioapic_affinity_irq(unsigned int irq, cpumask_t mask) | |||
529 | */ | 538 | */ |
530 | dest = SET_APIC_LOGICAL_ID(dest); | 539 | dest = SET_APIC_LOGICAL_ID(dest); |
531 | 540 | ||
541 | desc = irq_to_desc(irq); | ||
532 | spin_lock_irqsave(&ioapic_lock, flags); | 542 | spin_lock_irqsave(&ioapic_lock, flags); |
533 | __target_IO_APIC_irq(irq, dest, cfg->vector); | 543 | __target_IO_APIC_irq(irq, dest, cfg->vector); |
534 | irq_to_desc(irq)->affinity = mask; | 544 | desc->affinity = mask; |
535 | spin_unlock_irqrestore(&ioapic_lock, flags); | 545 | spin_unlock_irqrestore(&ioapic_lock, flags); |
536 | } | 546 | } |
537 | |||
538 | #endif /* CONFIG_SMP */ | 547 | #endif /* CONFIG_SMP */ |
539 | 548 | ||
540 | /* | 549 | /* |
@@ -699,7 +708,7 @@ static void __unmask_and_level_IO_APIC_irq(unsigned int irq) | |||
699 | 708 | ||
700 | #endif | 709 | #endif |
701 | 710 | ||
702 | static void mask_IO_APIC_irq(unsigned int irq) | 711 | static void mask_IO_APIC_irq (unsigned int irq) |
703 | { | 712 | { |
704 | unsigned long flags; | 713 | unsigned long flags; |
705 | 714 | ||
@@ -708,7 +717,7 @@ static void mask_IO_APIC_irq(unsigned int irq) | |||
708 | spin_unlock_irqrestore(&ioapic_lock, flags); | 717 | spin_unlock_irqrestore(&ioapic_lock, flags); |
709 | } | 718 | } |
710 | 719 | ||
711 | static void unmask_IO_APIC_irq(unsigned int irq) | 720 | static void unmask_IO_APIC_irq (unsigned int irq) |
712 | { | 721 | { |
713 | unsigned long flags; | 722 | unsigned long flags; |
714 | 723 | ||
@@ -725,14 +734,13 @@ static void clear_IO_APIC_pin(unsigned int apic, unsigned int pin) | |||
725 | entry = ioapic_read_entry(apic, pin); | 734 | entry = ioapic_read_entry(apic, pin); |
726 | if (entry.delivery_mode == dest_SMI) | 735 | if (entry.delivery_mode == dest_SMI) |
727 | return; | 736 | return; |
728 | |||
729 | /* | 737 | /* |
730 | * Disable it in the IO-APIC irq-routing table: | 738 | * Disable it in the IO-APIC irq-routing table: |
731 | */ | 739 | */ |
732 | ioapic_mask_entry(apic, pin); | 740 | ioapic_mask_entry(apic, pin); |
733 | } | 741 | } |
734 | 742 | ||
735 | static void clear_IO_APIC(void) | 743 | static void clear_IO_APIC (void) |
736 | { | 744 | { |
737 | int apic, pin; | 745 | int apic, pin; |
738 | 746 | ||
@@ -741,7 +749,7 @@ static void clear_IO_APIC(void) | |||
741 | clear_IO_APIC_pin(apic, pin); | 749 | clear_IO_APIC_pin(apic, pin); |
742 | } | 750 | } |
743 | 751 | ||
744 | #ifndef CONFIG_SMP | 752 | #if !defined(CONFIG_SMP) && defined(CONFIG_X86_32) |
745 | void send_IPI_self(int vector) | 753 | void send_IPI_self(int vector) |
746 | { | 754 | { |
747 | unsigned int cfg; | 755 | unsigned int cfg; |
@@ -756,9 +764,9 @@ void send_IPI_self(int vector) | |||
756 | */ | 764 | */ |
757 | apic_write(APIC_ICR, cfg); | 765 | apic_write(APIC_ICR, cfg); |
758 | } | 766 | } |
759 | #endif /* !CONFIG_SMP */ | 767 | #endif /* !CONFIG_SMP && CONFIG_X86_32*/ |
760 | |||
761 | 768 | ||
769 | #ifdef CONFIG_X86_32 | ||
762 | /* | 770 | /* |
763 | * support for broken MP BIOSs, enables hand-redirection of PIRQ0-7 to | 771 | * support for broken MP BIOSs, enables hand-redirection of PIRQ0-7 to |
764 | * specific CPU-side IRQs. | 772 | * specific CPU-side IRQs. |
@@ -797,6 +805,75 @@ static int __init ioapic_pirq_setup(char *str) | |||
797 | } | 805 | } |
798 | 806 | ||
799 | __setup("pirq=", ioapic_pirq_setup); | 807 | __setup("pirq=", ioapic_pirq_setup); |
808 | #endif /* CONFIG_X86_32 */ | ||
809 | |||
810 | #ifdef CONFIG_INTR_REMAP | ||
811 | /* I/O APIC RTE contents at the OS boot up */ | ||
812 | static struct IO_APIC_route_entry *early_ioapic_entries[MAX_IO_APICS]; | ||
813 | |||
814 | /* | ||
815 | * Saves and masks all the unmasked IO-APIC RTE's | ||
816 | */ | ||
817 | int save_mask_IO_APIC_setup(void) | ||
818 | { | ||
819 | union IO_APIC_reg_01 reg_01; | ||
820 | unsigned long flags; | ||
821 | int apic, pin; | ||
822 | |||
823 | /* | ||
824 | * The number of IO-APIC IRQ registers (== #pins): | ||
825 | */ | ||
826 | for (apic = 0; apic < nr_ioapics; apic++) { | ||
827 | spin_lock_irqsave(&ioapic_lock, flags); | ||
828 | reg_01.raw = io_apic_read(apic, 1); | ||
829 | spin_unlock_irqrestore(&ioapic_lock, flags); | ||
830 | nr_ioapic_registers[apic] = reg_01.bits.entries+1; | ||
831 | } | ||
832 | |||
833 | for (apic = 0; apic < nr_ioapics; apic++) { | ||
834 | early_ioapic_entries[apic] = | ||
835 | kzalloc(sizeof(struct IO_APIC_route_entry) * | ||
836 | nr_ioapic_registers[apic], GFP_KERNEL); | ||
837 | if (!early_ioapic_entries[apic]) | ||
838 | return -ENOMEM; | ||
839 | } | ||
840 | |||
841 | for (apic = 0; apic < nr_ioapics; apic++) | ||
842 | for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) { | ||
843 | struct IO_APIC_route_entry entry; | ||
844 | |||
845 | entry = early_ioapic_entries[apic][pin] = | ||
846 | ioapic_read_entry(apic, pin); | ||
847 | if (!entry.mask) { | ||
848 | entry.mask = 1; | ||
849 | ioapic_write_entry(apic, pin, entry); | ||
850 | } | ||
851 | } | ||
852 | return 0; | ||
853 | } | ||
854 | |||
855 | void restore_IO_APIC_setup(void) | ||
856 | { | ||
857 | int apic, pin; | ||
858 | |||
859 | for (apic = 0; apic < nr_ioapics; apic++) | ||
860 | for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) | ||
861 | ioapic_write_entry(apic, pin, | ||
862 | early_ioapic_entries[apic][pin]); | ||
863 | } | ||
864 | |||
865 | void reinit_intr_remapped_IO_APIC(int intr_remapping) | ||
866 | { | ||
867 | /* | ||
868 | * for now plain restore of previous settings. | ||
869 | * TBD: In the case of OS enabling interrupt-remapping, | ||
870 | * IO-APIC RTE's need to be setup to point to interrupt-remapping | ||
871 | * table entries. for now, do a plain restore, and wait for | ||
872 | * the setup_IO_APIC_irqs() to do proper initialization. | ||
873 | */ | ||
874 | restore_IO_APIC_setup(); | ||
875 | } | ||
876 | #endif | ||
800 | 877 | ||
801 | /* | 878 | /* |
802 | * Find the IRQ entry number of a certain pin. | 879 | * Find the IRQ entry number of a certain pin. |
@@ -848,7 +925,7 @@ static int __init find_isa_irq_apic(int irq, int type) | |||
848 | } | 925 | } |
849 | if (i < mp_irq_entries) { | 926 | if (i < mp_irq_entries) { |
850 | int apic; | 927 | int apic; |
851 | for (apic = 0; apic < nr_ioapics; apic++) { | 928 | for(apic = 0; apic < nr_ioapics; apic++) { |
852 | if (mp_ioapics[apic].mp_apicid == mp_irqs[i].mp_dstapic) | 929 | if (mp_ioapics[apic].mp_apicid == mp_irqs[i].mp_dstapic) |
853 | return apic; | 930 | return apic; |
854 | } | 931 | } |
@@ -867,10 +944,10 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin) | |||
867 | { | 944 | { |
868 | int apic, i, best_guess = -1; | 945 | int apic, i, best_guess = -1; |
869 | 946 | ||
870 | apic_printk(APIC_DEBUG, "querying PCI -> IRQ mapping bus:%d, " | 947 | apic_printk(APIC_DEBUG, "querying PCI -> IRQ mapping bus:%d, slot:%d, pin:%d.\n", |
871 | "slot:%d, pin:%d.\n", bus, slot, pin); | 948 | bus, slot, pin); |
872 | if (test_bit(bus, mp_bus_not_pci)) { | 949 | if (test_bit(bus, mp_bus_not_pci)) { |
873 | printk(KERN_WARNING "PCI BIOS passed nonexistent PCI bus %d!\n", bus); | 950 | apic_printk(APIC_VERBOSE, "PCI BIOS passed nonexistent PCI bus %d!\n", bus); |
874 | return -1; | 951 | return -1; |
875 | } | 952 | } |
876 | for (i = 0; i < mp_irq_entries; i++) { | 953 | for (i = 0; i < mp_irq_entries; i++) { |
@@ -885,7 +962,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin) | |||
885 | !mp_irqs[i].mp_irqtype && | 962 | !mp_irqs[i].mp_irqtype && |
886 | (bus == lbus) && | 963 | (bus == lbus) && |
887 | (slot == ((mp_irqs[i].mp_srcbusirq >> 2) & 0x1f))) { | 964 | (slot == ((mp_irqs[i].mp_srcbusirq >> 2) & 0x1f))) { |
888 | int irq = pin_2_irq(i, apic, mp_irqs[i].mp_dstirq); | 965 | int irq = pin_2_irq(i,apic,mp_irqs[i].mp_dstirq); |
889 | 966 | ||
890 | if (!(apic || IO_APIC_IRQ(irq))) | 967 | if (!(apic || IO_APIC_IRQ(irq))) |
891 | continue; | 968 | continue; |
@@ -902,6 +979,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin) | |||
902 | } | 979 | } |
903 | return best_guess; | 980 | return best_guess; |
904 | } | 981 | } |
982 | |||
905 | EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector); | 983 | EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector); |
906 | 984 | ||
907 | #if defined(CONFIG_EISA) || defined(CONFIG_MCA) | 985 | #if defined(CONFIG_EISA) || defined(CONFIG_MCA) |
@@ -918,6 +996,7 @@ static int EISA_ELCR(unsigned int irq) | |||
918 | "Broken MPtable reports ISA irq %d\n", irq); | 996 | "Broken MPtable reports ISA irq %d\n", irq); |
919 | return 0; | 997 | return 0; |
920 | } | 998 | } |
999 | |||
921 | #endif | 1000 | #endif |
922 | 1001 | ||
923 | /* ISA interrupts are always polarity zero edge triggered, | 1002 | /* ISA interrupts are always polarity zero edge triggered, |
@@ -954,36 +1033,36 @@ static int MPBIOS_polarity(int idx) | |||
954 | /* | 1033 | /* |
955 | * Determine IRQ line polarity (high active or low active): | 1034 | * Determine IRQ line polarity (high active or low active): |
956 | */ | 1035 | */ |
957 | switch (mp_irqs[idx].mp_irqflag & 3) { | 1036 | switch (mp_irqs[idx].mp_irqflag & 3) |
958 | case 0: /* conforms, ie. bus-type dependent polarity */ | ||
959 | { | ||
960 | polarity = test_bit(bus, mp_bus_not_pci)? | ||
961 | default_ISA_polarity(idx): | ||
962 | default_PCI_polarity(idx); | ||
963 | break; | ||
964 | } | ||
965 | case 1: /* high active */ | ||
966 | { | ||
967 | polarity = 0; | ||
968 | break; | ||
969 | } | ||
970 | case 2: /* reserved */ | ||
971 | { | ||
972 | printk(KERN_WARNING "broken BIOS!!\n"); | ||
973 | polarity = 1; | ||
974 | break; | ||
975 | } | ||
976 | case 3: /* low active */ | ||
977 | { | ||
978 | polarity = 1; | ||
979 | break; | ||
980 | } | ||
981 | default: /* invalid */ | ||
982 | { | 1037 | { |
983 | printk(KERN_WARNING "broken BIOS!!\n"); | 1038 | case 0: /* conforms, ie. bus-type dependent polarity */ |
984 | polarity = 1; | 1039 | if (test_bit(bus, mp_bus_not_pci)) |
985 | break; | 1040 | polarity = default_ISA_polarity(idx); |
986 | } | 1041 | else |
1042 | polarity = default_PCI_polarity(idx); | ||
1043 | break; | ||
1044 | case 1: /* high active */ | ||
1045 | { | ||
1046 | polarity = 0; | ||
1047 | break; | ||
1048 | } | ||
1049 | case 2: /* reserved */ | ||
1050 | { | ||
1051 | printk(KERN_WARNING "broken BIOS!!\n"); | ||
1052 | polarity = 1; | ||
1053 | break; | ||
1054 | } | ||
1055 | case 3: /* low active */ | ||
1056 | { | ||
1057 | polarity = 1; | ||
1058 | break; | ||
1059 | } | ||
1060 | default: /* invalid */ | ||
1061 | { | ||
1062 | printk(KERN_WARNING "broken BIOS!!\n"); | ||
1063 | polarity = 1; | ||
1064 | break; | ||
1065 | } | ||
987 | } | 1066 | } |
988 | return polarity; | 1067 | return polarity; |
989 | } | 1068 | } |
@@ -996,67 +1075,67 @@ static int MPBIOS_trigger(int idx) | |||
996 | /* | 1075 | /* |
997 | * Determine IRQ trigger mode (edge or level sensitive): | 1076 | * Determine IRQ trigger mode (edge or level sensitive): |
998 | */ | 1077 | */ |
999 | switch ((mp_irqs[idx].mp_irqflag>>2) & 3) { | 1078 | switch ((mp_irqs[idx].mp_irqflag>>2) & 3) |
1000 | case 0: /* conforms, ie. bus-type dependent */ | ||
1001 | { | 1079 | { |
1002 | trigger = test_bit(bus, mp_bus_not_pci)? | 1080 | case 0: /* conforms, ie. bus-type dependent */ |
1003 | default_ISA_trigger(idx): | 1081 | if (test_bit(bus, mp_bus_not_pci)) |
1004 | default_PCI_trigger(idx); | 1082 | trigger = default_ISA_trigger(idx); |
1083 | else | ||
1084 | trigger = default_PCI_trigger(idx); | ||
1005 | #if defined(CONFIG_EISA) || defined(CONFIG_MCA) | 1085 | #if defined(CONFIG_EISA) || defined(CONFIG_MCA) |
1006 | switch (mp_bus_id_to_type[bus]) { | 1086 | switch (mp_bus_id_to_type[bus]) { |
1007 | case MP_BUS_ISA: /* ISA pin */ | 1087 | case MP_BUS_ISA: /* ISA pin */ |
1008 | { | 1088 | { |
1009 | /* set before the switch */ | 1089 | /* set before the switch */ |
1090 | break; | ||
1091 | } | ||
1092 | case MP_BUS_EISA: /* EISA pin */ | ||
1093 | { | ||
1094 | trigger = default_EISA_trigger(idx); | ||
1095 | break; | ||
1096 | } | ||
1097 | case MP_BUS_PCI: /* PCI pin */ | ||
1098 | { | ||
1099 | /* set before the switch */ | ||
1100 | break; | ||
1101 | } | ||
1102 | case MP_BUS_MCA: /* MCA pin */ | ||
1103 | { | ||
1104 | trigger = default_MCA_trigger(idx); | ||
1105 | break; | ||
1106 | } | ||
1107 | default: | ||
1108 | { | ||
1109 | printk(KERN_WARNING "broken BIOS!!\n"); | ||
1110 | trigger = 1; | ||
1111 | break; | ||
1112 | } | ||
1113 | } | ||
1114 | #endif | ||
1010 | break; | 1115 | break; |
1011 | } | 1116 | case 1: /* edge */ |
1012 | case MP_BUS_EISA: /* EISA pin */ | ||
1013 | { | 1117 | { |
1014 | trigger = default_EISA_trigger(idx); | 1118 | trigger = 0; |
1015 | break; | 1119 | break; |
1016 | } | 1120 | } |
1017 | case MP_BUS_PCI: /* PCI pin */ | 1121 | case 2: /* reserved */ |
1018 | { | 1122 | { |
1019 | /* set before the switch */ | 1123 | printk(KERN_WARNING "broken BIOS!!\n"); |
1124 | trigger = 1; | ||
1020 | break; | 1125 | break; |
1021 | } | 1126 | } |
1022 | case MP_BUS_MCA: /* MCA pin */ | 1127 | case 3: /* level */ |
1023 | { | 1128 | { |
1024 | trigger = default_MCA_trigger(idx); | 1129 | trigger = 1; |
1025 | break; | 1130 | break; |
1026 | } | 1131 | } |
1027 | default: | 1132 | default: /* invalid */ |
1028 | { | 1133 | { |
1029 | printk(KERN_WARNING "broken BIOS!!\n"); | 1134 | printk(KERN_WARNING "broken BIOS!!\n"); |
1030 | trigger = 1; | 1135 | trigger = 0; |
1031 | break; | 1136 | break; |
1032 | } | 1137 | } |
1033 | } | 1138 | } |
1034 | #endif | ||
1035 | break; | ||
1036 | } | ||
1037 | case 1: /* edge */ | ||
1038 | { | ||
1039 | trigger = 0; | ||
1040 | break; | ||
1041 | } | ||
1042 | case 2: /* reserved */ | ||
1043 | { | ||
1044 | printk(KERN_WARNING "broken BIOS!!\n"); | ||
1045 | trigger = 1; | ||
1046 | break; | ||
1047 | } | ||
1048 | case 3: /* level */ | ||
1049 | { | ||
1050 | trigger = 1; | ||
1051 | break; | ||
1052 | } | ||
1053 | default: /* invalid */ | ||
1054 | { | ||
1055 | printk(KERN_WARNING "broken BIOS!!\n"); | ||
1056 | trigger = 0; | ||
1057 | break; | ||
1058 | } | ||
1059 | } | ||
1060 | return trigger; | 1139 | return trigger; |
1061 | } | 1140 | } |
1062 | 1141 | ||
@@ -1082,9 +1161,9 @@ static int pin_2_irq(int idx, int apic, int pin) | |||
1082 | if (mp_irqs[idx].mp_dstirq != pin) | 1161 | if (mp_irqs[idx].mp_dstirq != pin) |
1083 | printk(KERN_ERR "broken BIOS or MPTABLE parser, ayiee!!\n"); | 1162 | printk(KERN_ERR "broken BIOS or MPTABLE parser, ayiee!!\n"); |
1084 | 1163 | ||
1085 | if (test_bit(bus, mp_bus_not_pci)) | 1164 | if (test_bit(bus, mp_bus_not_pci)) { |
1086 | irq = mp_irqs[idx].mp_srcbusirq; | 1165 | irq = mp_irqs[idx].mp_srcbusirq; |
1087 | else { | 1166 | } else { |
1088 | /* | 1167 | /* |
1089 | * PCI IRQs are mapped in order | 1168 | * PCI IRQs are mapped in order |
1090 | */ | 1169 | */ |
@@ -1092,14 +1171,14 @@ static int pin_2_irq(int idx, int apic, int pin) | |||
1092 | while (i < apic) | 1171 | while (i < apic) |
1093 | irq += nr_ioapic_registers[i++]; | 1172 | irq += nr_ioapic_registers[i++]; |
1094 | irq += pin; | 1173 | irq += pin; |
1095 | 1174 | /* | |
1096 | /* | 1175 | * For MPS mode, so far only needed by ES7000 platform |
1097 | * For MPS mode, so far only needed by ES7000 platform | 1176 | */ |
1098 | */ | 1177 | if (ioapic_renumber_irq) |
1099 | if (ioapic_renumber_irq) | 1178 | irq = ioapic_renumber_irq(apic, irq); |
1100 | irq = ioapic_renumber_irq(apic, irq); | ||
1101 | } | 1179 | } |
1102 | 1180 | ||
1181 | #ifdef CONFIG_X86_32 | ||
1103 | /* | 1182 | /* |
1104 | * PCI IRQ command line redirection. Yes, limits are hardcoded. | 1183 | * PCI IRQ command line redirection. Yes, limits are hardcoded. |
1105 | */ | 1184 | */ |
@@ -1116,6 +1195,8 @@ static int pin_2_irq(int idx, int apic, int pin) | |||
1116 | } | 1195 | } |
1117 | } | 1196 | } |
1118 | } | 1197 | } |
1198 | #endif | ||
1199 | |||
1119 | return irq; | 1200 | return irq; |
1120 | } | 1201 | } |
1121 | 1202 | ||
@@ -1145,74 +1226,70 @@ static int __assign_irq_vector(int irq, cpumask_t mask) | |||
1145 | * Also, we've got to be careful not to trash gate | 1226 | * Also, we've got to be careful not to trash gate |
1146 | * 0x80, because int 0x80 is hm, kind of importantish. ;) | 1227 | * 0x80, because int 0x80 is hm, kind of importantish. ;) |
1147 | */ | 1228 | */ |
1148 | static int current_vector = FIRST_DEVICE_VECTOR, current_offset = 0; | 1229 | static int current_vector = FIRST_DEVICE_VECTOR, current_offset = 0; |
1149 | unsigned int old_vector; | 1230 | unsigned int old_vector; |
1150 | int cpu; | 1231 | int cpu; |
1151 | struct irq_cfg *cfg; | 1232 | struct irq_cfg *cfg; |
1152 | 1233 | ||
1153 | cfg = irq_cfg(irq); | 1234 | cfg = irq_cfg(irq); |
1154 | 1235 | ||
1155 | /* Only try and allocate irqs on cpus that are present */ | 1236 | /* Only try and allocate irqs on cpus that are present */ |
1156 | cpus_and(mask, mask, cpu_online_map); | 1237 | cpus_and(mask, mask, cpu_online_map); |
1157 | 1238 | ||
1158 | if ((cfg->move_in_progress) || cfg->move_cleanup_count) | 1239 | if ((cfg->move_in_progress) || cfg->move_cleanup_count) |
1159 | return -EBUSY; | 1240 | return -EBUSY; |
1160 | 1241 | ||
1161 | old_vector = cfg->vector; | 1242 | old_vector = cfg->vector; |
1162 | if (old_vector) { | 1243 | if (old_vector) { |
1163 | cpumask_t tmp; | 1244 | cpumask_t tmp; |
1164 | cpus_and(tmp, cfg->domain, mask); | 1245 | cpus_and(tmp, cfg->domain, mask); |
1165 | if (!cpus_empty(tmp)) | 1246 | if (!cpus_empty(tmp)) |
1166 | return 0; | 1247 | return 0; |
1167 | } | 1248 | } |
1168 | 1249 | ||
1169 | for_each_cpu_mask_nr(cpu, mask) { | 1250 | for_each_cpu_mask_nr(cpu, mask) { |
1170 | cpumask_t domain, new_mask; | 1251 | cpumask_t domain, new_mask; |
1171 | int new_cpu; | 1252 | int new_cpu; |
1172 | int vector, offset; | 1253 | int vector, offset; |
1173 | 1254 | ||
1174 | domain = vector_allocation_domain(cpu); | 1255 | domain = vector_allocation_domain(cpu); |
1175 | cpus_and(new_mask, domain, cpu_online_map); | 1256 | cpus_and(new_mask, domain, cpu_online_map); |
1176 | 1257 | ||
1177 | vector = current_vector; | 1258 | vector = current_vector; |
1178 | offset = current_offset; | 1259 | offset = current_offset; |
1179 | next: | 1260 | next: |
1180 | vector += 8; | 1261 | vector += 8; |
1181 | if (vector >= first_system_vector) { | 1262 | if (vector >= first_system_vector) { |
1182 | /* If we run out of vectors on large boxen, must share them. */ | 1263 | /* If we run out of vectors on large boxen, must share them. */ |
1183 | offset = (offset + 1) % 8; | 1264 | offset = (offset + 1) % 8; |
1184 | vector = FIRST_DEVICE_VECTOR + offset; | 1265 | vector = FIRST_DEVICE_VECTOR + offset; |
1185 | } | 1266 | } |
1186 | if (unlikely(current_vector == vector)) | 1267 | if (unlikely(current_vector == vector)) |
1187 | continue; | 1268 | continue; |
1188 | #ifdef CONFIG_X86_64 | 1269 | #ifdef CONFIG_X86_64 |
1189 | if (vector == IA32_SYSCALL_VECTOR) | 1270 | if (vector == IA32_SYSCALL_VECTOR) |
1190 | goto next; | 1271 | goto next; |
1191 | #else | 1272 | #else |
1192 | if (vector == SYSCALL_VECTOR) | 1273 | if (vector == SYSCALL_VECTOR) |
1193 | goto next; | 1274 | goto next; |
1194 | #endif | 1275 | #endif |
1195 | for_each_cpu_mask_nr(new_cpu, new_mask) | 1276 | for_each_cpu_mask_nr(new_cpu, new_mask) |
1196 | if (per_cpu(vector_irq, new_cpu)[vector] != -1) | 1277 | if (per_cpu(vector_irq, new_cpu)[vector] != -1) |
1197 | goto next; | 1278 | goto next; |
1198 | /* Found one! */ | 1279 | /* Found one! */ |
1199 | current_vector = vector; | 1280 | current_vector = vector; |
1200 | current_offset = offset; | 1281 | current_offset = offset; |
1201 | if (old_vector) { | 1282 | if (old_vector) { |
1202 | cfg->move_in_progress = 1; | 1283 | cfg->move_in_progress = 1; |
1203 | cfg->old_domain = cfg->domain; | 1284 | cfg->old_domain = cfg->domain; |
1204 | } | ||
1205 | printk(KERN_DEBUG "assign_irq_vector: irq %d vector %#x cpu ", irq, vector); | ||
1206 | for_each_cpu_mask_nr(new_cpu, new_mask) { | ||
1207 | per_cpu(vector_irq, new_cpu)[vector] = irq; | ||
1208 | printk(KERN_CONT " %d ", new_cpu); | ||
1209 | } | 1285 | } |
1210 | printk(KERN_CONT "\n"); | 1286 | for_each_cpu_mask_nr(new_cpu, new_mask) |
1211 | cfg->vector = vector; | 1287 | per_cpu(vector_irq, new_cpu)[vector] = irq; |
1212 | cfg->domain = domain; | 1288 | cfg->vector = vector; |
1213 | return 0; | 1289 | cfg->domain = domain; |
1214 | } | 1290 | return 0; |
1215 | return -ENOSPC; | 1291 | } |
1292 | return -ENOSPC; | ||
1216 | } | 1293 | } |
1217 | 1294 | ||
1218 | static int assign_irq_vector(int irq, cpumask_t mask) | 1295 | static int assign_irq_vector(int irq, cpumask_t mask) |
@@ -1223,7 +1300,6 @@ static int assign_irq_vector(int irq, cpumask_t mask) | |||
1223 | spin_lock_irqsave(&vector_lock, flags); | 1300 | spin_lock_irqsave(&vector_lock, flags); |
1224 | err = __assign_irq_vector(irq, mask); | 1301 | err = __assign_irq_vector(irq, mask); |
1225 | spin_unlock_irqrestore(&vector_lock, flags); | 1302 | spin_unlock_irqrestore(&vector_lock, flags); |
1226 | |||
1227 | return err; | 1303 | return err; |
1228 | } | 1304 | } |
1229 | 1305 | ||
@@ -1269,36 +1345,39 @@ void __setup_vector_irq(int cpu) | |||
1269 | cfg = irq_cfg(irq); | 1345 | cfg = irq_cfg(irq); |
1270 | if (!cpu_isset(cpu, cfg->domain)) | 1346 | if (!cpu_isset(cpu, cfg->domain)) |
1271 | per_cpu(vector_irq, cpu)[vector] = -1; | 1347 | per_cpu(vector_irq, cpu)[vector] = -1; |
1272 | } | 1348 | } |
1273 | } | 1349 | } |
1274 | 1350 | ||
1275 | static struct irq_chip ioapic_chip; | 1351 | static struct irq_chip ioapic_chip; |
1352 | #ifdef CONFIG_INTR_REMAP | ||
1353 | static struct irq_chip ir_ioapic_chip; | ||
1354 | #endif | ||
1276 | 1355 | ||
1277 | #define IOAPIC_AUTO -1 | 1356 | #define IOAPIC_AUTO -1 |
1278 | #define IOAPIC_EDGE 0 | 1357 | #define IOAPIC_EDGE 0 |
1279 | #define IOAPIC_LEVEL 1 | 1358 | #define IOAPIC_LEVEL 1 |
1280 | 1359 | ||
1281 | #ifdef CONFIG_X86_32 | 1360 | #ifdef CONFIG_X86_32 |
1282 | static inline int IO_APIC_irq_trigger(int irq) | 1361 | static inline int IO_APIC_irq_trigger(int irq) |
1283 | { | 1362 | { |
1284 | int apic, idx, pin; | 1363 | int apic, idx, pin; |
1285 | 1364 | ||
1286 | for (apic = 0; apic < nr_ioapics; apic++) { | 1365 | for (apic = 0; apic < nr_ioapics; apic++) { |
1287 | for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) { | 1366 | for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) { |
1288 | idx = find_irq_entry(apic, pin, mp_INT); | 1367 | idx = find_irq_entry(apic, pin, mp_INT); |
1289 | if ((idx != -1) && (irq == pin_2_irq(idx, apic, pin))) | 1368 | if ((idx != -1) && (irq == pin_2_irq(idx, apic, pin))) |
1290 | return irq_trigger(idx); | 1369 | return irq_trigger(idx); |
1291 | } | 1370 | } |
1292 | } | 1371 | } |
1293 | /* | 1372 | /* |
1294 | * nonexistent IRQs are edge default | 1373 | * nonexistent IRQs are edge default |
1295 | */ | 1374 | */ |
1296 | return 0; | 1375 | return 0; |
1297 | } | 1376 | } |
1298 | #else | 1377 | #else |
1299 | static inline int IO_APIC_irq_trigger(int irq) | 1378 | static inline int IO_APIC_irq_trigger(int irq) |
1300 | { | 1379 | { |
1301 | return 1; | 1380 | return 1; |
1302 | } | 1381 | } |
1303 | #endif | 1382 | #endif |
1304 | 1383 | ||
@@ -1318,13 +1397,27 @@ static void ioapic_register_intr(int irq, unsigned long trigger) | |||
1318 | else | 1397 | else |
1319 | desc->status &= ~IRQ_LEVEL; | 1398 | desc->status &= ~IRQ_LEVEL; |
1320 | 1399 | ||
1400 | #ifdef CONFIG_INTR_REMAP | ||
1401 | if (irq_remapped(irq)) { | ||
1402 | desc->status |= IRQ_MOVE_PCNTXT; | ||
1403 | if (trigger) | ||
1404 | set_irq_chip_and_handler_name(irq, &ir_ioapic_chip, | ||
1405 | handle_fasteoi_irq, | ||
1406 | "fasteoi"); | ||
1407 | else | ||
1408 | set_irq_chip_and_handler_name(irq, &ir_ioapic_chip, | ||
1409 | handle_edge_irq, "edge"); | ||
1410 | return; | ||
1411 | } | ||
1412 | #endif | ||
1321 | if ((trigger == IOAPIC_AUTO && IO_APIC_irq_trigger(irq)) || | 1413 | if ((trigger == IOAPIC_AUTO && IO_APIC_irq_trigger(irq)) || |
1322 | trigger == IOAPIC_LEVEL) | 1414 | trigger == IOAPIC_LEVEL) |
1323 | set_irq_chip_and_handler_name(irq, &ioapic_chip, | 1415 | set_irq_chip_and_handler_name(irq, &ioapic_chip, |
1324 | handle_fasteoi_irq, "fasteoi"); | 1416 | handle_fasteoi_irq, |
1417 | "fasteoi"); | ||
1325 | else | 1418 | else |
1326 | set_irq_chip_and_handler_name(irq, &ioapic_chip, | 1419 | set_irq_chip_and_handler_name(irq, &ioapic_chip, |
1327 | handle_edge_irq, "edge"); | 1420 | handle_edge_irq, "edge"); |
1328 | } | 1421 | } |
1329 | 1422 | ||
1330 | static int setup_ioapic_entry(int apic, int irq, | 1423 | static int setup_ioapic_entry(int apic, int irq, |
@@ -1337,11 +1430,45 @@ static int setup_ioapic_entry(int apic, int irq, | |||
1337 | */ | 1430 | */ |
1338 | memset(entry,0,sizeof(*entry)); | 1431 | memset(entry,0,sizeof(*entry)); |
1339 | 1432 | ||
1340 | entry->delivery_mode = INT_DELIVERY_MODE; | 1433 | #ifdef CONFIG_INTR_REMAP |
1341 | entry->dest_mode = INT_DEST_MODE; | 1434 | if (intr_remapping_enabled) { |
1342 | entry->dest = destination; | 1435 | struct intel_iommu *iommu = map_ioapic_to_ir(apic); |
1436 | struct irte irte; | ||
1437 | struct IR_IO_APIC_route_entry *ir_entry = | ||
1438 | (struct IR_IO_APIC_route_entry *) entry; | ||
1439 | int index; | ||
1440 | |||
1441 | if (!iommu) | ||
1442 | panic("No mapping iommu for ioapic %d\n", apic); | ||
1443 | |||
1444 | index = alloc_irte(iommu, irq, 1); | ||
1445 | if (index < 0) | ||
1446 | panic("Failed to allocate IRTE for ioapic %d\n", apic); | ||
1447 | |||
1448 | memset(&irte, 0, sizeof(irte)); | ||
1449 | |||
1450 | irte.present = 1; | ||
1451 | irte.dst_mode = INT_DEST_MODE; | ||
1452 | irte.trigger_mode = trigger; | ||
1453 | irte.dlvry_mode = INT_DELIVERY_MODE; | ||
1454 | irte.vector = vector; | ||
1455 | irte.dest_id = IRTE_DEST(destination); | ||
1456 | |||
1457 | modify_irte(irq, &irte); | ||
1458 | |||
1459 | ir_entry->index2 = (index >> 15) & 0x1; | ||
1460 | ir_entry->zero = 0; | ||
1461 | ir_entry->format = 1; | ||
1462 | ir_entry->index = (index & 0x7fff); | ||
1463 | } else | ||
1464 | #endif | ||
1465 | { | ||
1466 | entry->delivery_mode = INT_DELIVERY_MODE; | ||
1467 | entry->dest_mode = INT_DEST_MODE; | ||
1468 | entry->dest = destination; | ||
1469 | } | ||
1343 | 1470 | ||
1344 | entry->mask = 0; /* enable IRQ */ | 1471 | entry->mask = 0; /* enable IRQ */ |
1345 | entry->trigger = trigger; | 1472 | entry->trigger = trigger; |
1346 | entry->polarity = polarity; | 1473 | entry->polarity = polarity; |
1347 | entry->vector = vector; | 1474 | entry->vector = vector; |
@@ -1351,12 +1478,11 @@ static int setup_ioapic_entry(int apic, int irq, | |||
1351 | */ | 1478 | */ |
1352 | if (trigger) | 1479 | if (trigger) |
1353 | entry->mask = 1; | 1480 | entry->mask = 1; |
1354 | |||
1355 | return 0; | 1481 | return 0; |
1356 | } | 1482 | } |
1357 | 1483 | ||
1358 | static void setup_IO_APIC_irq(int apic, int pin, unsigned int irq, | 1484 | static void setup_IO_APIC_irq(int apic, int pin, unsigned int irq, |
1359 | int trigger, int polarity) | 1485 | int trigger, int polarity) |
1360 | { | 1486 | { |
1361 | struct irq_cfg *cfg; | 1487 | struct irq_cfg *cfg; |
1362 | struct IO_APIC_route_entry entry; | 1488 | struct IO_APIC_route_entry entry; |
@@ -1420,10 +1546,10 @@ static void __init setup_IO_APIC_irqs(void) | |||
1420 | } | 1546 | } |
1421 | 1547 | ||
1422 | irq = pin_2_irq(idx, apic, pin); | 1548 | irq = pin_2_irq(idx, apic, pin); |
1423 | 1549 | #ifdef CONFIG_X86_32 | |
1424 | if (multi_timer_check(apic, irq)) | 1550 | if (multi_timer_check(apic, irq)) |
1425 | continue; | 1551 | continue; |
1426 | 1552 | #endif | |
1427 | add_pin_to_irq(irq, apic, pin); | 1553 | add_pin_to_irq(irq, apic, pin); |
1428 | 1554 | ||
1429 | setup_IO_APIC_irq(apic, pin, irq, | 1555 | setup_IO_APIC_irq(apic, pin, irq, |
@@ -1443,6 +1569,11 @@ static void __init setup_timer_IRQ0_pin(unsigned int apic, unsigned int pin, | |||
1443 | { | 1569 | { |
1444 | struct IO_APIC_route_entry entry; | 1570 | struct IO_APIC_route_entry entry; |
1445 | 1571 | ||
1572 | #ifdef CONFIG_INTR_REMAP | ||
1573 | if (intr_remapping_enabled) | ||
1574 | return; | ||
1575 | #endif | ||
1576 | |||
1446 | memset(&entry, 0, sizeof(entry)); | 1577 | memset(&entry, 0, sizeof(entry)); |
1447 | 1578 | ||
1448 | /* | 1579 | /* |
@@ -1461,7 +1592,7 @@ static void __init setup_timer_IRQ0_pin(unsigned int apic, unsigned int pin, | |||
1461 | * The timer IRQ doesn't have to know that behind the | 1592 | * The timer IRQ doesn't have to know that behind the |
1462 | * scene we may have a 8259A-master in AEOI mode ... | 1593 | * scene we may have a 8259A-master in AEOI mode ... |
1463 | */ | 1594 | */ |
1464 | ioapic_register_intr(0, IOAPIC_EDGE); | 1595 | set_irq_chip_and_handler_name(0, &ioapic_chip, handle_edge_irq, "edge"); |
1465 | 1596 | ||
1466 | /* | 1597 | /* |
1467 | * Add it to the IO-APIC irq-routing table: | 1598 | * Add it to the IO-APIC irq-routing table: |
@@ -1501,17 +1632,18 @@ __apicdebuginit(void) print_IO_APIC(void) | |||
1501 | reg_01.raw = io_apic_read(apic, 1); | 1632 | reg_01.raw = io_apic_read(apic, 1); |
1502 | if (reg_01.bits.version >= 0x10) | 1633 | if (reg_01.bits.version >= 0x10) |
1503 | reg_02.raw = io_apic_read(apic, 2); | 1634 | reg_02.raw = io_apic_read(apic, 2); |
1504 | if (reg_01.bits.version >= 0x20) | 1635 | if (reg_01.bits.version >= 0x20) |
1505 | reg_03.raw = io_apic_read(apic, 3); | 1636 | reg_03.raw = io_apic_read(apic, 3); |
1506 | spin_unlock_irqrestore(&ioapic_lock, flags); | 1637 | spin_unlock_irqrestore(&ioapic_lock, flags); |
1507 | 1638 | ||
1639 | printk("\n"); | ||
1508 | printk(KERN_DEBUG "IO APIC #%d......\n", mp_ioapics[apic].mp_apicid); | 1640 | printk(KERN_DEBUG "IO APIC #%d......\n", mp_ioapics[apic].mp_apicid); |
1509 | printk(KERN_DEBUG ".... register #00: %08X\n", reg_00.raw); | 1641 | printk(KERN_DEBUG ".... register #00: %08X\n", reg_00.raw); |
1510 | printk(KERN_DEBUG "....... : physical APIC id: %02X\n", reg_00.bits.ID); | 1642 | printk(KERN_DEBUG "....... : physical APIC id: %02X\n", reg_00.bits.ID); |
1511 | printk(KERN_DEBUG "....... : Delivery Type: %X\n", reg_00.bits.delivery_type); | 1643 | printk(KERN_DEBUG "....... : Delivery Type: %X\n", reg_00.bits.delivery_type); |
1512 | printk(KERN_DEBUG "....... : LTS : %X\n", reg_00.bits.LTS); | 1644 | printk(KERN_DEBUG "....... : LTS : %X\n", reg_00.bits.LTS); |
1513 | 1645 | ||
1514 | printk(KERN_DEBUG ".... register #01: %08X\n", reg_01.raw); | 1646 | printk(KERN_DEBUG ".... register #01: %08X\n", *(int *)®_01); |
1515 | printk(KERN_DEBUG "....... : max redirection entries: %04X\n", reg_01.bits.entries); | 1647 | printk(KERN_DEBUG "....... : max redirection entries: %04X\n", reg_01.bits.entries); |
1516 | 1648 | ||
1517 | printk(KERN_DEBUG "....... : PRQ implemented: %X\n", reg_01.bits.PRQ); | 1649 | printk(KERN_DEBUG "....... : PRQ implemented: %X\n", reg_01.bits.PRQ); |
@@ -1548,7 +1680,10 @@ __apicdebuginit(void) print_IO_APIC(void) | |||
1548 | 1680 | ||
1549 | entry = ioapic_read_entry(apic, i); | 1681 | entry = ioapic_read_entry(apic, i); |
1550 | 1682 | ||
1551 | printk(KERN_DEBUG " %02x %02X ", i, entry.dest); | 1683 | printk(KERN_DEBUG " %02x %03X ", |
1684 | i, | ||
1685 | entry.dest | ||
1686 | ); | ||
1552 | 1687 | ||
1553 | printk("%1d %1d %1d %1d %1d %1d %1d %02X\n", | 1688 | printk("%1d %1d %1d %1d %1d %1d %1d %02X\n", |
1554 | entry.mask, | 1689 | entry.mask, |
@@ -1567,7 +1702,7 @@ __apicdebuginit(void) print_IO_APIC(void) | |||
1567 | struct irq_pin_list *entry = cfg->irq_2_pin; | 1702 | struct irq_pin_list *entry = cfg->irq_2_pin; |
1568 | if (!entry) | 1703 | if (!entry) |
1569 | continue; | 1704 | continue; |
1570 | printk(KERN_DEBUG "IRQ%d ", i); | 1705 | printk(KERN_DEBUG "IRQ%d ", cfg->irq); |
1571 | for (;;) { | 1706 | for (;;) { |
1572 | printk("-> %d:%d", entry->apic, entry->pin); | 1707 | printk("-> %d:%d", entry->apic, entry->pin); |
1573 | if (!entry->next) | 1708 | if (!entry->next) |
@@ -1614,8 +1749,7 @@ __apicdebuginit(void) print_local_APIC(void *dummy) | |||
1614 | printk("\n" KERN_DEBUG "printing local APIC contents on CPU#%d/%d:\n", | 1749 | printk("\n" KERN_DEBUG "printing local APIC contents on CPU#%d/%d:\n", |
1615 | smp_processor_id(), hard_smp_processor_id()); | 1750 | smp_processor_id(), hard_smp_processor_id()); |
1616 | v = apic_read(APIC_ID); | 1751 | v = apic_read(APIC_ID); |
1617 | printk(KERN_INFO "... APIC ID: %08x (%01x)\n", v, | 1752 | printk(KERN_INFO "... APIC ID: %08x (%01x)\n", v, read_apic_id()); |
1618 | GET_APIC_ID(v)); | ||
1619 | v = apic_read(APIC_LVR); | 1753 | v = apic_read(APIC_LVR); |
1620 | printk(KERN_INFO "... APIC VERSION: %08x\n", v); | 1754 | printk(KERN_INFO "... APIC VERSION: %08x\n", v); |
1621 | ver = GET_APIC_VERSION(v); | 1755 | ver = GET_APIC_VERSION(v); |
@@ -1624,7 +1758,7 @@ __apicdebuginit(void) print_local_APIC(void *dummy) | |||
1624 | v = apic_read(APIC_TASKPRI); | 1758 | v = apic_read(APIC_TASKPRI); |
1625 | printk(KERN_DEBUG "... APIC TASKPRI: %08x (%02x)\n", v, v & APIC_TPRI_MASK); | 1759 | printk(KERN_DEBUG "... APIC TASKPRI: %08x (%02x)\n", v, v & APIC_TPRI_MASK); |
1626 | 1760 | ||
1627 | if (APIC_INTEGRATED(ver)) { /* !82489DX */ | 1761 | if (APIC_INTEGRATED(ver)) { /* !82489DX */ |
1628 | v = apic_read(APIC_ARBPRI); | 1762 | v = apic_read(APIC_ARBPRI); |
1629 | printk(KERN_DEBUG "... APIC ARBPRI: %08x (%02x)\n", v, | 1763 | printk(KERN_DEBUG "... APIC ARBPRI: %08x (%02x)\n", v, |
1630 | v & APIC_ARBPRI_MASK); | 1764 | v & APIC_ARBPRI_MASK); |
@@ -1650,9 +1784,10 @@ __apicdebuginit(void) print_local_APIC(void *dummy) | |||
1650 | printk(KERN_DEBUG "... APIC IRR field:\n"); | 1784 | printk(KERN_DEBUG "... APIC IRR field:\n"); |
1651 | print_APIC_bitfield(APIC_IRR); | 1785 | print_APIC_bitfield(APIC_IRR); |
1652 | 1786 | ||
1653 | if (APIC_INTEGRATED(ver)) { /* !82489DX */ | 1787 | if (APIC_INTEGRATED(ver)) { /* !82489DX */ |
1654 | if (maxlvt > 3) /* Due to the Pentium erratum 3AP. */ | 1788 | if (maxlvt > 3) /* Due to the Pentium erratum 3AP. */ |
1655 | apic_write(APIC_ESR, 0); | 1789 | apic_write(APIC_ESR, 0); |
1790 | |||
1656 | v = apic_read(APIC_ESR); | 1791 | v = apic_read(APIC_ESR); |
1657 | printk(KERN_DEBUG "... APIC ESR: %08x\n", v); | 1792 | printk(KERN_DEBUG "... APIC ESR: %08x\n", v); |
1658 | } | 1793 | } |
@@ -1710,11 +1845,11 @@ __apicdebuginit(void) print_PIC(void) | |||
1710 | v = inb(0xa0) << 8 | inb(0x20); | 1845 | v = inb(0xa0) << 8 | inb(0x20); |
1711 | printk(KERN_DEBUG "... PIC IRR: %04x\n", v); | 1846 | printk(KERN_DEBUG "... PIC IRR: %04x\n", v); |
1712 | 1847 | ||
1713 | outb(0x0b, 0xa0); | 1848 | outb(0x0b,0xa0); |
1714 | outb(0x0b, 0x20); | 1849 | outb(0x0b,0x20); |
1715 | v = inb(0xa0) << 8 | inb(0x20); | 1850 | v = inb(0xa0) << 8 | inb(0x20); |
1716 | outb(0x0a, 0xa0); | 1851 | outb(0x0a,0xa0); |
1717 | outb(0x0a, 0x20); | 1852 | outb(0x0a,0x20); |
1718 | 1853 | ||
1719 | spin_unlock_irqrestore(&i8259A_lock, flags); | 1854 | spin_unlock_irqrestore(&i8259A_lock, flags); |
1720 | 1855 | ||
@@ -1739,16 +1874,19 @@ fs_initcall(print_all_ICs); | |||
1739 | /* Where if anywhere is the i8259 connect in external int mode */ | 1874 | /* Where if anywhere is the i8259 connect in external int mode */ |
1740 | static struct { int pin, apic; } ioapic_i8259 = { -1, -1 }; | 1875 | static struct { int pin, apic; } ioapic_i8259 = { -1, -1 }; |
1741 | 1876 | ||
1742 | static void __init enable_IO_APIC(void) | 1877 | void __init enable_IO_APIC(void) |
1743 | { | 1878 | { |
1744 | union IO_APIC_reg_01 reg_01; | 1879 | union IO_APIC_reg_01 reg_01; |
1745 | int i8259_apic, i8259_pin; | 1880 | int i8259_apic, i8259_pin; |
1746 | int i, apic; | 1881 | int apic; |
1747 | unsigned long flags; | 1882 | unsigned long flags; |
1748 | 1883 | ||
1884 | #ifdef CONFIG_X86_32 | ||
1885 | int i; | ||
1749 | if (!pirqs_enabled) | 1886 | if (!pirqs_enabled) |
1750 | for (i = 0; i < MAX_PIRQS; i++) | 1887 | for (i = 0; i < MAX_PIRQS; i++) |
1751 | pirq_entries[i] = -1; | 1888 | pirq_entries[i] = -1; |
1889 | #endif | ||
1752 | 1890 | ||
1753 | /* | 1891 | /* |
1754 | * The number of IO-APIC IRQ registers (== #pins): | 1892 | * The number of IO-APIC IRQ registers (== #pins): |
@@ -1759,7 +1897,7 @@ static void __init enable_IO_APIC(void) | |||
1759 | spin_unlock_irqrestore(&ioapic_lock, flags); | 1897 | spin_unlock_irqrestore(&ioapic_lock, flags); |
1760 | nr_ioapic_registers[apic] = reg_01.bits.entries+1; | 1898 | nr_ioapic_registers[apic] = reg_01.bits.entries+1; |
1761 | } | 1899 | } |
1762 | for (apic = 0; apic < nr_ioapics; apic++) { | 1900 | for(apic = 0; apic < nr_ioapics; apic++) { |
1763 | int pin; | 1901 | int pin; |
1764 | /* See if any of the pins is in ExtINT mode */ | 1902 | /* See if any of the pins is in ExtINT mode */ |
1765 | for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) { | 1903 | for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) { |
@@ -1830,16 +1968,18 @@ void disable_IO_APIC(void) | |||
1830 | entry.dest_mode = 0; /* Physical */ | 1968 | entry.dest_mode = 0; /* Physical */ |
1831 | entry.delivery_mode = dest_ExtINT; /* ExtInt */ | 1969 | entry.delivery_mode = dest_ExtINT; /* ExtInt */ |
1832 | entry.vector = 0; | 1970 | entry.vector = 0; |
1833 | entry.dest = read_apic_id(); | 1971 | entry.dest = read_apic_id(); |
1834 | 1972 | ||
1835 | /* | 1973 | /* |
1836 | * Add it to the IO-APIC irq-routing table: | 1974 | * Add it to the IO-APIC irq-routing table: |
1837 | */ | 1975 | */ |
1838 | ioapic_write_entry(ioapic_i8259.apic, ioapic_i8259.pin, entry); | 1976 | ioapic_write_entry(ioapic_i8259.apic, ioapic_i8259.pin, entry); |
1839 | } | 1977 | } |
1978 | |||
1840 | disconnect_bsp_APIC(ioapic_i8259.pin != -1); | 1979 | disconnect_bsp_APIC(ioapic_i8259.pin != -1); |
1841 | } | 1980 | } |
1842 | 1981 | ||
1982 | #ifdef CONFIG_X86_32 | ||
1843 | /* | 1983 | /* |
1844 | * function to set the IO-APIC physical IDs based on the | 1984 | * function to set the IO-APIC physical IDs based on the |
1845 | * values stored in the MPC table. | 1985 | * values stored in the MPC table. |
@@ -1940,8 +2080,6 @@ static void __init setup_ioapic_ids_from_mpc(void) | |||
1940 | 2080 | ||
1941 | reg_00.bits.ID = mp_ioapics[apic].mp_apicid; | 2081 | reg_00.bits.ID = mp_ioapics[apic].mp_apicid; |
1942 | spin_lock_irqsave(&ioapic_lock, flags); | 2082 | spin_lock_irqsave(&ioapic_lock, flags); |
1943 | io_apic_write(apic, 0, reg_00.raw); | ||
1944 | spin_unlock_irqrestore(&ioapic_lock, flags); | ||
1945 | 2083 | ||
1946 | /* | 2084 | /* |
1947 | * Sanity check | 2085 | * Sanity check |
@@ -1955,6 +2093,7 @@ static void __init setup_ioapic_ids_from_mpc(void) | |||
1955 | apic_printk(APIC_VERBOSE, " ok.\n"); | 2093 | apic_printk(APIC_VERBOSE, " ok.\n"); |
1956 | } | 2094 | } |
1957 | } | 2095 | } |
2096 | #endif | ||
1958 | 2097 | ||
1959 | int no_timer_check __initdata; | 2098 | int no_timer_check __initdata; |
1960 | 2099 | ||
@@ -1994,9 +2133,10 @@ static int __init timer_irq_works(void) | |||
1994 | * might have cached one ExtINT interrupt. Finally, at | 2133 | * might have cached one ExtINT interrupt. Finally, at |
1995 | * least one tick may be lost due to delays. | 2134 | * least one tick may be lost due to delays. |
1996 | */ | 2135 | */ |
2136 | |||
2137 | /* jiffies wrap? */ | ||
1997 | if (time_after(jiffies, t1 + 4)) | 2138 | if (time_after(jiffies, t1 + 4)) |
1998 | return 1; | 2139 | return 1; |
1999 | |||
2000 | return 0; | 2140 | return 0; |
2001 | } | 2141 | } |
2002 | 2142 | ||
@@ -2014,8 +2154,6 @@ static int __init timer_irq_works(void) | |||
2014 | */ | 2154 | */ |
2015 | 2155 | ||
2016 | /* | 2156 | /* |
2017 | * Startup quirk: | ||
2018 | * | ||
2019 | * Starting up a edge-triggered IO-APIC interrupt is | 2157 | * Starting up a edge-triggered IO-APIC interrupt is |
2020 | * nasty - we need to make sure that we get the edge. | 2158 | * nasty - we need to make sure that we get the edge. |
2021 | * If it is already asserted for some reason, we need | 2159 | * If it is already asserted for some reason, we need |
@@ -2023,9 +2161,8 @@ static int __init timer_irq_works(void) | |||
2023 | * | 2161 | * |
2024 | * This is not complete - we should be able to fake | 2162 | * This is not complete - we should be able to fake |
2025 | * an edge even if it isn't on the 8259A... | 2163 | * an edge even if it isn't on the 8259A... |
2026 | * | ||
2027 | * (We do this for level-triggered IRQs too - it cannot hurt.) | ||
2028 | */ | 2164 | */ |
2165 | |||
2029 | static unsigned int startup_ioapic_irq(unsigned int irq) | 2166 | static unsigned int startup_ioapic_irq(unsigned int irq) |
2030 | { | 2167 | { |
2031 | int was_pending = 0; | 2168 | int was_pending = 0; |
@@ -2043,18 +2180,191 @@ static unsigned int startup_ioapic_irq(unsigned int irq) | |||
2043 | return was_pending; | 2180 | return was_pending; |
2044 | } | 2181 | } |
2045 | 2182 | ||
2183 | #ifdef CONFIG_X86_64 | ||
2046 | static int ioapic_retrigger_irq(unsigned int irq) | 2184 | static int ioapic_retrigger_irq(unsigned int irq) |
2047 | { | 2185 | { |
2048 | send_IPI_self(irq_cfg(irq)->vector); | 2186 | |
2187 | struct irq_cfg *cfg = irq_cfg(irq); | ||
2188 | unsigned long flags; | ||
2189 | |||
2190 | spin_lock_irqsave(&vector_lock, flags); | ||
2191 | send_IPI_mask(cpumask_of_cpu(first_cpu(cfg->domain)), cfg->vector); | ||
2192 | spin_unlock_irqrestore(&vector_lock, flags); | ||
2049 | 2193 | ||
2050 | return 1; | 2194 | return 1; |
2051 | } | 2195 | } |
2196 | #else | ||
2197 | static int ioapic_retrigger_irq(unsigned int irq) | ||
2198 | { | ||
2199 | send_IPI_self(irq_cfg(irq)->vector); | ||
2200 | |||
2201 | return 1; | ||
2202 | } | ||
2203 | #endif | ||
2204 | |||
2205 | /* | ||
2206 | * Level and edge triggered IO-APIC interrupts need different handling, | ||
2207 | * so we use two separate IRQ descriptors. Edge triggered IRQs can be | ||
2208 | * handled with the level-triggered descriptor, but that one has slightly | ||
2209 | * more overhead. Level-triggered interrupts cannot be handled with the | ||
2210 | * edge-triggered handler, without risking IRQ storms and other ugly | ||
2211 | * races. | ||
2212 | */ | ||
2052 | 2213 | ||
2053 | #ifdef CONFIG_SMP | 2214 | #ifdef CONFIG_SMP |
2215 | |||
2216 | #ifdef CONFIG_INTR_REMAP | ||
2217 | static void ir_irq_migration(struct work_struct *work); | ||
2218 | |||
2219 | static DECLARE_DELAYED_WORK(ir_migration_work, ir_irq_migration); | ||
2220 | |||
2221 | /* | ||
2222 | * Migrate the IO-APIC irq in the presence of intr-remapping. | ||
2223 | * | ||
2224 | * For edge triggered, irq migration is a simple atomic update(of vector | ||
2225 | * and cpu destination) of IRTE and flush the hardware cache. | ||
2226 | * | ||
2227 | * For level triggered, we need to modify the io-apic RTE aswell with the update | ||
2228 | * vector information, along with modifying IRTE with vector and destination. | ||
2229 | * So irq migration for level triggered is little bit more complex compared to | ||
2230 | * edge triggered migration. But the good news is, we use the same algorithm | ||
2231 | * for level triggered migration as we have today, only difference being, | ||
2232 | * we now initiate the irq migration from process context instead of the | ||
2233 | * interrupt context. | ||
2234 | * | ||
2235 | * In future, when we do a directed EOI (combined with cpu EOI broadcast | ||
2236 | * suppression) to the IO-APIC, level triggered irq migration will also be | ||
2237 | * as simple as edge triggered migration and we can do the irq migration | ||
2238 | * with a simple atomic update to IO-APIC RTE. | ||
2239 | */ | ||
2240 | static void migrate_ioapic_irq(int irq, cpumask_t mask) | ||
2241 | { | ||
2242 | struct irq_cfg *cfg; | ||
2243 | struct irq_desc *desc; | ||
2244 | cpumask_t tmp, cleanup_mask; | ||
2245 | struct irte irte; | ||
2246 | int modify_ioapic_rte; | ||
2247 | unsigned int dest; | ||
2248 | unsigned long flags; | ||
2249 | |||
2250 | cpus_and(tmp, mask, cpu_online_map); | ||
2251 | if (cpus_empty(tmp)) | ||
2252 | return; | ||
2253 | |||
2254 | if (get_irte(irq, &irte)) | ||
2255 | return; | ||
2256 | |||
2257 | if (assign_irq_vector(irq, mask)) | ||
2258 | return; | ||
2259 | |||
2260 | cfg = irq_cfg(irq); | ||
2261 | cpus_and(tmp, cfg->domain, mask); | ||
2262 | dest = cpu_mask_to_apicid(tmp); | ||
2263 | |||
2264 | desc = irq_to_desc(irq); | ||
2265 | modify_ioapic_rte = desc->status & IRQ_LEVEL; | ||
2266 | if (modify_ioapic_rte) { | ||
2267 | spin_lock_irqsave(&ioapic_lock, flags); | ||
2268 | __target_IO_APIC_irq(irq, dest, cfg->vector); | ||
2269 | spin_unlock_irqrestore(&ioapic_lock, flags); | ||
2270 | } | ||
2271 | |||
2272 | irte.vector = cfg->vector; | ||
2273 | irte.dest_id = IRTE_DEST(dest); | ||
2274 | |||
2275 | /* | ||
2276 | * Modified the IRTE and flushes the Interrupt entry cache. | ||
2277 | */ | ||
2278 | modify_irte(irq, &irte); | ||
2279 | |||
2280 | if (cfg->move_in_progress) { | ||
2281 | cpus_and(cleanup_mask, cfg->old_domain, cpu_online_map); | ||
2282 | cfg->move_cleanup_count = cpus_weight(cleanup_mask); | ||
2283 | send_IPI_mask(cleanup_mask, IRQ_MOVE_CLEANUP_VECTOR); | ||
2284 | cfg->move_in_progress = 0; | ||
2285 | } | ||
2286 | |||
2287 | desc->affinity = mask; | ||
2288 | } | ||
2289 | |||
2290 | static int migrate_irq_remapped_level(int irq) | ||
2291 | { | ||
2292 | int ret = -1; | ||
2293 | struct irq_desc *desc = irq_to_desc(irq); | ||
2294 | |||
2295 | mask_IO_APIC_irq(irq); | ||
2296 | |||
2297 | if (io_apic_level_ack_pending(irq)) { | ||
2298 | /* | ||
2299 | * Interrupt in progress. Migrating irq now will change the | ||
2300 | * vector information in the IO-APIC RTE and that will confuse | ||
2301 | * the EOI broadcast performed by cpu. | ||
2302 | * So, delay the irq migration to the next instance. | ||
2303 | */ | ||
2304 | schedule_delayed_work(&ir_migration_work, 1); | ||
2305 | goto unmask; | ||
2306 | } | ||
2307 | |||
2308 | /* everthing is clear. we have right of way */ | ||
2309 | migrate_ioapic_irq(irq, desc->pending_mask); | ||
2310 | |||
2311 | ret = 0; | ||
2312 | desc->status &= ~IRQ_MOVE_PENDING; | ||
2313 | cpus_clear(desc->pending_mask); | ||
2314 | |||
2315 | unmask: | ||
2316 | unmask_IO_APIC_irq(irq); | ||
2317 | return ret; | ||
2318 | } | ||
2319 | |||
2320 | static void ir_irq_migration(struct work_struct *work) | ||
2321 | { | ||
2322 | unsigned int irq; | ||
2323 | struct irq_desc *desc; | ||
2324 | |||
2325 | for_each_irq_desc(irq, desc) { | ||
2326 | if (desc->status & IRQ_MOVE_PENDING) { | ||
2327 | unsigned long flags; | ||
2328 | |||
2329 | spin_lock_irqsave(&desc->lock, flags); | ||
2330 | if (!desc->chip->set_affinity || | ||
2331 | !(desc->status & IRQ_MOVE_PENDING)) { | ||
2332 | desc->status &= ~IRQ_MOVE_PENDING; | ||
2333 | spin_unlock_irqrestore(&desc->lock, flags); | ||
2334 | continue; | ||
2335 | } | ||
2336 | |||
2337 | desc->chip->set_affinity(irq, desc->pending_mask); | ||
2338 | spin_unlock_irqrestore(&desc->lock, flags); | ||
2339 | } | ||
2340 | } | ||
2341 | } | ||
2342 | |||
2343 | /* | ||
2344 | * Migrates the IRQ destination in the process context. | ||
2345 | */ | ||
2346 | static void set_ir_ioapic_affinity_irq(unsigned int irq, cpumask_t mask) | ||
2347 | { | ||
2348 | struct irq_desc *desc = irq_to_desc(irq); | ||
2349 | |||
2350 | if (desc->status & IRQ_LEVEL) { | ||
2351 | desc->status |= IRQ_MOVE_PENDING; | ||
2352 | desc->pending_mask = mask; | ||
2353 | migrate_irq_remapped_level(irq); | ||
2354 | return; | ||
2355 | } | ||
2356 | |||
2357 | migrate_ioapic_irq(irq, mask); | ||
2358 | } | ||
2359 | #endif | ||
2360 | |||
2054 | asmlinkage void smp_irq_move_cleanup_interrupt(void) | 2361 | asmlinkage void smp_irq_move_cleanup_interrupt(void) |
2055 | { | 2362 | { |
2056 | unsigned vector, me; | 2363 | unsigned vector, me; |
2057 | ack_APIC_irq(); | 2364 | ack_APIC_irq(); |
2365 | #ifdef CONFIG_X86_64 | ||
2366 | exit_idle(); | ||
2367 | #endif | ||
2058 | irq_enter(); | 2368 | irq_enter(); |
2059 | 2369 | ||
2060 | me = smp_processor_id(); | 2370 | me = smp_processor_id(); |
@@ -2107,6 +2417,17 @@ static void irq_complete_move(unsigned int irq) | |||
2107 | #else | 2417 | #else |
2108 | static inline void irq_complete_move(unsigned int irq) {} | 2418 | static inline void irq_complete_move(unsigned int irq) {} |
2109 | #endif | 2419 | #endif |
2420 | #ifdef CONFIG_INTR_REMAP | ||
2421 | static void ack_x2apic_level(unsigned int irq) | ||
2422 | { | ||
2423 | ack_x2APIC_irq(); | ||
2424 | } | ||
2425 | |||
2426 | static void ack_x2apic_edge(unsigned int irq) | ||
2427 | { | ||
2428 | ack_x2APIC_irq(); | ||
2429 | } | ||
2430 | #endif | ||
2110 | 2431 | ||
2111 | static void ack_apic_edge(unsigned int irq) | 2432 | static void ack_apic_edge(unsigned int irq) |
2112 | { | 2433 | { |
@@ -2118,55 +2439,55 @@ static void ack_apic_edge(unsigned int irq) | |||
2118 | #ifdef CONFIG_X86_64 | 2439 | #ifdef CONFIG_X86_64 |
2119 | static void ack_apic_level(unsigned int irq) | 2440 | static void ack_apic_level(unsigned int irq) |
2120 | { | 2441 | { |
2121 | int do_unmask_irq = 0; | 2442 | int do_unmask_irq = 0; |
2122 | 2443 | ||
2123 | irq_complete_move(irq); | 2444 | irq_complete_move(irq); |
2124 | #ifdef CONFIG_GENERIC_PENDING_IRQ | 2445 | #ifdef CONFIG_GENERIC_PENDING_IRQ |
2125 | /* If we are moving the irq we need to mask it */ | 2446 | /* If we are moving the irq we need to mask it */ |
2126 | if (unlikely(desc->status & IRQ_MOVE_PENDING)) { | 2447 | if (unlikely(irq_to_desc(irq)->status & IRQ_MOVE_PENDING)) { |
2127 | do_unmask_irq = 1; | 2448 | do_unmask_irq = 1; |
2128 | mask_IO_APIC_irq(irq); | 2449 | mask_IO_APIC_irq(irq); |
2129 | } | 2450 | } |
2130 | #endif | 2451 | #endif |
2131 | 2452 | ||
2132 | /* | 2453 | /* |
2133 | * We must acknowledge the irq before we move it or the acknowledge will | 2454 | * We must acknowledge the irq before we move it or the acknowledge will |
2134 | * not propagate properly. | 2455 | * not propagate properly. |
2135 | */ | 2456 | */ |
2136 | ack_APIC_irq(); | 2457 | ack_APIC_irq(); |
2137 | 2458 | ||
2138 | /* Now we can move and renable the irq */ | 2459 | /* Now we can move and renable the irq */ |
2139 | if (unlikely(do_unmask_irq)) { | 2460 | if (unlikely(do_unmask_irq)) { |
2140 | /* Only migrate the irq if the ack has been received. | 2461 | /* Only migrate the irq if the ack has been received. |
2141 | * | 2462 | * |
2142 | * On rare occasions the broadcast level triggered ack gets | 2463 | * On rare occasions the broadcast level triggered ack gets |
2143 | * delayed going to ioapics, and if we reprogram the | 2464 | * delayed going to ioapics, and if we reprogram the |
2144 | * vector while Remote IRR is still set the irq will never | 2465 | * vector while Remote IRR is still set the irq will never |
2145 | * fire again. | 2466 | * fire again. |
2146 | * | 2467 | * |
2147 | * To prevent this scenario we read the Remote IRR bit | 2468 | * To prevent this scenario we read the Remote IRR bit |
2148 | * of the ioapic. This has two effects. | 2469 | * of the ioapic. This has two effects. |
2149 | * - On any sane system the read of the ioapic will | 2470 | * - On any sane system the read of the ioapic will |
2150 | * flush writes (and acks) going to the ioapic from | 2471 | * flush writes (and acks) going to the ioapic from |
2151 | * this cpu. | 2472 | * this cpu. |
2152 | * - We get to see if the ACK has actually been delivered. | 2473 | * - We get to see if the ACK has actually been delivered. |
2153 | * | 2474 | * |
2154 | * Based on failed experiments of reprogramming the | 2475 | * Based on failed experiments of reprogramming the |
2155 | * ioapic entry from outside of irq context starting | 2476 | * ioapic entry from outside of irq context starting |
2156 | * with masking the ioapic entry and then polling until | 2477 | * with masking the ioapic entry and then polling until |
2157 | * Remote IRR was clear before reprogramming the | 2478 | * Remote IRR was clear before reprogramming the |
2158 | * ioapic I don't trust the Remote IRR bit to be | 2479 | * ioapic I don't trust the Remote IRR bit to be |
2159 | * completey accurate. | 2480 | * completey accurate. |
2160 | * | 2481 | * |
2161 | * However there appears to be no other way to plug | 2482 | * However there appears to be no other way to plug |
2162 | * this race, so if the Remote IRR bit is not | 2483 | * this race, so if the Remote IRR bit is not |
2163 | * accurate and is causing problems then it is a hardware bug | 2484 | * accurate and is causing problems then it is a hardware bug |
2164 | * and you can go talk to the chipset vendor about it. | 2485 | * and you can go talk to the chipset vendor about it. |
2165 | */ | 2486 | */ |
2166 | if (!io_apic_level_ack_pending(irq)) | 2487 | if (!io_apic_level_ack_pending(irq)) |
2167 | move_masked_irq(irq, desc); | 2488 | move_masked_irq(irq); |
2168 | unmask_IO_APIC_irq(irq); | 2489 | unmask_IO_APIC_irq(irq); |
2169 | } | 2490 | } |
2170 | } | 2491 | } |
2171 | #else | 2492 | #else |
2172 | atomic_t irq_mis_count; | 2493 | atomic_t irq_mis_count; |
@@ -2177,25 +2498,25 @@ static void ack_apic_level(unsigned int irq) | |||
2177 | 2498 | ||
2178 | irq_complete_move(irq); | 2499 | irq_complete_move(irq); |
2179 | move_native_irq(irq); | 2500 | move_native_irq(irq); |
2180 | /* | 2501 | /* |
2181 | * It appears there is an erratum which affects at least version 0x11 | 2502 | * It appears there is an erratum which affects at least version 0x11 |
2182 | * of I/O APIC (that's the 82093AA and cores integrated into various | 2503 | * of I/O APIC (that's the 82093AA and cores integrated into various |
2183 | * chipsets). Under certain conditions a level-triggered interrupt is | 2504 | * chipsets). Under certain conditions a level-triggered interrupt is |
2184 | * erroneously delivered as edge-triggered one but the respective IRR | 2505 | * erroneously delivered as edge-triggered one but the respective IRR |
2185 | * bit gets set nevertheless. As a result the I/O unit expects an EOI | 2506 | * bit gets set nevertheless. As a result the I/O unit expects an EOI |
2186 | * message but it will never arrive and further interrupts are blocked | 2507 | * message but it will never arrive and further interrupts are blocked |
2187 | * from the source. The exact reason is so far unknown, but the | 2508 | * from the source. The exact reason is so far unknown, but the |
2188 | * phenomenon was observed when two consecutive interrupt requests | 2509 | * phenomenon was observed when two consecutive interrupt requests |
2189 | * from a given source get delivered to the same CPU and the source is | 2510 | * from a given source get delivered to the same CPU and the source is |
2190 | * temporarily disabled in between. | 2511 | * temporarily disabled in between. |
2191 | * | 2512 | * |
2192 | * A workaround is to simulate an EOI message manually. We achieve it | 2513 | * A workaround is to simulate an EOI message manually. We achieve it |
2193 | * by setting the trigger mode to edge and then to level when the edge | 2514 | * by setting the trigger mode to edge and then to level when the edge |
2194 | * trigger mode gets detected in the TMR of a local APIC for a | 2515 | * trigger mode gets detected in the TMR of a local APIC for a |
2195 | * level-triggered interrupt. We mask the source for the time of the | 2516 | * level-triggered interrupt. We mask the source for the time of the |
2196 | * operation to prevent an edge-triggered interrupt escaping meanwhile. | 2517 | * operation to prevent an edge-triggered interrupt escaping meanwhile. |
2197 | * The idea is from Manfred Spraul. --macro | 2518 | * The idea is from Manfred Spraul. --macro |
2198 | */ | 2519 | */ |
2199 | i = irq_cfg(irq)->vector; | 2520 | i = irq_cfg(irq)->vector; |
2200 | 2521 | ||
2201 | v = apic_read(APIC_TMR + ((i & ~0x1f) >> 1)); | 2522 | v = apic_read(APIC_TMR + ((i & ~0x1f) >> 1)); |
@@ -2225,6 +2546,20 @@ static struct irq_chip ioapic_chip __read_mostly = { | |||
2225 | .retrigger = ioapic_retrigger_irq, | 2546 | .retrigger = ioapic_retrigger_irq, |
2226 | }; | 2547 | }; |
2227 | 2548 | ||
2549 | #ifdef CONFIG_INTR_REMAP | ||
2550 | static struct irq_chip ir_ioapic_chip __read_mostly = { | ||
2551 | .name = "IR-IO-APIC", | ||
2552 | .startup = startup_ioapic_irq, | ||
2553 | .mask = mask_IO_APIC_irq, | ||
2554 | .unmask = unmask_IO_APIC_irq, | ||
2555 | .ack = ack_x2apic_edge, | ||
2556 | .eoi = ack_x2apic_level, | ||
2557 | #ifdef CONFIG_SMP | ||
2558 | .set_affinity = set_ir_ioapic_affinity_irq, | ||
2559 | #endif | ||
2560 | .retrigger = ioapic_retrigger_irq, | ||
2561 | }; | ||
2562 | #endif | ||
2228 | 2563 | ||
2229 | static inline void init_IO_APIC_traps(void) | 2564 | static inline void init_IO_APIC_traps(void) |
2230 | { | 2565 | { |
@@ -2282,7 +2617,7 @@ static void unmask_lapic_irq(unsigned int irq) | |||
2282 | apic_write(APIC_LVT0, v & ~APIC_LVT_MASKED); | 2617 | apic_write(APIC_LVT0, v & ~APIC_LVT_MASKED); |
2283 | } | 2618 | } |
2284 | 2619 | ||
2285 | static void ack_lapic_irq(unsigned int irq) | 2620 | static void ack_lapic_irq (unsigned int irq) |
2286 | { | 2621 | { |
2287 | ack_APIC_irq(); | 2622 | ack_APIC_irq(); |
2288 | } | 2623 | } |
@@ -2383,12 +2718,12 @@ static inline void __init unlock_ExtINT_logic(void) | |||
2383 | 2718 | ||
2384 | static int disable_timer_pin_1 __initdata; | 2719 | static int disable_timer_pin_1 __initdata; |
2385 | /* Actually the next is obsolete, but keep it for paranoid reasons -AK */ | 2720 | /* Actually the next is obsolete, but keep it for paranoid reasons -AK */ |
2386 | static int __init parse_disable_timer_pin_1(char *arg) | 2721 | static int __init disable_timer_pin_setup(char *arg) |
2387 | { | 2722 | { |
2388 | disable_timer_pin_1 = 1; | 2723 | disable_timer_pin_1 = 1; |
2389 | return 0; | 2724 | return 0; |
2390 | } | 2725 | } |
2391 | early_param("disable_timer_pin_1", parse_disable_timer_pin_1); | 2726 | early_param("disable_timer_pin_1", disable_timer_pin_setup); |
2392 | 2727 | ||
2393 | int timer_through_8259 __initdata; | 2728 | int timer_through_8259 __initdata; |
2394 | 2729 | ||
@@ -2397,6 +2732,8 @@ int timer_through_8259 __initdata; | |||
2397 | * a wide range of boards and BIOS bugs. Fortunately only the timer IRQ | 2732 | * a wide range of boards and BIOS bugs. Fortunately only the timer IRQ |
2398 | * is so screwy. Thanks to Brian Perkins for testing/hacking this beast | 2733 | * is so screwy. Thanks to Brian Perkins for testing/hacking this beast |
2399 | * fanatically on his truly buggy board. | 2734 | * fanatically on his truly buggy board. |
2735 | * | ||
2736 | * FIXME: really need to revamp this for all platforms. | ||
2400 | */ | 2737 | */ |
2401 | static inline void __init check_timer(void) | 2738 | static inline void __init check_timer(void) |
2402 | { | 2739 | { |
@@ -2408,8 +2745,8 @@ static inline void __init check_timer(void) | |||
2408 | 2745 | ||
2409 | local_irq_save(flags); | 2746 | local_irq_save(flags); |
2410 | 2747 | ||
2411 | ver = apic_read(APIC_LVR); | 2748 | ver = apic_read(APIC_LVR); |
2412 | ver = GET_APIC_VERSION(ver); | 2749 | ver = GET_APIC_VERSION(ver); |
2413 | 2750 | ||
2414 | /* | 2751 | /* |
2415 | * get/set the timer IRQ vector: | 2752 | * get/set the timer IRQ vector: |
@@ -2428,7 +2765,9 @@ static inline void __init check_timer(void) | |||
2428 | */ | 2765 | */ |
2429 | apic_write(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_EXTINT); | 2766 | apic_write(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_EXTINT); |
2430 | init_8259A(1); | 2767 | init_8259A(1); |
2768 | #ifdef CONFIG_X86_32 | ||
2431 | timer_ack = (nmi_watchdog == NMI_IO_APIC && !APIC_INTEGRATED(ver)); | 2769 | timer_ack = (nmi_watchdog == NMI_IO_APIC && !APIC_INTEGRATED(ver)); |
2770 | #endif | ||
2432 | 2771 | ||
2433 | pin1 = find_isa_irq_pin(0, mp_INT); | 2772 | pin1 = find_isa_irq_pin(0, mp_INT); |
2434 | apic1 = find_isa_irq_apic(0, mp_INT); | 2773 | apic1 = find_isa_irq_apic(0, mp_INT); |
@@ -2447,6 +2786,10 @@ static inline void __init check_timer(void) | |||
2447 | * 8259A. | 2786 | * 8259A. |
2448 | */ | 2787 | */ |
2449 | if (pin1 == -1) { | 2788 | if (pin1 == -1) { |
2789 | #ifdef CONFIG_INTR_REMAP | ||
2790 | if (intr_remapping_enabled) | ||
2791 | panic("BIOS bug: timer not connected to IO-APIC"); | ||
2792 | #endif | ||
2450 | pin1 = pin2; | 2793 | pin1 = pin2; |
2451 | apic1 = apic2; | 2794 | apic1 = apic2; |
2452 | no_pin1 = 1; | 2795 | no_pin1 = 1; |
@@ -2473,6 +2816,10 @@ static inline void __init check_timer(void) | |||
2473 | clear_IO_APIC_pin(0, pin1); | 2816 | clear_IO_APIC_pin(0, pin1); |
2474 | goto out; | 2817 | goto out; |
2475 | } | 2818 | } |
2819 | #ifdef CONFIG_INTR_REMAP | ||
2820 | if (intr_remapping_enabled) | ||
2821 | panic("timer doesn't work through Interrupt-remapped IO-APIC"); | ||
2822 | #endif | ||
2476 | clear_IO_APIC_pin(apic1, pin1); | 2823 | clear_IO_APIC_pin(apic1, pin1); |
2477 | if (!no_pin1) | 2824 | if (!no_pin1) |
2478 | apic_printk(APIC_QUIET, KERN_ERR "..MP-BIOS bug: " | 2825 | apic_printk(APIC_QUIET, KERN_ERR "..MP-BIOS bug: " |
@@ -2512,7 +2859,9 @@ static inline void __init check_timer(void) | |||
2512 | "through the IO-APIC - disabling NMI Watchdog!\n"); | 2859 | "through the IO-APIC - disabling NMI Watchdog!\n"); |
2513 | nmi_watchdog = NMI_NONE; | 2860 | nmi_watchdog = NMI_NONE; |
2514 | } | 2861 | } |
2862 | #ifdef CONFIG_X86_32 | ||
2515 | timer_ack = 0; | 2863 | timer_ack = 0; |
2864 | #endif | ||
2516 | 2865 | ||
2517 | apic_printk(APIC_QUIET, KERN_INFO | 2866 | apic_printk(APIC_QUIET, KERN_INFO |
2518 | "...trying to set up timer as Virtual Wire IRQ...\n"); | 2867 | "...trying to set up timer as Virtual Wire IRQ...\n"); |
@@ -2570,17 +2919,25 @@ out: | |||
2570 | 2919 | ||
2571 | void __init setup_IO_APIC(void) | 2920 | void __init setup_IO_APIC(void) |
2572 | { | 2921 | { |
2922 | |||
2923 | #ifdef CONFIG_X86_32 | ||
2573 | enable_IO_APIC(); | 2924 | enable_IO_APIC(); |
2925 | #else | ||
2926 | /* | ||
2927 | * calling enable_IO_APIC() is moved to setup_local_APIC for BP | ||
2928 | */ | ||
2929 | #endif | ||
2574 | 2930 | ||
2575 | io_apic_irqs = ~PIC_IRQS; | 2931 | io_apic_irqs = ~PIC_IRQS; |
2576 | 2932 | ||
2577 | printk("ENABLING IO-APIC IRQs\n"); | 2933 | apic_printk(APIC_VERBOSE, "ENABLING IO-APIC IRQs\n"); |
2578 | 2934 | /* | |
2579 | /* | 2935 | * Set up IO-APIC IRQ routing. |
2580 | * Set up IO-APIC IRQ routing. | 2936 | */ |
2581 | */ | 2937 | #ifdef CONFIG_X86_32 |
2582 | if (!acpi_ioapic) | 2938 | if (!acpi_ioapic) |
2583 | setup_ioapic_ids_from_mpc(); | 2939 | setup_ioapic_ids_from_mpc(); |
2940 | #endif | ||
2584 | sync_Arb_IDs(); | 2941 | sync_Arb_IDs(); |
2585 | setup_IO_APIC_irqs(); | 2942 | setup_IO_APIC_irqs(); |
2586 | init_IO_APIC_traps(); | 2943 | init_IO_APIC_traps(); |
@@ -2588,15 +2945,15 @@ void __init setup_IO_APIC(void) | |||
2588 | } | 2945 | } |
2589 | 2946 | ||
2590 | /* | 2947 | /* |
2591 | * Called after all the initialization is done. If we didnt find any | 2948 | * Called after all the initialization is done. If we didnt find any |
2592 | * APIC bugs then we can allow the modify fast path | 2949 | * APIC bugs then we can allow the modify fast path |
2593 | */ | 2950 | */ |
2594 | 2951 | ||
2595 | static int __init io_apic_bug_finalize(void) | 2952 | static int __init io_apic_bug_finalize(void) |
2596 | { | 2953 | { |
2597 | if (sis_apic_bug == -1) | 2954 | if (sis_apic_bug == -1) |
2598 | sis_apic_bug = 0; | 2955 | sis_apic_bug = 0; |
2599 | return 0; | 2956 | return 0; |
2600 | } | 2957 | } |
2601 | 2958 | ||
2602 | late_initcall(io_apic_bug_finalize); | 2959 | late_initcall(io_apic_bug_finalize); |
@@ -2605,7 +2962,7 @@ struct sysfs_ioapic_data { | |||
2605 | struct sys_device dev; | 2962 | struct sys_device dev; |
2606 | struct IO_APIC_route_entry entry[0]; | 2963 | struct IO_APIC_route_entry entry[0]; |
2607 | }; | 2964 | }; |
2608 | static struct sysfs_ioapic_data *mp_ioapic_data[MAX_IO_APICS]; | 2965 | static struct sysfs_ioapic_data * mp_ioapic_data[MAX_IO_APICS]; |
2609 | 2966 | ||
2610 | static int ioapic_suspend(struct sys_device *dev, pm_message_t state) | 2967 | static int ioapic_suspend(struct sys_device *dev, pm_message_t state) |
2611 | { | 2968 | { |
@@ -2615,8 +2972,8 @@ static int ioapic_suspend(struct sys_device *dev, pm_message_t state) | |||
2615 | 2972 | ||
2616 | data = container_of(dev, struct sysfs_ioapic_data, dev); | 2973 | data = container_of(dev, struct sysfs_ioapic_data, dev); |
2617 | entry = data->entry; | 2974 | entry = data->entry; |
2618 | for (i = 0; i < nr_ioapic_registers[dev->id]; i++) | 2975 | for (i = 0; i < nr_ioapic_registers[dev->id]; i ++, entry ++ ) |
2619 | entry[i] = ioapic_read_entry(dev->id, i); | 2976 | *entry = ioapic_read_entry(dev->id, i); |
2620 | 2977 | ||
2621 | return 0; | 2978 | return 0; |
2622 | } | 2979 | } |
@@ -2653,14 +3010,14 @@ static struct sysdev_class ioapic_sysdev_class = { | |||
2653 | 3010 | ||
2654 | static int __init ioapic_init_sysfs(void) | 3011 | static int __init ioapic_init_sysfs(void) |
2655 | { | 3012 | { |
2656 | struct sys_device *dev; | 3013 | struct sys_device * dev; |
2657 | int i, size, error = 0; | 3014 | int i, size, error; |
2658 | 3015 | ||
2659 | error = sysdev_class_register(&ioapic_sysdev_class); | 3016 | error = sysdev_class_register(&ioapic_sysdev_class); |
2660 | if (error) | 3017 | if (error) |
2661 | return error; | 3018 | return error; |
2662 | 3019 | ||
2663 | for (i = 0; i < nr_ioapics; i++) { | 3020 | for (i = 0; i < nr_ioapics; i++ ) { |
2664 | size = sizeof(struct sys_device) + nr_ioapic_registers[i] | 3021 | size = sizeof(struct sys_device) + nr_ioapic_registers[i] |
2665 | * sizeof(struct IO_APIC_route_entry); | 3022 | * sizeof(struct IO_APIC_route_entry); |
2666 | mp_ioapic_data[i] = kzalloc(size, GFP_KERNEL); | 3023 | mp_ioapic_data[i] = kzalloc(size, GFP_KERNEL); |
@@ -2691,18 +3048,18 @@ device_initcall(ioapic_init_sysfs); | |||
2691 | unsigned int create_irq_nr(unsigned int irq_want) | 3048 | unsigned int create_irq_nr(unsigned int irq_want) |
2692 | { | 3049 | { |
2693 | /* Allocate an unused irq */ | 3050 | /* Allocate an unused irq */ |
2694 | unsigned int irq, new; | 3051 | unsigned int irq; |
3052 | unsigned int new; | ||
2695 | unsigned long flags; | 3053 | unsigned long flags; |
2696 | struct irq_cfg *cfg_new; | 3054 | struct irq_cfg *cfg_new; |
2697 | 3055 | ||
2698 | #ifndef CONFIG_HAVE_SPARSE_IRQ | 3056 | #ifndef CONFIG_HAVE_SPARSE_IRQ |
2699 | /* only can use bus/dev/fn.. when per_cpu vector is used */ | ||
2700 | irq_want = nr_irqs - 1; | 3057 | irq_want = nr_irqs - 1; |
2701 | #endif | 3058 | #endif |
2702 | 3059 | ||
2703 | irq = 0; | 3060 | irq = 0; |
2704 | spin_lock_irqsave(&vector_lock, flags); | 3061 | spin_lock_irqsave(&vector_lock, flags); |
2705 | for (new = (nr_irqs - 1); new > 0; new--) { | 3062 | for (new = irq_want; new > 0; new--) { |
2706 | if (platform_legacy_irq(new)) | 3063 | if (platform_legacy_irq(new)) |
2707 | continue; | 3064 | continue; |
2708 | cfg_new = irq_cfg(new); | 3065 | cfg_new = irq_cfg(new); |
@@ -2725,7 +3082,14 @@ unsigned int create_irq_nr(unsigned int irq_want) | |||
2725 | 3082 | ||
2726 | int create_irq(void) | 3083 | int create_irq(void) |
2727 | { | 3084 | { |
2728 | return create_irq_nr(nr_irqs - 1); | 3085 | int irq; |
3086 | |||
3087 | irq = create_irq_nr(nr_irqs - 1); | ||
3088 | |||
3089 | if (irq == 0) | ||
3090 | irq = -1; | ||
3091 | |||
3092 | return irq; | ||
2729 | } | 3093 | } |
2730 | 3094 | ||
2731 | void destroy_irq(unsigned int irq) | 3095 | void destroy_irq(unsigned int irq) |
@@ -2734,6 +3098,9 @@ void destroy_irq(unsigned int irq) | |||
2734 | 3098 | ||
2735 | dynamic_irq_cleanup(irq); | 3099 | dynamic_irq_cleanup(irq); |
2736 | 3100 | ||
3101 | #ifdef CONFIG_INTR_REMAP | ||
3102 | free_irte(irq); | ||
3103 | #endif | ||
2737 | spin_lock_irqsave(&vector_lock, flags); | 3104 | spin_lock_irqsave(&vector_lock, flags); |
2738 | __clear_irq_vector(irq); | 3105 | __clear_irq_vector(irq); |
2739 | spin_unlock_irqrestore(&vector_lock, flags); | 3106 | spin_unlock_irqrestore(&vector_lock, flags); |
@@ -2759,25 +3126,54 @@ static int msi_compose_msg(struct pci_dev *pdev, unsigned int irq, struct msi_ms | |||
2759 | cpus_and(tmp, cfg->domain, tmp); | 3126 | cpus_and(tmp, cfg->domain, tmp); |
2760 | dest = cpu_mask_to_apicid(tmp); | 3127 | dest = cpu_mask_to_apicid(tmp); |
2761 | 3128 | ||
2762 | msg->address_hi = MSI_ADDR_BASE_HI; | 3129 | #ifdef CONFIG_INTR_REMAP |
2763 | msg->address_lo = | 3130 | if (irq_remapped(irq)) { |
2764 | MSI_ADDR_BASE_LO | | 3131 | struct irte irte; |
2765 | ((INT_DEST_MODE == 0) ? | 3132 | int ir_index; |
2766 | MSI_ADDR_DEST_MODE_PHYSICAL: | 3133 | u16 sub_handle; |
2767 | MSI_ADDR_DEST_MODE_LOGICAL) | | 3134 | |
2768 | ((INT_DELIVERY_MODE != dest_LowestPrio) ? | 3135 | ir_index = map_irq_to_irte_handle(irq, &sub_handle); |
2769 | MSI_ADDR_REDIRECTION_CPU: | 3136 | BUG_ON(ir_index == -1); |
2770 | MSI_ADDR_REDIRECTION_LOWPRI) | | 3137 | |
2771 | MSI_ADDR_DEST_ID(dest); | 3138 | memset (&irte, 0, sizeof(irte)); |
2772 | 3139 | ||
2773 | msg->data = | 3140 | irte.present = 1; |
2774 | MSI_DATA_TRIGGER_EDGE | | 3141 | irte.dst_mode = INT_DEST_MODE; |
2775 | MSI_DATA_LEVEL_ASSERT | | 3142 | irte.trigger_mode = 0; /* edge */ |
2776 | ((INT_DELIVERY_MODE != dest_LowestPrio) ? | 3143 | irte.dlvry_mode = INT_DELIVERY_MODE; |
2777 | MSI_DATA_DELIVERY_FIXED: | 3144 | irte.vector = cfg->vector; |
2778 | MSI_DATA_DELIVERY_LOWPRI) | | 3145 | irte.dest_id = IRTE_DEST(dest); |
2779 | MSI_DATA_VECTOR(cfg->vector); | 3146 | |
3147 | modify_irte(irq, &irte); | ||
3148 | |||
3149 | msg->address_hi = MSI_ADDR_BASE_HI; | ||
3150 | msg->data = sub_handle; | ||
3151 | msg->address_lo = MSI_ADDR_BASE_LO | MSI_ADDR_IR_EXT_INT | | ||
3152 | MSI_ADDR_IR_SHV | | ||
3153 | MSI_ADDR_IR_INDEX1(ir_index) | | ||
3154 | MSI_ADDR_IR_INDEX2(ir_index); | ||
3155 | } else | ||
3156 | #endif | ||
3157 | { | ||
3158 | msg->address_hi = MSI_ADDR_BASE_HI; | ||
3159 | msg->address_lo = | ||
3160 | MSI_ADDR_BASE_LO | | ||
3161 | ((INT_DEST_MODE == 0) ? | ||
3162 | MSI_ADDR_DEST_MODE_PHYSICAL: | ||
3163 | MSI_ADDR_DEST_MODE_LOGICAL) | | ||
3164 | ((INT_DELIVERY_MODE != dest_LowestPrio) ? | ||
3165 | MSI_ADDR_REDIRECTION_CPU: | ||
3166 | MSI_ADDR_REDIRECTION_LOWPRI) | | ||
3167 | MSI_ADDR_DEST_ID(dest); | ||
2780 | 3168 | ||
3169 | msg->data = | ||
3170 | MSI_DATA_TRIGGER_EDGE | | ||
3171 | MSI_DATA_LEVEL_ASSERT | | ||
3172 | ((INT_DELIVERY_MODE != dest_LowestPrio) ? | ||
3173 | MSI_DATA_DELIVERY_FIXED: | ||
3174 | MSI_DATA_DELIVERY_LOWPRI) | | ||
3175 | MSI_DATA_VECTOR(cfg->vector); | ||
3176 | } | ||
2781 | return err; | 3177 | return err; |
2782 | } | 3178 | } |
2783 | 3179 | ||
@@ -2788,6 +3184,7 @@ static void set_msi_irq_affinity(unsigned int irq, cpumask_t mask) | |||
2788 | struct msi_msg msg; | 3184 | struct msi_msg msg; |
2789 | unsigned int dest; | 3185 | unsigned int dest; |
2790 | cpumask_t tmp; | 3186 | cpumask_t tmp; |
3187 | struct irq_desc *desc; | ||
2791 | 3188 | ||
2792 | cpus_and(tmp, mask, cpu_online_map); | 3189 | cpus_and(tmp, mask, cpu_online_map); |
2793 | if (cpus_empty(tmp)) | 3190 | if (cpus_empty(tmp)) |
@@ -2808,8 +3205,61 @@ static void set_msi_irq_affinity(unsigned int irq, cpumask_t mask) | |||
2808 | msg.address_lo |= MSI_ADDR_DEST_ID(dest); | 3205 | msg.address_lo |= MSI_ADDR_DEST_ID(dest); |
2809 | 3206 | ||
2810 | write_msi_msg(irq, &msg); | 3207 | write_msi_msg(irq, &msg); |
2811 | irq_to_desc(irq)->affinity = mask; | 3208 | desc = irq_to_desc(irq); |
3209 | desc->affinity = mask; | ||
3210 | } | ||
3211 | |||
3212 | #ifdef CONFIG_INTR_REMAP | ||
3213 | /* | ||
3214 | * Migrate the MSI irq to another cpumask. This migration is | ||
3215 | * done in the process context using interrupt-remapping hardware. | ||
3216 | */ | ||
3217 | static void ir_set_msi_irq_affinity(unsigned int irq, cpumask_t mask) | ||
3218 | { | ||
3219 | struct irq_cfg *cfg; | ||
3220 | unsigned int dest; | ||
3221 | cpumask_t tmp, cleanup_mask; | ||
3222 | struct irte irte; | ||
3223 | struct irq_desc *desc; | ||
3224 | |||
3225 | cpus_and(tmp, mask, cpu_online_map); | ||
3226 | if (cpus_empty(tmp)) | ||
3227 | return; | ||
3228 | |||
3229 | if (get_irte(irq, &irte)) | ||
3230 | return; | ||
3231 | |||
3232 | if (assign_irq_vector(irq, mask)) | ||
3233 | return; | ||
3234 | |||
3235 | cfg = irq_cfg(irq); | ||
3236 | cpus_and(tmp, cfg->domain, mask); | ||
3237 | dest = cpu_mask_to_apicid(tmp); | ||
3238 | |||
3239 | irte.vector = cfg->vector; | ||
3240 | irte.dest_id = IRTE_DEST(dest); | ||
3241 | |||
3242 | /* | ||
3243 | * atomically update the IRTE with the new destination and vector. | ||
3244 | */ | ||
3245 | modify_irte(irq, &irte); | ||
3246 | |||
3247 | /* | ||
3248 | * After this point, all the interrupts will start arriving | ||
3249 | * at the new destination. So, time to cleanup the previous | ||
3250 | * vector allocation. | ||
3251 | */ | ||
3252 | if (cfg->move_in_progress) { | ||
3253 | cpus_and(cleanup_mask, cfg->old_domain, cpu_online_map); | ||
3254 | cfg->move_cleanup_count = cpus_weight(cleanup_mask); | ||
3255 | send_IPI_mask(cleanup_mask, IRQ_MOVE_CLEANUP_VECTOR); | ||
3256 | cfg->move_in_progress = 0; | ||
3257 | } | ||
3258 | |||
3259 | desc = irq_to_desc(irq); | ||
3260 | desc->affinity = mask; | ||
2812 | } | 3261 | } |
3262 | #endif | ||
2813 | #endif /* CONFIG_SMP */ | 3263 | #endif /* CONFIG_SMP */ |
2814 | 3264 | ||
2815 | /* | 3265 | /* |
@@ -2827,6 +3277,45 @@ static struct irq_chip msi_chip = { | |||
2827 | .retrigger = ioapic_retrigger_irq, | 3277 | .retrigger = ioapic_retrigger_irq, |
2828 | }; | 3278 | }; |
2829 | 3279 | ||
3280 | #ifdef CONFIG_INTR_REMAP | ||
3281 | static struct irq_chip msi_ir_chip = { | ||
3282 | .name = "IR-PCI-MSI", | ||
3283 | .unmask = unmask_msi_irq, | ||
3284 | .mask = mask_msi_irq, | ||
3285 | .ack = ack_x2apic_edge, | ||
3286 | #ifdef CONFIG_SMP | ||
3287 | .set_affinity = ir_set_msi_irq_affinity, | ||
3288 | #endif | ||
3289 | .retrigger = ioapic_retrigger_irq, | ||
3290 | }; | ||
3291 | |||
3292 | /* | ||
3293 | * Map the PCI dev to the corresponding remapping hardware unit | ||
3294 | * and allocate 'nvec' consecutive interrupt-remapping table entries | ||
3295 | * in it. | ||
3296 | */ | ||
3297 | static int msi_alloc_irte(struct pci_dev *dev, int irq, int nvec) | ||
3298 | { | ||
3299 | struct intel_iommu *iommu; | ||
3300 | int index; | ||
3301 | |||
3302 | iommu = map_dev_to_ir(dev); | ||
3303 | if (!iommu) { | ||
3304 | printk(KERN_ERR | ||
3305 | "Unable to map PCI %s to iommu\n", pci_name(dev)); | ||
3306 | return -ENOENT; | ||
3307 | } | ||
3308 | |||
3309 | index = alloc_irte(iommu, irq, nvec); | ||
3310 | if (index < 0) { | ||
3311 | printk(KERN_ERR | ||
3312 | "Unable to allocate %d IRTE for PCI %s\n", nvec, | ||
3313 | pci_name(dev)); | ||
3314 | return -ENOSPC; | ||
3315 | } | ||
3316 | return index; | ||
3317 | } | ||
3318 | #endif | ||
2830 | 3319 | ||
2831 | static int setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc, int irq) | 3320 | static int setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc, int irq) |
2832 | { | 3321 | { |
@@ -2840,7 +3329,17 @@ static int setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc, int irq) | |||
2840 | set_irq_msi(irq, desc); | 3329 | set_irq_msi(irq, desc); |
2841 | write_msi_msg(irq, &msg); | 3330 | write_msi_msg(irq, &msg); |
2842 | 3331 | ||
2843 | set_irq_chip_and_handler_name(irq, &msi_chip, handle_edge_irq, "edge"); | 3332 | #ifdef CONFIG_INTR_REMAP |
3333 | if (irq_remapped(irq)) { | ||
3334 | struct irq_desc *desc = irq_to_desc(irq); | ||
3335 | /* | ||
3336 | * irq migration in process context | ||
3337 | */ | ||
3338 | desc->status |= IRQ_MOVE_PCNTXT; | ||
3339 | set_irq_chip_and_handler_name(irq, &msi_ir_chip, handle_edge_irq, "edge"); | ||
3340 | } else | ||
3341 | #endif | ||
3342 | set_irq_chip_and_handler_name(irq, &msi_chip, handle_edge_irq, "edge"); | ||
2844 | 3343 | ||
2845 | return 0; | 3344 | return 0; |
2846 | } | 3345 | } |
@@ -2859,59 +3358,164 @@ static unsigned int build_irq_for_pci_dev(struct pci_dev *dev) | |||
2859 | 3358 | ||
2860 | int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc) | 3359 | int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc) |
2861 | { | 3360 | { |
2862 | int irq, ret; | 3361 | unsigned int irq; |
2863 | 3362 | int ret; | |
2864 | unsigned int irq_want; | 3363 | unsigned int irq_want; |
2865 | 3364 | ||
2866 | irq_want = build_irq_for_pci_dev(dev) + 0x100; | 3365 | irq_want = build_irq_for_pci_dev(dev) + 0x100; |
2867 | 3366 | ||
2868 | irq = create_irq_nr(irq_want); | 3367 | irq = create_irq_nr(irq_want); |
2869 | |||
2870 | if (irq == 0) | 3368 | if (irq == 0) |
2871 | return -1; | 3369 | return -1; |
2872 | 3370 | ||
3371 | #ifdef CONFIG_INTR_REMAP | ||
3372 | if (!intr_remapping_enabled) | ||
3373 | goto no_ir; | ||
3374 | |||
3375 | ret = msi_alloc_irte(dev, irq, 1); | ||
3376 | if (ret < 0) | ||
3377 | goto error; | ||
3378 | no_ir: | ||
3379 | #endif | ||
2873 | ret = setup_msi_irq(dev, desc, irq); | 3380 | ret = setup_msi_irq(dev, desc, irq); |
2874 | if (ret < 0) { | 3381 | if (ret < 0) { |
2875 | destroy_irq(irq); | 3382 | destroy_irq(irq); |
2876 | return ret; | 3383 | return ret; |
2877 | } | 3384 | } |
2878 | |||
2879 | return 0; | 3385 | return 0; |
3386 | |||
3387 | #ifdef CONFIG_INTR_REMAP | ||
3388 | error: | ||
3389 | destroy_irq(irq); | ||
3390 | return ret; | ||
3391 | #endif | ||
2880 | } | 3392 | } |
2881 | 3393 | ||
2882 | int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) | 3394 | int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) |
2883 | { | 3395 | { |
2884 | unsigned int irq; | 3396 | unsigned int irq; |
2885 | int ret, sub_handle; | 3397 | int ret, sub_handle; |
2886 | struct msi_desc *desc; | 3398 | struct msi_desc *desc; |
2887 | unsigned int irq_want; | 3399 | unsigned int irq_want; |
2888 | 3400 | ||
2889 | irq_want = build_irq_for_pci_dev(dev) + 0x100; | 3401 | #ifdef CONFIG_INTR_REMAP |
2890 | sub_handle = 0; | 3402 | struct intel_iommu *iommu = 0; |
2891 | list_for_each_entry(desc, &dev->msi_list, list) { | 3403 | int index = 0; |
2892 | irq = create_irq_nr(irq_want--); | 3404 | #endif |
2893 | if (irq == 0) | 3405 | |
2894 | return -1; | 3406 | irq_want = build_irq_for_pci_dev(dev) + 0x100; |
2895 | ret = setup_msi_irq(dev, desc, irq); | 3407 | sub_handle = 0; |
2896 | if (ret < 0) | 3408 | list_for_each_entry(desc, &dev->msi_list, list) { |
2897 | goto error; | 3409 | irq = create_irq_nr(irq_want--); |
2898 | sub_handle++; | 3410 | if (irq == 0) |
2899 | } | 3411 | return -1; |
2900 | return 0; | 3412 | #ifdef CONFIG_INTR_REMAP |
3413 | if (!intr_remapping_enabled) | ||
3414 | goto no_ir; | ||
3415 | |||
3416 | if (!sub_handle) { | ||
3417 | /* | ||
3418 | * allocate the consecutive block of IRTE's | ||
3419 | * for 'nvec' | ||
3420 | */ | ||
3421 | index = msi_alloc_irte(dev, irq, nvec); | ||
3422 | if (index < 0) { | ||
3423 | ret = index; | ||
3424 | goto error; | ||
3425 | } | ||
3426 | } else { | ||
3427 | iommu = map_dev_to_ir(dev); | ||
3428 | if (!iommu) { | ||
3429 | ret = -ENOENT; | ||
3430 | goto error; | ||
3431 | } | ||
3432 | /* | ||
3433 | * setup the mapping between the irq and the IRTE | ||
3434 | * base index, the sub_handle pointing to the | ||
3435 | * appropriate interrupt remap table entry. | ||
3436 | */ | ||
3437 | set_irte_irq(irq, iommu, index, sub_handle); | ||
3438 | } | ||
3439 | no_ir: | ||
3440 | #endif | ||
3441 | ret = setup_msi_irq(dev, desc, irq); | ||
3442 | if (ret < 0) | ||
3443 | goto error; | ||
3444 | sub_handle++; | ||
3445 | } | ||
3446 | return 0; | ||
2901 | 3447 | ||
2902 | error: | 3448 | error: |
2903 | destroy_irq(irq); | 3449 | destroy_irq(irq); |
2904 | return ret; | 3450 | return ret; |
2905 | } | 3451 | } |
2906 | 3452 | ||
2907 | |||
2908 | void arch_teardown_msi_irq(unsigned int irq) | 3453 | void arch_teardown_msi_irq(unsigned int irq) |
2909 | { | 3454 | { |
2910 | destroy_irq(irq); | 3455 | destroy_irq(irq); |
2911 | } | 3456 | } |
2912 | 3457 | ||
2913 | #endif /* CONFIG_PCI_MSI */ | 3458 | #ifdef CONFIG_DMAR |
3459 | #ifdef CONFIG_SMP | ||
3460 | static void dmar_msi_set_affinity(unsigned int irq, cpumask_t mask) | ||
3461 | { | ||
3462 | struct irq_cfg *cfg; | ||
3463 | struct msi_msg msg; | ||
3464 | unsigned int dest; | ||
3465 | cpumask_t tmp; | ||
3466 | struct irq_desc *desc; | ||
3467 | |||
3468 | cpus_and(tmp, mask, cpu_online_map); | ||
3469 | if (cpus_empty(tmp)) | ||
3470 | return; | ||
3471 | |||
3472 | if (assign_irq_vector(irq, mask)) | ||
3473 | return; | ||
3474 | |||
3475 | cfg = irq_cfg(irq); | ||
3476 | cpus_and(tmp, cfg->domain, mask); | ||
3477 | dest = cpu_mask_to_apicid(tmp); | ||
3478 | |||
3479 | dmar_msi_read(irq, &msg); | ||
3480 | |||
3481 | msg.data &= ~MSI_DATA_VECTOR_MASK; | ||
3482 | msg.data |= MSI_DATA_VECTOR(cfg->vector); | ||
3483 | msg.address_lo &= ~MSI_ADDR_DEST_ID_MASK; | ||
3484 | msg.address_lo |= MSI_ADDR_DEST_ID(dest); | ||
3485 | |||
3486 | dmar_msi_write(irq, &msg); | ||
3487 | desc = irq_to_desc(irq); | ||
3488 | desc->affinity = mask; | ||
3489 | } | ||
3490 | #endif /* CONFIG_SMP */ | ||
3491 | |||
3492 | struct irq_chip dmar_msi_type = { | ||
3493 | .name = "DMAR_MSI", | ||
3494 | .unmask = dmar_msi_unmask, | ||
3495 | .mask = dmar_msi_mask, | ||
3496 | .ack = ack_apic_edge, | ||
3497 | #ifdef CONFIG_SMP | ||
3498 | .set_affinity = dmar_msi_set_affinity, | ||
3499 | #endif | ||
3500 | .retrigger = ioapic_retrigger_irq, | ||
3501 | }; | ||
2914 | 3502 | ||
3503 | int arch_setup_dmar_msi(unsigned int irq) | ||
3504 | { | ||
3505 | int ret; | ||
3506 | struct msi_msg msg; | ||
3507 | |||
3508 | ret = msi_compose_msg(NULL, irq, &msg); | ||
3509 | if (ret < 0) | ||
3510 | return ret; | ||
3511 | dmar_msi_write(irq, &msg); | ||
3512 | set_irq_chip_and_handler_name(irq, &dmar_msi_type, handle_edge_irq, | ||
3513 | "edge"); | ||
3514 | return 0; | ||
3515 | } | ||
3516 | #endif | ||
3517 | |||
3518 | #endif /* CONFIG_PCI_MSI */ | ||
2915 | /* | 3519 | /* |
2916 | * Hypertransport interrupt support | 3520 | * Hypertransport interrupt support |
2917 | */ | 3521 | */ |
@@ -2938,6 +3542,7 @@ static void set_ht_irq_affinity(unsigned int irq, cpumask_t mask) | |||
2938 | struct irq_cfg *cfg; | 3542 | struct irq_cfg *cfg; |
2939 | unsigned int dest; | 3543 | unsigned int dest; |
2940 | cpumask_t tmp; | 3544 | cpumask_t tmp; |
3545 | struct irq_desc *desc; | ||
2941 | 3546 | ||
2942 | cpus_and(tmp, mask, cpu_online_map); | 3547 | cpus_and(tmp, mask, cpu_online_map); |
2943 | if (cpus_empty(tmp)) | 3548 | if (cpus_empty(tmp)) |
@@ -2951,7 +3556,8 @@ static void set_ht_irq_affinity(unsigned int irq, cpumask_t mask) | |||
2951 | dest = cpu_mask_to_apicid(tmp); | 3556 | dest = cpu_mask_to_apicid(tmp); |
2952 | 3557 | ||
2953 | target_ht_irq(irq, dest, cfg->vector); | 3558 | target_ht_irq(irq, dest, cfg->vector); |
2954 | irq_to_desc(irq)->affinity = mask; | 3559 | desc = irq_to_desc(irq); |
3560 | desc->affinity = mask; | ||
2955 | } | 3561 | } |
2956 | #endif | 3562 | #endif |
2957 | 3563 | ||
@@ -2974,7 +3580,7 @@ int arch_setup_ht_irq(unsigned int irq, struct pci_dev *dev) | |||
2974 | 3580 | ||
2975 | tmp = TARGET_CPUS; | 3581 | tmp = TARGET_CPUS; |
2976 | err = assign_irq_vector(irq, tmp); | 3582 | err = assign_irq_vector(irq, tmp); |
2977 | if ( !err) { | 3583 | if (!err) { |
2978 | struct ht_irq_msg msg; | 3584 | struct ht_irq_msg msg; |
2979 | unsigned dest; | 3585 | unsigned dest; |
2980 | 3586 | ||
@@ -3007,11 +3613,12 @@ int arch_setup_ht_irq(unsigned int irq, struct pci_dev *dev) | |||
3007 | #endif /* CONFIG_HT_IRQ */ | 3613 | #endif /* CONFIG_HT_IRQ */ |
3008 | 3614 | ||
3009 | /* -------------------------------------------------------------------------- | 3615 | /* -------------------------------------------------------------------------- |
3010 | ACPI-based IOAPIC Configuration | 3616 | ACPI-based IOAPIC Configuration |
3011 | -------------------------------------------------------------------------- */ | 3617 | -------------------------------------------------------------------------- */ |
3012 | 3618 | ||
3013 | #ifdef CONFIG_ACPI | 3619 | #ifdef CONFIG_ACPI |
3014 | 3620 | ||
3621 | #ifdef CONFIG_X86_32 | ||
3015 | int __init io_apic_get_unique_id(int ioapic, int apic_id) | 3622 | int __init io_apic_get_unique_id(int ioapic, int apic_id) |
3016 | { | 3623 | { |
3017 | union IO_APIC_reg_00 reg_00; | 3624 | union IO_APIC_reg_00 reg_00; |
@@ -3086,7 +3693,6 @@ int __init io_apic_get_unique_id(int ioapic, int apic_id) | |||
3086 | return apic_id; | 3693 | return apic_id; |
3087 | } | 3694 | } |
3088 | 3695 | ||
3089 | |||
3090 | int __init io_apic_get_version(int ioapic) | 3696 | int __init io_apic_get_version(int ioapic) |
3091 | { | 3697 | { |
3092 | union IO_APIC_reg_01 reg_01; | 3698 | union IO_APIC_reg_01 reg_01; |
@@ -3098,9 +3704,9 @@ int __init io_apic_get_version(int ioapic) | |||
3098 | 3704 | ||
3099 | return reg_01.bits.version; | 3705 | return reg_01.bits.version; |
3100 | } | 3706 | } |
3707 | #endif | ||
3101 | 3708 | ||
3102 | 3709 | int __init io_apic_get_redir_entries (int ioapic) | |
3103 | int __init io_apic_get_redir_entries(int ioapic) | ||
3104 | { | 3710 | { |
3105 | union IO_APIC_reg_01 reg_01; | 3711 | union IO_APIC_reg_01 reg_01; |
3106 | unsigned long flags; | 3712 | unsigned long flags; |
@@ -3113,10 +3719,10 @@ int __init io_apic_get_redir_entries(int ioapic) | |||
3113 | } | 3719 | } |
3114 | 3720 | ||
3115 | 3721 | ||
3116 | int io_apic_set_pci_routing(int ioapic, int pin, int irq, int triggering, int polarity) | 3722 | int io_apic_set_pci_routing (int ioapic, int pin, int irq, int triggering, int polarity) |
3117 | { | 3723 | { |
3118 | if (!IO_APIC_IRQ(irq)) { | 3724 | if (!IO_APIC_IRQ(irq)) { |
3119 | printk(KERN_ERR "IOAPIC[%d]: Invalid reference to IRQ 0\n", | 3725 | apic_printk(APIC_QUIET,KERN_ERR "IOAPIC[%d]: Invalid reference to IRQ 0\n", |
3120 | ioapic); | 3726 | ioapic); |
3121 | return -EINVAL; | 3727 | return -EINVAL; |
3122 | } | 3728 | } |
@@ -3132,6 +3738,7 @@ int io_apic_set_pci_routing(int ioapic, int pin, int irq, int triggering, int po | |||
3132 | return 0; | 3738 | return 0; |
3133 | } | 3739 | } |
3134 | 3740 | ||
3741 | |||
3135 | int acpi_get_override_irq(int bus_irq, int *trigger, int *polarity) | 3742 | int acpi_get_override_irq(int bus_irq, int *trigger, int *polarity) |
3136 | { | 3743 | { |
3137 | int i; | 3744 | int i; |
@@ -3163,7 +3770,6 @@ void __init setup_ioapic_dest(void) | |||
3163 | { | 3770 | { |
3164 | int pin, ioapic, irq, irq_entry; | 3771 | int pin, ioapic, irq, irq_entry; |
3165 | struct irq_cfg *cfg; | 3772 | struct irq_cfg *cfg; |
3166 | struct irq_desc *desc; | ||
3167 | 3773 | ||
3168 | if (skip_ioapic_setup == 1) | 3774 | if (skip_ioapic_setup == 1) |
3169 | return; | 3775 | return; |
@@ -3184,43 +3790,124 @@ void __init setup_ioapic_dest(void) | |||
3184 | setup_IO_APIC_irq(ioapic, pin, irq, | 3790 | setup_IO_APIC_irq(ioapic, pin, irq, |
3185 | irq_trigger(irq_entry), | 3791 | irq_trigger(irq_entry), |
3186 | irq_polarity(irq_entry)); | 3792 | irq_polarity(irq_entry)); |
3187 | else { | 3793 | #ifdef CONFIG_INTR_REMAP |
3188 | desc = irq_to_desc(irq); | 3794 | else if (intr_remapping_enabled) |
3795 | set_ir_ioapic_affinity_irq(irq, TARGET_CPUS); | ||
3796 | #endif | ||
3797 | else | ||
3189 | set_ioapic_affinity_irq(irq, TARGET_CPUS); | 3798 | set_ioapic_affinity_irq(irq, TARGET_CPUS); |
3190 | } | ||
3191 | } | 3799 | } |
3192 | 3800 | ||
3193 | } | 3801 | } |
3194 | } | 3802 | } |
3195 | #endif | 3803 | #endif |
3196 | 3804 | ||
3805 | #ifdef CONFIG_X86_64 | ||
3806 | #define IOAPIC_RESOURCE_NAME_SIZE 11 | ||
3807 | |||
3808 | static struct resource *ioapic_resources; | ||
3809 | |||
3810 | static struct resource * __init ioapic_setup_resources(void) | ||
3811 | { | ||
3812 | unsigned long n; | ||
3813 | struct resource *res; | ||
3814 | char *mem; | ||
3815 | int i; | ||
3816 | |||
3817 | if (nr_ioapics <= 0) | ||
3818 | return NULL; | ||
3819 | |||
3820 | n = IOAPIC_RESOURCE_NAME_SIZE + sizeof(struct resource); | ||
3821 | n *= nr_ioapics; | ||
3822 | |||
3823 | mem = alloc_bootmem(n); | ||
3824 | res = (void *)mem; | ||
3825 | |||
3826 | if (mem != NULL) { | ||
3827 | mem += sizeof(struct resource) * nr_ioapics; | ||
3828 | |||
3829 | for (i = 0; i < nr_ioapics; i++) { | ||
3830 | res[i].name = mem; | ||
3831 | res[i].flags = IORESOURCE_MEM | IORESOURCE_BUSY; | ||
3832 | sprintf(mem, "IOAPIC %u", i); | ||
3833 | mem += IOAPIC_RESOURCE_NAME_SIZE; | ||
3834 | } | ||
3835 | } | ||
3836 | |||
3837 | ioapic_resources = res; | ||
3838 | |||
3839 | return res; | ||
3840 | } | ||
3841 | #endif | ||
3842 | |||
3197 | void __init ioapic_init_mappings(void) | 3843 | void __init ioapic_init_mappings(void) |
3198 | { | 3844 | { |
3199 | unsigned long ioapic_phys, idx = FIX_IO_APIC_BASE_0; | 3845 | unsigned long ioapic_phys, idx = FIX_IO_APIC_BASE_0; |
3200 | int i; | 3846 | int i; |
3847 | #ifdef CONFIG_X86_64 | ||
3848 | struct resource *ioapic_res; | ||
3201 | 3849 | ||
3850 | ioapic_res = ioapic_setup_resources(); | ||
3851 | #endif | ||
3202 | for (i = 0; i < nr_ioapics; i++) { | 3852 | for (i = 0; i < nr_ioapics; i++) { |
3203 | if (smp_found_config) { | 3853 | if (smp_found_config) { |
3204 | ioapic_phys = mp_ioapics[i].mp_apicaddr; | 3854 | ioapic_phys = mp_ioapics[i].mp_apicaddr; |
3205 | if (!ioapic_phys) { | 3855 | #ifdef CONFIG_X86_32 |
3206 | printk(KERN_ERR | 3856 | if (!ioapic_phys) { |
3207 | "WARNING: bogus zero IO-APIC " | 3857 | printk(KERN_ERR |
3208 | "address found in MPTABLE, " | 3858 | "WARNING: bogus zero IO-APIC " |
3209 | "disabling IO/APIC support!\n"); | 3859 | "address found in MPTABLE, " |
3210 | smp_found_config = 0; | 3860 | "disabling IO/APIC support!\n"); |
3211 | skip_ioapic_setup = 1; | 3861 | smp_found_config = 0; |
3212 | goto fake_ioapic_page; | 3862 | skip_ioapic_setup = 1; |
3213 | } | 3863 | goto fake_ioapic_page; |
3864 | } | ||
3865 | #endif | ||
3214 | } else { | 3866 | } else { |
3867 | #ifdef CONFIG_X86_32 | ||
3215 | fake_ioapic_page: | 3868 | fake_ioapic_page: |
3869 | #endif | ||
3216 | ioapic_phys = (unsigned long) | 3870 | ioapic_phys = (unsigned long) |
3217 | alloc_bootmem_pages(PAGE_SIZE); | 3871 | alloc_bootmem_pages(PAGE_SIZE); |
3218 | ioapic_phys = __pa(ioapic_phys); | 3872 | ioapic_phys = __pa(ioapic_phys); |
3219 | } | 3873 | } |
3220 | set_fixmap_nocache(idx, ioapic_phys); | 3874 | set_fixmap_nocache(idx, ioapic_phys); |
3221 | printk(KERN_DEBUG "mapped IOAPIC to %08lx (%08lx)\n", | 3875 | apic_printk(APIC_VERBOSE, |
3222 | __fix_to_virt(idx), ioapic_phys); | 3876 | "mapped IOAPIC to %08lx (%08lx)\n", |
3877 | __fix_to_virt(idx), ioapic_phys); | ||
3223 | idx++; | 3878 | idx++; |
3879 | |||
3880 | #ifdef CONFIG_X86_64 | ||
3881 | if (ioapic_res != NULL) { | ||
3882 | ioapic_res->start = ioapic_phys; | ||
3883 | ioapic_res->end = ioapic_phys + (4 * 1024) - 1; | ||
3884 | ioapic_res++; | ||
3885 | } | ||
3886 | #endif | ||
3224 | } | 3887 | } |
3225 | } | 3888 | } |
3226 | 3889 | ||
3890 | #ifdef CONFIG_X86_64 | ||
3891 | static int __init ioapic_insert_resources(void) | ||
3892 | { | ||
3893 | int i; | ||
3894 | struct resource *r = ioapic_resources; | ||
3895 | |||
3896 | if (!r) { | ||
3897 | printk(KERN_ERR | ||
3898 | "IO APIC resources could be not be allocated.\n"); | ||
3899 | return -1; | ||
3900 | } | ||
3901 | |||
3902 | for (i = 0; i < nr_ioapics; i++) { | ||
3903 | insert_resource(&iomem_resource, r); | ||
3904 | r++; | ||
3905 | } | ||
3906 | |||
3907 | return 0; | ||
3908 | } | ||
3909 | |||
3910 | /* Insert the IO APIC resources after PCI initialization has occured to handle | ||
3911 | * IO APICS that are mapped in on a BAR in PCI space. */ | ||
3912 | late_initcall(ioapic_insert_resources); | ||
3913 | #endif | ||