~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/mips/kernel/crash.c

Version: ~ [ linux-5.10-rc5 ] ~ [ linux-5.9.10 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.79 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.159 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.208 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.245 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.245 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #include <linux/kernel.h>
  2 #include <linux/smp.h>
  3 #include <linux/reboot.h>
  4 #include <linux/kexec.h>
  5 #include <linux/bootmem.h>
  6 #include <linux/crash_dump.h>
  7 #include <linux/delay.h>
  8 #include <linux/irq.h>
  9 #include <linux/types.h>
 10 #include <linux/sched.h>
 11 
 12 /* This keeps a track of which one is crashing cpu. */
 13 static int crashing_cpu = -1;
 14 static cpumask_t cpus_in_crash = CPU_MASK_NONE;
 15 
 16 #ifdef CONFIG_SMP
 17 static void crash_shutdown_secondary(void *passed_regs)
 18 {
 19         struct pt_regs *regs = passed_regs;
 20         int cpu = smp_processor_id();
 21 
 22         /*
 23          * If we are passed registers, use those.  Otherwise get the
 24          * regs from the last interrupt, which should be correct, as
 25          * we are in an interrupt.  But if the regs are not there,
 26          * pull them from the top of the stack.  They are probably
 27          * wrong, but we need something to keep from crashing again.
 28          */
 29         if (!regs)
 30                 regs = get_irq_regs();
 31         if (!regs)
 32                 regs = task_pt_regs(current);
 33 
 34         if (!cpu_online(cpu))
 35                 return;
 36 
 37         /* We won't be sent IPIs any more. */
 38         set_cpu_online(cpu, false);
 39 
 40         local_irq_disable();
 41         if (!cpu_isset(cpu, cpus_in_crash))
 42                 crash_save_cpu(regs, cpu);
 43         cpu_set(cpu, cpus_in_crash);
 44 
 45         while (!atomic_read(&kexec_ready_to_reboot))
 46                 cpu_relax();
 47         relocated_kexec_smp_wait(NULL);
 48         /* NOTREACHED */
 49 }
 50 
 51 static void crash_kexec_prepare_cpus(void)
 52 {
 53         unsigned int msecs;
 54 
 55         unsigned int ncpus = num_online_cpus() - 1;/* Excluding the panic cpu */
 56 
 57         dump_send_ipi(crash_shutdown_secondary);
 58         smp_wmb();
 59 
 60         /*
 61          * The crash CPU sends an IPI and wait for other CPUs to
 62          * respond. Delay of at least 10 seconds.
 63          */
 64         pr_emerg("Sending IPI to other cpus...\n");
 65         msecs = 10000;
 66         while ((cpus_weight(cpus_in_crash) < ncpus) && (--msecs > 0)) {
 67                 cpu_relax();
 68                 mdelay(1);
 69         }
 70 }
 71 
 72 #else /* !defined(CONFIG_SMP)  */
 73 static void crash_kexec_prepare_cpus(void) {}
 74 #endif /* !defined(CONFIG_SMP)  */
 75 
 76 void default_machine_crash_shutdown(struct pt_regs *regs)
 77 {
 78         local_irq_disable();
 79         crashing_cpu = smp_processor_id();
 80         crash_save_cpu(regs, crashing_cpu);
 81         crash_kexec_prepare_cpus();
 82         cpu_set(crashing_cpu, cpus_in_crash);
 83 }
 84 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp