diff options
author | Anton Blanchard <anton@samba.org> | 2011-11-29 19:23:10 -0500 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2011-12-07 22:02:22 -0500 |
commit | 9b00ac06978c54788f13eefd34a07b77db48d567 (patch) | |
tree | 4727d71f5d4071b5595d4268c0fe05c8bf2ae02a /arch | |
parent | 58154c8ce71a7854d969d73468fd00e5eeeab708 (diff) |
powerpc: Remove broken and complicated kdump system reset code
We have a lot of complicated logic that handles possible recursion between
kdump and a system reset exception. We can solve this in a much simpler
way using the same setjmp/longjmp tricks xmon does.
As a first step, this patch removes the old system reset code.
Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/include/asm/kexec.h | 6 | ||||
-rw-r--r-- | arch/powerpc/kernel/crash.c | 87 | ||||
-rw-r--r-- | arch/powerpc/kernel/traps.c | 33 |
3 files changed, 25 insertions, 101 deletions
diff --git a/arch/powerpc/include/asm/kexec.h b/arch/powerpc/include/asm/kexec.h index f921eb121d39..209ed8ba1637 100644 --- a/arch/powerpc/include/asm/kexec.h +++ b/arch/powerpc/include/asm/kexec.h | |||
@@ -73,11 +73,6 @@ extern void kexec_smp_wait(void); /* get and clear naca physid, wait for | |||
73 | master to copy new code to 0 */ | 73 | master to copy new code to 0 */ |
74 | extern int crashing_cpu; | 74 | extern int crashing_cpu; |
75 | extern void crash_send_ipi(void (*crash_ipi_callback)(struct pt_regs *)); | 75 | extern void crash_send_ipi(void (*crash_ipi_callback)(struct pt_regs *)); |
76 | extern cpumask_t cpus_in_sr; | ||
77 | static inline int kexec_sr_activated(int cpu) | ||
78 | { | ||
79 | return cpumask_test_cpu(cpu, &cpus_in_sr); | ||
80 | } | ||
81 | 76 | ||
82 | struct kimage; | 77 | struct kimage; |
83 | struct pt_regs; | 78 | struct pt_regs; |
@@ -94,7 +89,6 @@ extern void reserve_crashkernel(void); | |||
94 | extern void machine_kexec_mask_interrupts(void); | 89 | extern void machine_kexec_mask_interrupts(void); |
95 | 90 | ||
96 | #else /* !CONFIG_KEXEC */ | 91 | #else /* !CONFIG_KEXEC */ |
97 | static inline int kexec_sr_activated(int cpu) { return 0; } | ||
98 | static inline void crash_kexec_secondary(struct pt_regs *regs) { } | 92 | static inline void crash_kexec_secondary(struct pt_regs *regs) { } |
99 | 93 | ||
100 | static inline int overlaps_crashkernel(unsigned long start, unsigned long size) | 94 | static inline int overlaps_crashkernel(unsigned long start, unsigned long size) |
diff --git a/arch/powerpc/kernel/crash.c b/arch/powerpc/kernel/crash.c index d879809d5c45..3d87b205d5f5 100644 --- a/arch/powerpc/kernel/crash.c +++ b/arch/powerpc/kernel/crash.c | |||
@@ -47,7 +47,6 @@ | |||
47 | /* This keeps a track of which one is crashing cpu. */ | 47 | /* This keeps a track of which one is crashing cpu. */ |
48 | int crashing_cpu = -1; | 48 | int crashing_cpu = -1; |
49 | static cpumask_t cpus_in_crash = CPU_MASK_NONE; | 49 | static cpumask_t cpus_in_crash = CPU_MASK_NONE; |
50 | cpumask_t cpus_in_sr = CPU_MASK_NONE; | ||
51 | 50 | ||
52 | #define CRASH_HANDLER_MAX 3 | 51 | #define CRASH_HANDLER_MAX 3 |
53 | /* NULL terminated list of shutdown handles */ | 52 | /* NULL terminated list of shutdown handles */ |
@@ -55,7 +54,6 @@ static crash_shutdown_t crash_shutdown_handles[CRASH_HANDLER_MAX+1]; | |||
55 | static DEFINE_SPINLOCK(crash_handlers_lock); | 54 | static DEFINE_SPINLOCK(crash_handlers_lock); |
56 | 55 | ||
57 | #ifdef CONFIG_SMP | 56 | #ifdef CONFIG_SMP |
58 | static atomic_t enter_on_soft_reset = ATOMIC_INIT(0); | ||
59 | 57 | ||
60 | void crash_ipi_callback(struct pt_regs *regs) | 58 | void crash_ipi_callback(struct pt_regs *regs) |
61 | { | 59 | { |
@@ -70,23 +68,8 @@ void crash_ipi_callback(struct pt_regs *regs) | |||
70 | cpumask_set_cpu(cpu, &cpus_in_crash); | 68 | cpumask_set_cpu(cpu, &cpus_in_crash); |
71 | 69 | ||
72 | /* | 70 | /* |
73 | * Entered via soft-reset - could be the kdump | ||
74 | * process is invoked using soft-reset or user activated | ||
75 | * it if some CPU did not respond to an IPI. | ||
76 | * For soft-reset, the secondary CPU can enter this func | ||
77 | * twice. 1 - using IPI, and 2. soft-reset. | ||
78 | * Tell the kexec CPU that entered via soft-reset and ready | ||
79 | * to go down. | ||
80 | */ | ||
81 | if (cpumask_test_cpu(cpu, &cpus_in_sr)) { | ||
82 | cpumask_clear_cpu(cpu, &cpus_in_sr); | ||
83 | atomic_inc(&enter_on_soft_reset); | ||
84 | } | ||
85 | |||
86 | /* | ||
87 | * Starting the kdump boot. | 71 | * Starting the kdump boot. |
88 | * This barrier is needed to make sure that all CPUs are stopped. | 72 | * This barrier is needed to make sure that all CPUs are stopped. |
89 | * If not, soft-reset will be invoked to bring other CPUs. | ||
90 | */ | 73 | */ |
91 | while (!cpumask_test_cpu(crashing_cpu, &cpus_in_crash)) | 74 | while (!cpumask_test_cpu(crashing_cpu, &cpus_in_crash)) |
92 | cpu_relax(); | 75 | cpu_relax(); |
@@ -103,25 +86,14 @@ void crash_ipi_callback(struct pt_regs *regs) | |||
103 | /* NOTREACHED */ | 86 | /* NOTREACHED */ |
104 | } | 87 | } |
105 | 88 | ||
106 | /* | ||
107 | * Wait until all CPUs are entered via soft-reset. | ||
108 | */ | ||
109 | static void crash_soft_reset_check(int cpu) | ||
110 | { | ||
111 | unsigned int ncpus = num_online_cpus() - 1;/* Excluding the panic cpu */ | ||
112 | |||
113 | cpumask_clear_cpu(cpu, &cpus_in_sr); | ||
114 | while (atomic_read(&enter_on_soft_reset) != ncpus) | ||
115 | cpu_relax(); | ||
116 | } | ||
117 | |||
118 | |||
119 | static void crash_kexec_prepare_cpus(int cpu) | 89 | static void crash_kexec_prepare_cpus(int cpu) |
120 | { | 90 | { |
121 | unsigned int msecs; | 91 | unsigned int msecs; |
122 | 92 | ||
123 | unsigned int ncpus = num_online_cpus() - 1;/* Excluding the panic cpu */ | 93 | unsigned int ncpus = num_online_cpus() - 1;/* Excluding the panic cpu */ |
124 | 94 | ||
95 | printk(KERN_EMERG "Sending IPI to other CPUs\n"); | ||
96 | |||
125 | crash_send_ipi(crash_ipi_callback); | 97 | crash_send_ipi(crash_ipi_callback); |
126 | smp_wmb(); | 98 | smp_wmb(); |
127 | 99 | ||
@@ -131,7 +103,6 @@ static void crash_kexec_prepare_cpus(int cpu) | |||
131 | * respond. | 103 | * respond. |
132 | * Delay of at least 10 seconds. | 104 | * Delay of at least 10 seconds. |
133 | */ | 105 | */ |
134 | printk(KERN_EMERG "Sending IPI to other cpus...\n"); | ||
135 | msecs = 10000; | 106 | msecs = 10000; |
136 | while ((cpumask_weight(&cpus_in_crash) < ncpus) && (--msecs > 0)) { | 107 | while ((cpumask_weight(&cpus_in_crash) < ncpus) && (--msecs > 0)) { |
137 | cpu_relax(); | 108 | cpu_relax(); |
@@ -140,69 +111,36 @@ static void crash_kexec_prepare_cpus(int cpu) | |||
140 | 111 | ||
141 | /* Would it be better to replace the trap vector here? */ | 112 | /* Would it be better to replace the trap vector here? */ |
142 | 113 | ||
143 | /* | ||
144 | * FIXME: In case if we do not get all CPUs, one possibility: ask the | ||
145 | * user to do soft reset such that we get all. | ||
146 | * Soft-reset will be used until better mechanism is implemented. | ||
147 | */ | ||
148 | if (cpumask_weight(&cpus_in_crash) < ncpus) { | 114 | if (cpumask_weight(&cpus_in_crash) < ncpus) { |
149 | printk(KERN_EMERG "done waiting: %d cpu(s) not responding\n", | 115 | printk(KERN_EMERG "ERROR: %d CPU(s) not responding\n", |
150 | ncpus - cpumask_weight(&cpus_in_crash)); | 116 | ncpus - cpumask_weight(&cpus_in_crash)); |
151 | printk(KERN_EMERG "Activate soft-reset to stop other cpu(s)\n"); | ||
152 | cpumask_clear(&cpus_in_sr); | ||
153 | atomic_set(&enter_on_soft_reset, 0); | ||
154 | while (cpumask_weight(&cpus_in_crash) < ncpus) | ||
155 | cpu_relax(); | ||
156 | } | 117 | } |
157 | /* | 118 | |
158 | * Make sure all CPUs are entered via soft-reset if the kdump is | 119 | printk(KERN_EMERG "IPI complete\n"); |
159 | * invoked using soft-reset. | ||
160 | */ | ||
161 | if (cpumask_test_cpu(cpu, &cpus_in_sr)) | ||
162 | crash_soft_reset_check(cpu); | ||
163 | /* Leave the IPI callback set */ | ||
164 | } | 120 | } |
165 | 121 | ||
166 | /* | 122 | /* |
167 | * This function will be called by secondary cpus or by kexec cpu | 123 | * This function will be called by secondary cpus. |
168 | * if soft-reset is activated to stop some CPUs. | ||
169 | */ | 124 | */ |
170 | void crash_kexec_secondary(struct pt_regs *regs) | 125 | void crash_kexec_secondary(struct pt_regs *regs) |
171 | { | 126 | { |
172 | int cpu = smp_processor_id(); | ||
173 | unsigned long flags; | 127 | unsigned long flags; |
174 | int msecs = 5; | 128 | int msecs = 500; |
175 | 129 | ||
176 | local_irq_save(flags); | 130 | local_irq_save(flags); |
177 | /* Wait 5ms if the kexec CPU is not entered yet. */ | 131 | |
132 | /* Wait 500ms for the primary crash CPU to signal its progress */ | ||
178 | while (crashing_cpu < 0) { | 133 | while (crashing_cpu < 0) { |
179 | if (--msecs < 0) { | 134 | if (--msecs < 0) { |
180 | /* | 135 | /* No response, kdump image may not have been loaded */ |
181 | * Either kdump image is not loaded or | ||
182 | * kdump process is not started - Probably xmon | ||
183 | * exited using 'x'(exit and recover) or | ||
184 | * kexec_should_crash() failed for all running tasks. | ||
185 | */ | ||
186 | cpumask_clear_cpu(cpu, &cpus_in_sr); | ||
187 | local_irq_restore(flags); | 136 | local_irq_restore(flags); |
188 | return; | 137 | return; |
189 | } | 138 | } |
139 | |||
190 | mdelay(1); | 140 | mdelay(1); |
191 | cpu_relax(); | 141 | cpu_relax(); |
192 | } | 142 | } |
193 | if (cpu == crashing_cpu) { | 143 | |
194 | /* | ||
195 | * Panic CPU will enter this func only via soft-reset. | ||
196 | * Wait until all secondary CPUs entered and | ||
197 | * then start kexec boot. | ||
198 | */ | ||
199 | crash_soft_reset_check(cpu); | ||
200 | cpumask_set_cpu(crashing_cpu, &cpus_in_crash); | ||
201 | if (ppc_md.kexec_cpu_down) | ||
202 | ppc_md.kexec_cpu_down(1, 0); | ||
203 | machine_kexec(kexec_crash_image); | ||
204 | /* NOTREACHED */ | ||
205 | } | ||
206 | crash_ipi_callback(regs); | 144 | crash_ipi_callback(regs); |
207 | } | 145 | } |
208 | 146 | ||
@@ -225,7 +163,6 @@ static void crash_kexec_prepare_cpus(int cpu) | |||
225 | 163 | ||
226 | void crash_kexec_secondary(struct pt_regs *regs) | 164 | void crash_kexec_secondary(struct pt_regs *regs) |
227 | { | 165 | { |
228 | cpumask_clear(&cpus_in_sr); | ||
229 | } | 166 | } |
230 | #endif /* CONFIG_SMP */ | 167 | #endif /* CONFIG_SMP */ |
231 | 168 | ||
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c index 91377870b26a..014f88f03d3f 100644 --- a/arch/powerpc/kernel/traps.c +++ b/arch/powerpc/kernel/traps.c | |||
@@ -162,10 +162,20 @@ int die(const char *str, struct pt_regs *regs, long err) | |||
162 | printk("\n"); | 162 | printk("\n"); |
163 | raw_spin_unlock_irqrestore(&die.lock, flags); | 163 | raw_spin_unlock_irqrestore(&die.lock, flags); |
164 | 164 | ||
165 | if (kexec_should_crash(current) || | 165 | /* |
166 | kexec_sr_activated(smp_processor_id())) | 166 | * A system reset (0x100) is a request to dump, so we always send |
167 | * it through the crashdump code. | ||
168 | */ | ||
169 | if (kexec_should_crash(current) || (TRAP(regs) == 0x100)) { | ||
167 | crash_kexec(regs); | 170 | crash_kexec(regs); |
168 | crash_kexec_secondary(regs); | 171 | |
172 | /* | ||
173 | * We aren't the primary crash CPU. We need to send it | ||
174 | * to a holding pattern to avoid it ending up in the panic | ||
175 | * code. | ||
176 | */ | ||
177 | crash_kexec_secondary(regs); | ||
178 | } | ||
169 | 179 | ||
170 | /* | 180 | /* |
171 | * While our oops output is serialised by a spinlock, output | 181 | * While our oops output is serialised by a spinlock, output |
@@ -232,25 +242,8 @@ void system_reset_exception(struct pt_regs *regs) | |||
232 | return; | 242 | return; |
233 | } | 243 | } |
234 | 244 | ||
235 | #ifdef CONFIG_KEXEC | ||
236 | cpumask_set_cpu(smp_processor_id(), &cpus_in_sr); | ||
237 | #endif | ||
238 | |||
239 | die("System Reset", regs, SIGABRT); | 245 | die("System Reset", regs, SIGABRT); |
240 | 246 | ||
241 | /* | ||
242 | * Some CPUs when released from the debugger will execute this path. | ||
243 | * These CPUs entered the debugger via a soft-reset. If the CPU was | ||
244 | * hung before entering the debugger it will return to the hung | ||
245 | * state when exiting this function. This causes a problem in | ||
246 | * kdump since the hung CPU(s) will not respond to the IPI sent | ||
247 | * from kdump. To prevent the problem we call crash_kexec_secondary() | ||
248 | * here. If a kdump had not been initiated or we exit the debugger | ||
249 | * with the "exit and recover" command (x) crash_kexec_secondary() | ||
250 | * will return after 5ms and the CPU returns to its previous state. | ||
251 | */ | ||
252 | crash_kexec_secondary(regs); | ||
253 | |||
254 | /* Must die if the interrupt is not recoverable */ | 247 | /* Must die if the interrupt is not recoverable */ |
255 | if (!(regs->msr & MSR_RI)) | 248 | if (!(regs->msr & MSR_RI)) |
256 | panic("Unrecoverable System Reset"); | 249 | panic("Unrecoverable System Reset"); |