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/powerpc/kernel/crash.c | |
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/powerpc/kernel/crash.c')
-rw-r--r-- | arch/powerpc/kernel/crash.c | 87 |
1 files changed, 12 insertions, 75 deletions
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 | ||