aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/kernel/apic/io_apic.c115
1 files changed, 61 insertions, 54 deletions
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index b377b973899e..78960a3b0ed0 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -539,23 +539,41 @@ static void __init replace_pin_at_irq_node(struct irq_cfg *cfg, int node,
539 add_pin_to_irq_node(cfg, node, newapic, newpin); 539 add_pin_to_irq_node(cfg, node, newapic, newpin);
540} 540}
541 541
542static void __io_apic_modify_irq(struct irq_pin_list *entry,
543 int mask_and, int mask_or,
544 void (*final)(struct irq_pin_list *entry))
545{
546 unsigned int reg, pin;
547
548 pin = entry->pin;
549 reg = io_apic_read(entry->apic, 0x10 + pin * 2);
550 reg &= mask_and;
551 reg |= mask_or;
552 io_apic_modify(entry->apic, 0x10 + pin * 2, reg);
553 if (final)
554 final(entry);
555}
556
542static void io_apic_modify_irq(struct irq_cfg *cfg, 557static void io_apic_modify_irq(struct irq_cfg *cfg,
543 int mask_and, int mask_or, 558 int mask_and, int mask_or,
544 void (*final)(struct irq_pin_list *entry)) 559 void (*final)(struct irq_pin_list *entry))
545{ 560{
546 int pin;
547 struct irq_pin_list *entry; 561 struct irq_pin_list *entry;
548 562
549 for_each_irq_pin(entry, cfg->irq_2_pin) { 563 for_each_irq_pin(entry, cfg->irq_2_pin)
550 unsigned int reg; 564 __io_apic_modify_irq(entry, mask_and, mask_or, final);
551 pin = entry->pin; 565}
552 reg = io_apic_read(entry->apic, 0x10 + pin * 2); 566
553 reg &= mask_and; 567static void __mask_and_edge_IO_APIC_irq(struct irq_pin_list *entry)
554 reg |= mask_or; 568{
555 io_apic_modify(entry->apic, 0x10 + pin * 2, reg); 569 __io_apic_modify_irq(entry, ~IO_APIC_REDIR_LEVEL_TRIGGER,
556 if (final) 570 IO_APIC_REDIR_MASKED, NULL);
557 final(entry); 571}
558 } 572
573static void __unmask_and_level_IO_APIC_irq(struct irq_pin_list *entry)
574{
575 __io_apic_modify_irq(entry, ~IO_APIC_REDIR_MASKED,
576 IO_APIC_REDIR_LEVEL_TRIGGER, NULL);
559} 577}
560 578
561static void __unmask_IO_APIC_irq(struct irq_cfg *cfg) 579static void __unmask_IO_APIC_irq(struct irq_cfg *cfg)
@@ -579,18 +597,6 @@ static void __mask_IO_APIC_irq(struct irq_cfg *cfg)
579 io_apic_modify_irq(cfg, ~0, IO_APIC_REDIR_MASKED, &io_apic_sync); 597 io_apic_modify_irq(cfg, ~0, IO_APIC_REDIR_MASKED, &io_apic_sync);
580} 598}
581 599
582static void __mask_and_edge_IO_APIC_irq(struct irq_cfg *cfg)
583{
584 io_apic_modify_irq(cfg, ~IO_APIC_REDIR_LEVEL_TRIGGER,
585 IO_APIC_REDIR_MASKED, NULL);
586}
587
588static void __unmask_and_level_IO_APIC_irq(struct irq_cfg *cfg)
589{
590 io_apic_modify_irq(cfg, ~IO_APIC_REDIR_MASKED,
591 IO_APIC_REDIR_LEVEL_TRIGGER, NULL);
592}
593
594static void mask_IO_APIC_irq_desc(struct irq_desc *desc) 600static void mask_IO_APIC_irq_desc(struct irq_desc *desc)
595{ 601{
596 struct irq_cfg *cfg = desc->chip_data; 602 struct irq_cfg *cfg = desc->chip_data;
@@ -2492,17 +2498,42 @@ static void ack_apic_edge(unsigned int irq)
2492 2498
2493atomic_t irq_mis_count; 2499atomic_t irq_mis_count;
2494 2500
2495static int use_eoi_reg __read_mostly; 2501/*
2496 2502 * IO-APIC versions below 0x20 don't support EOI register.
2503 * For the record, here is the information about various versions:
2504 * 0Xh 82489DX
2505 * 1Xh I/OAPIC or I/O(x)APIC which are not PCI 2.2 Compliant
2506 * 2Xh I/O(x)APIC which is PCI 2.2 Compliant
2507 * 30h-FFh Reserved
2508 *
2509 * Some of the Intel ICH Specs (ICH2 to ICH5) documents the io-apic
2510 * version as 0x2. This is an error with documentation and these ICH chips
2511 * use io-apic's of version 0x20.
2512 *
2513 * For IO-APIC's with EOI register, we use that to do an explicit EOI.
2514 * Otherwise, we simulate the EOI message manually by changing the trigger
2515 * mode to edge and then back to level, with RTE being masked during this.
2516*/
2497static void __eoi_ioapic_irq(unsigned int irq, struct irq_cfg *cfg) 2517static void __eoi_ioapic_irq(unsigned int irq, struct irq_cfg *cfg)
2498{ 2518{
2499 struct irq_pin_list *entry; 2519 struct irq_pin_list *entry;
2500 2520
2501 for_each_irq_pin(entry, cfg->irq_2_pin) { 2521 for_each_irq_pin(entry, cfg->irq_2_pin) {
2502 if (irq_remapped(irq)) 2522 if (mp_ioapics[entry->apic].apicver >= 0x20) {
2503 io_apic_eoi(entry->apic, entry->pin); 2523 /*
2504 else 2524 * Intr-remapping uses pin number as the virtual vector
2505 io_apic_eoi(entry->apic, cfg->vector); 2525 * in the RTE. Actual vector is programmed in
2526 * intr-remapping table entry. Hence for the io-apic
2527 * EOI we use the pin number.
2528 */
2529 if (irq_remapped(irq))
2530 io_apic_eoi(entry->apic, entry->pin);
2531 else
2532 io_apic_eoi(entry->apic, cfg->vector);
2533 } else {
2534 __mask_and_edge_IO_APIC_irq(entry);
2535 __unmask_and_level_IO_APIC_irq(entry);
2536 }
2506 } 2537 }
2507} 2538}
2508 2539
@@ -2520,23 +2551,6 @@ static void eoi_ioapic_irq(struct irq_desc *desc)
2520 spin_unlock_irqrestore(&ioapic_lock, flags); 2551 spin_unlock_irqrestore(&ioapic_lock, flags);
2521} 2552}
2522 2553
2523static int ioapic_supports_eoi(void)
2524{
2525 struct pci_dev *root;
2526
2527 root = pci_get_bus_and_slot(0, PCI_DEVFN(0, 0));
2528 if (root && root->vendor == PCI_VENDOR_ID_INTEL &&
2529 mp_ioapics[0].apicver >= 0x2) {
2530 use_eoi_reg = 1;
2531 printk(KERN_INFO "IO-APIC supports EOI register\n");
2532 } else
2533 printk(KERN_INFO "IO-APIC doesn't support EOI\n");
2534
2535 return 0;
2536}
2537
2538fs_initcall(ioapic_supports_eoi);
2539
2540static void ack_apic_level(unsigned int irq) 2554static void ack_apic_level(unsigned int irq)
2541{ 2555{
2542 struct irq_desc *desc = irq_to_desc(irq); 2556 struct irq_desc *desc = irq_to_desc(irq);
@@ -2587,14 +2601,7 @@ static void ack_apic_level(unsigned int irq)
2587 if (!(v & (1 << (i & 0x1f)))) { 2601 if (!(v & (1 << (i & 0x1f)))) {
2588 atomic_inc(&irq_mis_count); 2602 atomic_inc(&irq_mis_count);
2589 2603
2590 if (use_eoi_reg) 2604 eoi_ioapic_irq(desc);
2591 eoi_ioapic_irq(desc);
2592 else {
2593 spin_lock(&ioapic_lock);
2594 __mask_and_edge_IO_APIC_irq(cfg);
2595 __unmask_and_level_IO_APIC_irq(cfg);
2596 spin_unlock(&ioapic_lock);
2597 }
2598 } 2605 }
2599 2606
2600 /* Now we can move and renable the irq */ 2607 /* Now we can move and renable the irq */