]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/ia64/kernel/crash.c
[IA64] kdump on INIT needs multi-nodes sync-up (v.2)
[linux-2.6-omap-h63xx.git] / arch / ia64 / kernel / crash.c
index 5cdd2f5fa064acbcd5ab266526545a5b4e77f3fd..1d64ef478dde9397ec99e5dace2ce9e52ba996d9 100644 (file)
 #include <linux/elfcore.h>
 #include <linux/sysctl.h>
 #include <linux/init.h>
+#include <linux/kdebug.h>
 
-#include <asm/kdebug.h>
 #include <asm/mca.h>
 
 int kdump_status[NR_CPUS];
-atomic_t kdump_cpu_freezed;
+static atomic_t kdump_cpu_frozen;
 atomic_t kdump_in_progress;
-int kdump_on_init = 1;
+static int kdump_on_init = 1;
 
 static inline Elf64_Word
 *append_elf_note(Elf64_Word *buf, char *name, unsigned type, void *data,
@@ -74,7 +74,7 @@ crash_save_this_cpu(void)
        buf = (u64 *) per_cpu_ptr(crash_notes, cpu);
        if (!buf)
                return;
-       buf = append_elf_note(buf, "CORE", NT_PRSTATUS, prstatus,
+       buf = append_elf_note(buf, KEXEC_CORE_NOTE_NAME, NT_PRSTATUS, prstatus,
                        sizeof(*prstatus));
        final_note(buf);
 }
@@ -86,7 +86,7 @@ kdump_wait_cpu_freeze(void)
        int cpu_num = num_online_cpus() - 1;
        int timeout = 1000;
        while(timeout-- > 0) {
-               if (atomic_read(&kdump_cpu_freezed) == cpu_num)
+               if (atomic_read(&kdump_cpu_frozen) == cpu_num)
                        return 0;
                udelay(1000);
        }
@@ -108,8 +108,8 @@ machine_crash_shutdown(struct pt_regs *pt)
        kexec_disable_iosapic();
 #ifdef CONFIG_SMP
        kdump_smp_send_stop();
+       /* not all cpu response to IPI, send INIT to freeze them */
        if (kdump_wait_cpu_freeze() && kdump_on_init)   {
-               //not all cpu response to IPI, send INIT to freeze them
                kdump_smp_send_init();
        }
 #endif
@@ -136,7 +136,7 @@ kdump_cpu_freeze(struct unw_frame_info *info, void *arg)
        cpuid = smp_processor_id();
        crash_save_this_cpu();
        current->thread.ksp = (__u64)info->sw - 16;
-       atomic_inc(&kdump_cpu_freezed);
+       atomic_inc(&kdump_cpu_frozen);
        kdump_status[cpuid] = 1;
        mb();
 #ifdef CONFIG_HOTPLUG_CPU
@@ -156,24 +156,30 @@ kdump_init_notifier(struct notifier_block *self, unsigned long val, void *data)
        if (!kdump_on_init)
                return NOTIFY_DONE;
 
-       if (val != DIE_INIT_MONARCH_ENTER &&
-           val != DIE_INIT_SLAVE_ENTER &&
+       if (val != DIE_INIT_MONARCH_LEAVE &&
+           val != DIE_INIT_SLAVE_LEAVE &&
+           val != DIE_INIT_MONARCH_PROCESS &&
            val != DIE_MCA_RENDZVOUS_LEAVE &&
            val != DIE_MCA_MONARCH_LEAVE)
                return NOTIFY_DONE;
 
        nd = (struct ia64_mca_notify_die *)args->err;
-       /* Reason code 1 means machine check rendezous*/
-       if ((val == DIE_INIT_MONARCH_ENTER || DIE_INIT_SLAVE_ENTER) &&
-                nd->sos->rv_rc == 1)
+       /* Reason code 1 means machine check rendezvous*/
+       if ((val == DIE_INIT_MONARCH_LEAVE || val == DIE_INIT_SLAVE_LEAVE
+           || val == DIE_INIT_MONARCH_PROCESS) && nd->sos->rv_rc == 1)
                return NOTIFY_DONE;
 
        switch (val) {
-               case DIE_INIT_MONARCH_ENTER:
+               case DIE_INIT_MONARCH_PROCESS:
+                       atomic_set(&kdump_in_progress, 1);
+                       *(nd->monarch_cpu) = -1;
+                       break;
+               case DIE_INIT_MONARCH_LEAVE:
                        machine_kdump_on_init();
                        break;
-               case DIE_INIT_SLAVE_ENTER:
-                       unw_init_running(kdump_cpu_freeze, NULL);
+               case DIE_INIT_SLAVE_LEAVE:
+                       if (atomic_read(&kdump_in_progress))
+                               unw_init_running(kdump_cpu_freeze, NULL);
                        break;
                case DIE_MCA_RENDZVOUS_LEAVE:
                        if (atomic_read(&kdump_in_progress))
@@ -215,8 +221,10 @@ static ctl_table sys_table[] = {
 static int
 machine_crash_setup(void)
 {
+       /* be notified before default_monarch_init_process */
        static struct notifier_block kdump_init_notifier_nb = {
                .notifier_call = kdump_init_notifier,
+               .priority = 1,
        };
        int ret;
        if((ret = register_die_notifier(&kdump_init_notifier_nb)) != 0)