Merge master.kernel.org:/pub/scm/linux/kernel/git/davej/cpufreq
[pandora-kernel.git] / arch / powerpc / platforms / pseries / xics.c
index 716972a..253972e 100644 (file)
@@ -34,6 +34,7 @@
 #include <asm/i8259.h>
 
 #include "xics.h"
+#include "plpar_wrappers.h"
 
 #define XICS_IPI               2
 #define XICS_IRQ_SPURIOUS      0
@@ -110,27 +111,6 @@ static inline void direct_qirr_info(int n_cpu, u8 value)
 /* LPAR low level accessors */
 
 
-static inline long plpar_eoi(unsigned long xirr)
-{
-       return plpar_hcall_norets(H_EOI, xirr);
-}
-
-static inline long plpar_cppr(unsigned long cppr)
-{
-       return plpar_hcall_norets(H_CPPR, cppr);
-}
-
-static inline long plpar_ipi(unsigned long servernum, unsigned long mfrr)
-{
-       return plpar_hcall_norets(H_IPI, servernum, mfrr);
-}
-
-static inline long plpar_xirr(unsigned long *xirr_ret)
-{
-       unsigned long dummy;
-       return plpar_hcall(H_XIRR, 0, 0, 0, 0, xirr_ret, &dummy, &dummy);
-}
-
 static inline unsigned int lpar_xirr_info_get(int n_cpu)
 {
        unsigned long lpar_rc;
@@ -467,7 +447,7 @@ void xics_setup_cpu(void)
         *
         * XXX: undo of teardown on kexec needs this too, as may hotplug
         */
-       rtas_set_indicator(GLOBAL_INTERRUPT_QUEUE,
+       rtas_set_indicator_fast(GLOBAL_INTERRUPT_QUEUE,
                (1UL << interrupt_server_size) - 1 - default_distrib_server, 1);
 }
 
@@ -502,16 +482,9 @@ static int xics_host_match(struct irq_host *h, struct device_node *node)
 }
 
 static int xics_host_map_direct(struct irq_host *h, unsigned int virq,
-                               irq_hw_number_t hw, unsigned int flags)
+                               irq_hw_number_t hw)
 {
-       unsigned int sense = flags & IRQ_TYPE_SENSE_MASK;
-
-       pr_debug("xics: map_direct virq %d, hwirq 0x%lx, flags: 0x%x\n",
-                virq, hw, flags);
-
-       if (sense && sense != IRQ_TYPE_LEVEL_LOW)
-               printk(KERN_WARNING "xics: using unsupported sense 0x%x"
-                      " for irq %d (h: 0x%lx)\n", flags, virq, hw);
+       pr_debug("xics: map_direct virq %d, hwirq 0x%lx\n", virq, hw);
 
        get_irq_desc(virq)->status |= IRQ_LEVEL;
        set_irq_chip_and_handler(virq, &xics_pic_direct, handle_fasteoi_irq);
@@ -519,16 +492,9 @@ static int xics_host_map_direct(struct irq_host *h, unsigned int virq,
 }
 
 static int xics_host_map_lpar(struct irq_host *h, unsigned int virq,
-                             irq_hw_number_t hw, unsigned int flags)
+                             irq_hw_number_t hw)
 {
-       unsigned int sense = flags & IRQ_TYPE_SENSE_MASK;
-
-       pr_debug("xics: map_lpar virq %d, hwirq 0x%lx, flags: 0x%x\n",
-                virq, hw, flags);
-
-       if (sense && sense != IRQ_TYPE_LEVEL_LOW)
-               printk(KERN_WARNING "xics: using unsupported sense 0x%x"
-                      " for irq %d (h: 0x%lx)\n", flags, virq, hw);
+       pr_debug("xics: map_direct virq %d, hwirq 0x%lx\n", virq, hw);
 
        get_irq_desc(virq)->status |= IRQ_LEVEL;
        set_irq_chip_and_handler(virq, &xics_pic_lpar, handle_fasteoi_irq);
@@ -604,14 +570,14 @@ static void __init xics_init_one_node(struct device_node *np,
                                      unsigned int *indx)
 {
        unsigned int ilen;
-       u32 *ireg;
+       const u32 *ireg;
 
        /* This code does the theorically broken assumption that the interrupt
         * server numbers are the same as the hard CPU numbers.
         * This happens to be the case so far but we are playing with fire...
         * should be fixed one of these days. -BenH.
         */
-       ireg = (u32 *)get_property(np, "ibm,interrupt-server-ranges", NULL);
+       ireg = get_property(np, "ibm,interrupt-server-ranges", NULL);
 
        /* Do that ever happen ? we'll know soon enough... but even good'old
         * f80 does have that property ..
@@ -623,7 +589,7 @@ static void __init xics_init_one_node(struct device_node *np,
                 */
                *indx = *ireg;
        }
-       ireg = (u32 *)get_property(np, "reg", &ilen);
+       ireg = get_property(np, "reg", &ilen);
        if (!ireg)
                panic("xics_init_IRQ: can't find interrupt reg property");
 
@@ -649,7 +615,7 @@ static void __init xics_setup_8259_cascade(void)
 {
        struct device_node *np, *old, *found = NULL;
        int cascade, naddr;
-       u32 *addrp;
+       const u32 *addrp;
        unsigned long intack = 0;
 
        for_each_node_by_type(np, "interrupt-controller")
@@ -675,7 +641,7 @@ static void __init xics_setup_8259_cascade(void)
                        break;
                if (strcmp(np->name, "pci") != 0)
                        continue;
-               addrp = (u32 *)get_property(np, "8259-interrupt-acknowledge", NULL);
+               addrp = get_property(np, "8259-interrupt-acknowledge", NULL);
                if (addrp == NULL)
                        continue;
                naddr = prom_n_addr_cells(np);
@@ -694,7 +660,8 @@ void __init xics_init_IRQ(void)
 {
        int i;
        struct device_node *np;
-       u32 *ireg, ilen, indx = 0;
+       u32 ilen, indx = 0;
+       const u32 *ireg;
        int found = 0;
 
        ppc64_boot_msg(0x20, "XICS Init");
@@ -719,18 +686,17 @@ void __init xics_init_IRQ(void)
        for (np = of_find_node_by_type(NULL, "cpu");
             np;
             np = of_find_node_by_type(np, "cpu")) {
-               ireg = (u32 *)get_property(np, "reg", &ilen);
+               ireg = get_property(np, "reg", &ilen);
                if (ireg && ireg[0] == get_hard_smp_processor_id(boot_cpuid)) {
-                       ireg = (u32 *)get_property(np,
-                                                 "ibm,ppc-interrupt-gserver#s",
-                                                  &ilen);
+                       ireg = get_property(np,
+                                       "ibm,ppc-interrupt-gserver#s", &ilen);
                        i = ilen / sizeof(int);
                        if (ireg && i > 0) {
                                default_server = ireg[0];
                                /* take last element */
                                default_distrib_server = ireg[i-1];
                        }
-                       ireg = (u32 *)get_property(np,
+                       ireg = get_property(np,
                                        "ibm,interrupt-server#-size", NULL);
                        if (ireg)
                                interrupt_server_size = *ireg;
@@ -757,7 +723,7 @@ void xics_request_IPIs(void)
 {
        unsigned int ipi;
 
-       ipi = irq_create_mapping(xics_host, XICS_IPI, 0);
+       ipi = irq_create_mapping(xics_host, XICS_IPI);
        BUG_ON(ipi == NO_IRQ);
 
        /*
@@ -782,6 +748,14 @@ void xics_teardown_cpu(int secondary)
 
        xics_set_cpu_priority(cpu, 0);
 
+       /*
+        * Clear IPI
+        */
+       if (firmware_has_feature(FW_FEATURE_LPAR))
+               lpar_qirr_info(cpu, 0xff);
+       else
+               direct_qirr_info(cpu, 0xff);
+
        /*
         * we need to EOI the IPI if we got here from kexec down IPI
         *
@@ -795,14 +769,14 @@ void xics_teardown_cpu(int secondary)
                return;
        desc = get_irq_desc(ipi);
        if (desc->chip && desc->chip->eoi)
-               desc->chip->eoi(XICS_IPI);
+               desc->chip->eoi(ipi);
 
        /*
         * Some machines need to have at least one cpu in the GIQ,
         * so leave the master cpu in the group.
         */
        if (secondary)
-               rtas_set_indicator(GLOBAL_INTERRUPT_QUEUE,
+               rtas_set_indicator_fast(GLOBAL_INTERRUPT_QUEUE,
                                   (1UL << interrupt_server_size) - 1 -
                                   default_distrib_server, 0);
 }
@@ -819,7 +793,7 @@ void xics_migrate_irqs_away(void)
        xics_set_cpu_priority(cpu, 0);
 
        /* remove ourselves from the global interrupt queue */
-       status = rtas_set_indicator(GLOBAL_INTERRUPT_QUEUE,
+       status = rtas_set_indicator_fast(GLOBAL_INTERRUPT_QUEUE,
                (1UL << interrupt_server_size) - 1 - default_distrib_server, 0);
        WARN_ON(status < 0);