]> xenbits.xensource.com Git - people/ssmith/netchannel2-pvops.git/commitdiff
xen: bind pirq to vector and event channel
authorJeremy Fitzhardinge <jeremy@goop.org>
Mon, 9 Feb 2009 20:05:48 +0000 (12:05 -0800)
committerJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Thu, 25 Jun 2009 20:38:23 +0000 (13:38 -0700)
Having converting a dev+pin to a gsi, and that gsi to an irq, and
allocated a vector for the irq, we must program the IO APIC to deliver
an interrupt on a pin to the vector, so Xen can deliver it as an event
channel.

Given the pirq, we can get the gsi and vector.  We map the gsi to a
specific IO APIC's pin, and set the routing entry.

(We were passing the ACPI triggering and polarity levels directly into
the apic - but they have reversed values.  The result was that
all the level-triggered interrupts were edge, and vice-versa.
It's surprising that anything worked at all, but now AHCI works
for me.

Thanks for Gerd Hoffmann for noticing this.)

[ Impact: program IO APICs under Xen ]

Diagnosed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
arch/x86/xen/apic.c
arch/x86/xen/pci.c

index 71f93f6d5690659769e9a4611ab257ecba3cc278..ee0db39f71221ea73368aae046d6c8cefbedfde1 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <asm/io_apic.h>
 #include <asm/acpi.h>
+#include <asm/hw_irq.h>
 
 #include <asm/xen/hypervisor.h>
 #include <asm/xen/hypercall.h>
@@ -13,6 +14,7 @@
 
 void __init xen_io_apic_init(void)
 {
+       enable_IO_APIC();
 }
 
 unsigned int xen_io_apic_read(unsigned apic, unsigned reg)
index f45000777762599a38ce29594e3288af0015a4e4..af4e8987a7efe5ccbf3b1cc03cadb8e84d7f1953 100644 (file)
@@ -2,6 +2,8 @@
 #include <linux/acpi.h>
 #include <linux/pci.h>
 
+#include <asm/mpspec.h>
+#include <asm/io_apic.h>
 #include <asm/pci_x86.h>
 
 #include <asm/xen/hypervisor.h>
 
 #include "xen-ops.h"
 
+static void xen_set_io_apic_routing(int irq, int trigger, int polarity)
+{
+       int ioapic, ioapic_pin;
+       int vector, gsi;
+       struct IO_APIC_route_entry entry;
+
+       gsi = xen_gsi_from_irq(irq);
+       vector = xen_vector_from_irq(irq);
+
+       ioapic = mp_find_ioapic(gsi);
+       if (ioapic == -1) {
+               printk(KERN_WARNING "xen_set_ioapic_routing: irq %d gsi %d ioapic %d\n",
+                       irq, gsi, ioapic);
+               return;
+       }
+
+       ioapic_pin = mp_find_ioapic_pin(ioapic, gsi);
+
+       printk(KERN_INFO "xen_set_ioapic_routing: irq %d gsi %d vector %d ioapic %d pin %d triggering %d polarity %d\n",
+               irq, gsi, vector, ioapic, ioapic_pin, trigger, polarity);
+
+       setup_ioapic_entry(ioapic, -1, &entry, ~0, trigger, polarity, vector,
+                          ioapic_pin);
+       ioapic_write_entry(ioapic, ioapic_pin, entry);
+}
+
 int xen_register_gsi(u32 gsi, int triggering, int polarity)
 {
        int irq;
@@ -25,6 +53,11 @@ int xen_register_gsi(u32 gsi, int triggering, int polarity)
 
        printk(KERN_DEBUG "xen: --> irq=%d\n", irq);
 
+       if (irq > 0)
+               xen_set_io_apic_routing(irq,
+                                       triggering == ACPI_EDGE_SENSITIVE ? 0 : 1,
+                                       polarity == ACPI_ACTIVE_HIGH ? 0 : 1);
+
        return irq;
 }