Merge git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6
[sfrench/cifs-2.6.git] / arch / powerpc / platforms / iseries / irq.c
index 62bbbcf5ded3e27d19f5c2ed0f1d2e402171b87f..5225abfafd9b8f44b1ec7e7aeac3cfe800e233a7 100644 (file)
@@ -23,7 +23,6 @@
  *   Created, December 13, 2000 by Wayne Holm
  * End Change Activity
  */
-#include <linux/config.h>
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/threads.h>
 #include "irq.h"
 #include "pci.h"
 #include "call_pci.h"
-
-#if defined(CONFIG_SMP)
-extern void iSeries_smp_message_recv(struct pt_regs *);
-#endif
+#include "smp.h"
 
 #ifdef CONFIG_PCI
 
@@ -89,7 +85,7 @@ static DEFINE_SPINLOCK(pending_irqs_lock);
 static int num_pending_irqs;
 static int pending_irqs[NR_IRQS];
 
-static void int_received(struct pci_event *event, struct pt_regs *regs)
+static void int_received(struct pci_event *event)
 {
        int irq;
 
@@ -147,11 +143,11 @@ static void int_received(struct pci_event *event, struct pt_regs *regs)
        }
 }
 
-static void pci_event_handler(struct HvLpEvent *event, struct pt_regs *regs)
+static void pci_event_handler(struct HvLpEvent *event)
 {
        if (event && (event->xType == HvLpEvent_Type_PciIo)) {
                if (hvlpevent_is_int(event))
-                       int_received((struct pci_event *)event, regs);
+                       int_received((struct pci_event *)event);
                else
                        printk(KERN_ERR
                                "pci_event_handler: unexpected ack received\n");
@@ -163,27 +159,6 @@ static void pci_event_handler(struct HvLpEvent *event, struct pt_regs *regs)
                printk(KERN_ERR "pci_event_handler: NULL event received\n");
 }
 
-/*
- * This is called by init_IRQ.  set in ppc_md.init_IRQ by iSeries_setup.c
- * It must be called before the bus walk.
- */
-void __init iSeries_init_IRQ(void)
-{
-       /* Register PCI event handler and open an event path */
-       int ret;
-
-       ret = HvLpEvent_registerHandler(HvLpEvent_Type_PciIo,
-                       &pci_event_handler);
-       if (ret == 0) {
-               ret = HvLpEvent_openPath(HvLpEvent_Type_PciIo, 0);
-               if (ret != 0)
-                       printk(KERN_ERR "iseries_init_IRQ: open event path "
-                                       "failed with rc 0x%x\n", ret);
-       } else
-               printk(KERN_ERR "iseries_init_IRQ: register handler "
-                               "failed with rc 0x%x\n", ret);
-}
-
 #define REAL_IRQ_TO_SUBBUS(irq)        (((irq) >> 14) & 0xff)
 #define REAL_IRQ_TO_BUS(irq)   ((((irq) >> 6) & 0xff) + 1)
 #define REAL_IRQ_TO_IDSEL(irq) ((((irq) >> 3) & 7) + 1)
@@ -197,7 +172,7 @@ static void iseries_enable_IRQ(unsigned int irq)
 {
        u32 bus, dev_id, function, mask;
        const u32 sub_bus = 0;
-       unsigned int rirq = virt_irq_to_real_map[irq];
+       unsigned int rirq = (unsigned int)irq_map[irq].hwirq;
 
        /* The IRQ has already been locked by the caller */
        bus = REAL_IRQ_TO_BUS(rirq);
@@ -214,7 +189,7 @@ static unsigned int iseries_startup_IRQ(unsigned int irq)
 {
        u32 bus, dev_id, function, mask;
        const u32 sub_bus = 0;
-       unsigned int rirq = virt_irq_to_real_map[irq];
+       unsigned int rirq = (unsigned int)irq_map[irq].hwirq;
 
        bus = REAL_IRQ_TO_BUS(rirq);
        function = REAL_IRQ_TO_FUNC(rirq);
@@ -242,9 +217,9 @@ void __init iSeries_activate_IRQs()
        for_each_irq (irq) {
                irq_desc_t *desc = get_irq_desc(irq);
 
-               if (desc && desc->handler && desc->handler->startup) {
+               if (desc && desc->chip && desc->chip->startup) {
                        spin_lock_irqsave(&desc->lock, flags);
-                       desc->handler->startup(irq);
+                       desc->chip->startup(irq);
                        spin_unlock_irqrestore(&desc->lock, flags);
                }
        }
@@ -255,7 +230,7 @@ static void iseries_shutdown_IRQ(unsigned int irq)
 {
        u32 bus, dev_id, function, mask;
        const u32 sub_bus = 0;
-       unsigned int rirq = virt_irq_to_real_map[irq];
+       unsigned int rirq = (unsigned int)irq_map[irq].hwirq;
 
        /* irq should be locked by the caller */
        bus = REAL_IRQ_TO_BUS(rirq);
@@ -278,7 +253,7 @@ static void iseries_disable_IRQ(unsigned int irq)
 {
        u32 bus, dev_id, function, mask;
        const u32 sub_bus = 0;
-       unsigned int rirq = virt_irq_to_real_map[irq];
+       unsigned int rirq = (unsigned int)irq_map[irq].hwirq;
 
        /* The IRQ has already been locked by the caller */
        bus = REAL_IRQ_TO_BUS(rirq);
@@ -292,19 +267,19 @@ static void iseries_disable_IRQ(unsigned int irq)
 
 static void iseries_end_IRQ(unsigned int irq)
 {
-       unsigned int rirq = virt_irq_to_real_map[irq];
+       unsigned int rirq = (unsigned int)irq_map[irq].hwirq;
 
        HvCallPci_eoi(REAL_IRQ_TO_BUS(rirq), REAL_IRQ_TO_SUBBUS(rirq),
                (REAL_IRQ_TO_IDSEL(rirq) << 4) + REAL_IRQ_TO_FUNC(rirq));
 }
 
-static hw_irq_controller iSeries_IRQ_handler = {
-       .typename = "iSeries irq controller",
-       .startup = iseries_startup_IRQ,
-       .shutdown = iseries_shutdown_IRQ,
-       .enable = iseries_enable_IRQ,
-       .disable = iseries_disable_IRQ,
-       .end = iseries_end_IRQ
+static struct irq_chip iseries_pic = {
+       .typename       = "iSeries irq controller",
+       .startup        = iseries_startup_IRQ,
+       .shutdown       = iseries_shutdown_IRQ,
+       .unmask         = iseries_enable_IRQ,
+       .mask           = iseries_disable_IRQ,
+       .eoi            = iseries_end_IRQ
 };
 
 /*
@@ -315,17 +290,14 @@ static hw_irq_controller iSeries_IRQ_handler = {
 int __init iSeries_allocate_IRQ(HvBusNumber bus,
                HvSubBusNumber sub_bus, u32 bsubbus)
 {
-       int virtirq;
        unsigned int realirq;
        u8 idsel = ISERIES_GET_DEVICE_FROM_SUBBUS(bsubbus);
        u8 function = ISERIES_GET_FUNCTION_FROM_SUBBUS(bsubbus);
 
        realirq = (((((sub_bus << 8) + (bus - 1)) << 3) + (idsel - 1)) << 3)
                + function;
-       virtirq = virt_irq_create_mapping(realirq);
 
-       irq_desc[virtirq].handler = &iSeries_IRQ_handler;
-       return virtirq;
+       return irq_create_mapping(NULL, realirq);
 }
 
 #endif /* CONFIG_PCI */
@@ -333,19 +305,18 @@ int __init iSeries_allocate_IRQ(HvBusNumber bus,
 /*
  * Get the next pending IRQ.
  */
-int iSeries_get_irq(struct pt_regs *regs)
+unsigned int iSeries_get_irq(void)
 {
-       /* -2 means ignore this interrupt */
-       int irq = -2;
+       int irq = NO_IRQ_IGNORE;
 
 #ifdef CONFIG_SMP
        if (get_lppaca()->int_dword.fields.ipi_cnt) {
                get_lppaca()->int_dword.fields.ipi_cnt = 0;
-               iSeries_smp_message_recv(regs);
+               iSeries_smp_message_recv();
        }
 #endif /* CONFIG_SMP */
        if (hvlpevent_is_pending())
-               process_hvlpevents(regs);
+               process_hvlpevents();
 
 #ifdef CONFIG_PCI
        if (num_pending_irqs) {
@@ -359,9 +330,57 @@ int iSeries_get_irq(struct pt_regs *regs)
                }
                spin_unlock(&pending_irqs_lock);
                if (irq >= NR_IRQS)
-                       irq = -2;
+                       irq = NO_IRQ_IGNORE;
        }
 #endif
 
        return irq;
 }
+
+static int iseries_irq_host_map(struct irq_host *h, unsigned int virq,
+                               irq_hw_number_t hw)
+{
+       set_irq_chip_and_handler(virq, &iseries_pic, handle_fasteoi_irq);
+
+       return 0;
+}
+
+static struct irq_host_ops iseries_irq_host_ops = {
+       .map = iseries_irq_host_map,
+};
+
+/*
+ * This is called by init_IRQ.  set in ppc_md.init_IRQ by iSeries_setup.c
+ * It must be called before the bus walk.
+ */
+void __init iSeries_init_IRQ(void)
+{
+       /* Register PCI event handler and open an event path */
+       struct irq_host *host;
+       int ret;
+
+       /*
+        * The Hypervisor only allows us up to 256 interrupt
+        * sources (the irq number is passed in a u8).
+        */
+       irq_set_virq_count(256);
+
+       /* Create irq host. No need for a revmap since HV will give us
+        * back our virtual irq number
+        */
+       host = irq_alloc_host(IRQ_HOST_MAP_NOMAP, 0, &iseries_irq_host_ops, 0);
+       BUG_ON(host == NULL);
+       irq_set_default_host(host);
+
+       ret = HvLpEvent_registerHandler(HvLpEvent_Type_PciIo,
+                       &pci_event_handler);
+       if (ret == 0) {
+               ret = HvLpEvent_openPath(HvLpEvent_Type_PciIo, 0);
+               if (ret != 0)
+                       printk(KERN_ERR "iseries_init_IRQ: open event path "
+                                       "failed with rc 0x%x\n", ret);
+       } else
+               printk(KERN_ERR "iseries_init_IRQ: register handler "
+                               "failed with rc 0x%x\n", ret);
+}
+