goto fail_set;
        }
 
+       ps3_chip_mask(*virq);
+
        return result;
 
 fail_set:
        pr_debug("%s:%d: node %lu, cpu %d, virq %u\n", __func__, __LINE__,
                pd->node, pd->cpu, virq);
 
+       ps3_chip_mask(virq);
+
        result = lv1_disconnect_irq_plug_ext(pd->node, pd->cpu, virq);
 
        if (result)
 {
        int result;
 
-       pr_debug(" -> %s:%d virq: %u\n", __func__, __LINE__, virq);
+       pr_debug(" -> %s:%d virq %u\n", __func__, __LINE__, virq);
+
+       ps3_chip_mask(virq);
 
        result = lv1_destruct_event_receive_port(virq_to_hw(virq));
 
                pr_debug("%s:%d: lv1_destruct_event_receive_port failed: %s\n",
                        __func__, __LINE__, ps3_result(result));
 
-       /* lv1_destruct_event_receive_port() destroys the IRQ plug,
-        * so don't call ps3_irq_plug_destroy() here.
+       /*
+        * Don't call ps3_virq_destroy() here since ps3_smp_cleanup_cpu()
+        * calls from interrupt context (smp_call_function) when kexecing.
         */
 
-       result = ps3_virq_destroy(virq);
-       BUG_ON(result);
-
        pr_debug(" <- %s:%d\n", __func__, __LINE__);
        return result;
 }
-EXPORT_SYMBOL_GPL(ps3_event_receive_port_destroy);
 
 int ps3_send_event_locally(unsigned int virq)
 {
        result = ps3_event_receive_port_destroy(virq);
        BUG_ON(result);
 
+       /*
+        * ps3_event_receive_port_destroy() destroys the IRQ plug,
+        * so don't call ps3_irq_plug_destroy() here.
+        */
+
+       result = ps3_virq_destroy(virq);
+       BUG_ON(result);
+
        pr_debug(" <- %s:%d\n", __func__, __LINE__);
        return result;
 }
 int ps3_io_irq_destroy(unsigned int virq)
 {
        int result;
+       unsigned long outlet = virq_to_hw(virq);
 
-       result = lv1_destruct_io_irq_outlet(virq_to_hw(virq));
+       ps3_chip_mask(virq);
 
-       if (result)
-               pr_debug("%s:%d: lv1_destruct_io_irq_outlet failed: %s\n",
-                       __func__, __LINE__, ps3_result(result));
+       /*
+        * lv1_destruct_io_irq_outlet() will destroy the IRQ plug,
+        * so call ps3_irq_plug_destroy() first.
+        */
 
        result = ps3_irq_plug_destroy(virq);
        BUG_ON(result);
 
+       result = lv1_destruct_io_irq_outlet(outlet);
+
+       if (result)
+               pr_debug("%s:%d: lv1_destruct_io_irq_outlet failed: %s\n",
+                       __func__, __LINE__, ps3_result(result));
+
        return result;
 }
 EXPORT_SYMBOL_GPL(ps3_io_irq_destroy);
 {
        int result;
 
+       ps3_chip_mask(virq);
        result = lv1_deconfigure_virtual_uart_irq();
 
        if (result) {
 
 int ps3_spe_irq_destroy(unsigned int virq)
 {
-       int result = ps3_irq_plug_destroy(virq);
+       int result;
+
+       ps3_chip_mask(virq);
+
+       result = ps3_irq_plug_destroy(virq);
        BUG_ON(result);
-       return 0;
+
+       return result;
 }
 
 
        pr_debug("%s:%d: hwirq %lu, virq %u\n", __func__, __LINE__, hwirq,
                virq);
 
-       set_irq_chip_and_handler(virq, &irq_chip, handle_fasteoi_irq);
+       set_irq_chip_and_handler(virq, &ps3_irq_chip, handle_fasteoi_irq);
 
        return 0;
 }
                cpu, virq, pd->bmp.ipi_debug_brk_mask);
 }
 
-unsigned int ps3_get_irq(void)
+static unsigned int ps3_get_irq(void)
 {
        struct ps3_private *pd = &__get_cpu_var(ps3_private);
        u64 x = (pd->bmp.status & pd->bmp.mask);
 
        ppc_md.get_irq = ps3_get_irq;
 }
+
+void ps3_shutdown_IRQ(int cpu)
+{
+       int result;
+       u64 ppe_id;
+       u64 thread_id = get_hard_smp_processor_id(cpu);
+
+       lv1_get_logical_ppe_id(&ppe_id);
+       result = lv1_configure_irq_state_bitmap(ppe_id, thread_id, 0);
+
+       DBG("%s:%d: lv1_configure_irq_state_bitmap (%lu:%lu/%d) %s\n", __func__,
+               __LINE__, ppe_id, thread_id, cpu, ps3_result(result));
+}
 
 #if defined(CONFIG_KEXEC)
 static void ps3_kexec_cpu_down(int crash_shutdown, int secondary)
 {
-       DBG(" -> %s:%d\n", __func__, __LINE__);
-
-       if (secondary) {
-               int cpu;
-               for_each_online_cpu(cpu)
-                       if (cpu)
-                               ps3_smp_cleanup_cpu(cpu);
-       } else
-               ps3_smp_cleanup_cpu(0);
-
-       DBG(" <- %s:%d\n", __func__, __LINE__);
-}
-
-static void ps3_machine_kexec(struct kimage *image)
-{
-       unsigned long ppe_id;
-
-       DBG(" -> %s:%d\n", __func__, __LINE__);
+       int cpu = smp_processor_id();
 
-       lv1_get_logical_ppe_id(&ppe_id);
-       lv1_configure_irq_state_bitmap(ppe_id, 0, 0);
-       ps3_mm_shutdown();
-       ps3_mm_vas_destroy();
+       DBG(" -> %s:%d: (%d)\n", __func__, __LINE__, cpu);
 
-       default_machine_kexec(image);
+       ps3_smp_cleanup_cpu(cpu);
+       ps3_shutdown_IRQ(cpu);
 
        DBG(" <- %s:%d\n", __func__, __LINE__);
 }
        .power_off                      = ps3_power_off,
 #if defined(CONFIG_KEXEC)
        .kexec_cpu_down                 = ps3_kexec_cpu_down,
-       .machine_kexec                  = ps3_machine_kexec,
+       .machine_kexec                  = default_machine_kexec,
        .machine_kexec_prepare          = default_machine_kexec_prepare,
        .machine_crash_shutdown         = default_machine_crash_shutdown,
 #endif