Skip to content

Commit 51acdfd

Browse files
author
Russell King
committed
ARM: smp: flush L1 cache in cpu_die()
Flush the L1 cache for the CPU which is going down in cpu_die() so that we don't end up with all platforms doing this. This ensures that any cache lines we own are pushed out before the cache becomes inaccessible. We may end up subsequently creating some dirty cache lines - for example, with the complete() call, but this update must become visible to other CPUs before __cpu_die() can proceed. Subsequent accesses from the platforms cpu_die() function should _not_ matter. Also place a mb() after the complete() call to ensure that this is visible to other CPUs. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent da2265b commit 51acdfd

1 file changed

Lines changed: 38 additions & 4 deletions

File tree

‎arch/arm/kernel/smp.c‎

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,13 @@ void __cpuinit __cpu_die(unsigned int cpu)
211211
}
212212
printk(KERN_NOTICE "CPU%u: shutdown\n", cpu);
213213

214+
/*
215+
* platform_cpu_kill() is generally expected to do the powering off
216+
* and/or cutting of clocks to the dying CPU. Optionally, this may
217+
* be done by the CPU which is dying in preference to supporting
218+
* this call, but that means there is _no_ synchronisation between
219+
* the requesting CPU and the dying CPU actually losing power.
220+
*/
214221
if (!platform_cpu_kill(cpu))
215222
printk("CPU%u: unable to kill\n", cpu);
216223
}
@@ -230,14 +237,41 @@ void __ref cpu_die(void)
230237
idle_task_exit();
231238

232239
local_irq_disable();
233-
mb();
234240

235-
/* Tell __cpu_die() that this CPU is now safe to dispose of */
241+
/*
242+
* Flush the data out of the L1 cache for this CPU. This must be
243+
* before the completion to ensure that data is safely written out
244+
* before platform_cpu_kill() gets called - which may disable
245+
* *this* CPU and power down its cache.
246+
*/
247+
flush_cache_louis();
248+
249+
/*
250+
* Tell __cpu_die() that this CPU is now safe to dispose of. Once
251+
* this returns, power and/or clocks can be removed at any point
252+
* from this CPU and its cache by platform_cpu_kill().
253+
*/
236254
RCU_NONIDLE(complete(&cpu_died));
237255

238256
/*
239-
* actual CPU shutdown procedure is at least platform (if not
240-
* CPU) specific.
257+
* Ensure that the cache lines associated with that completion are
258+
* written out. This covers the case where _this_ CPU is doing the
259+
* powering down, to ensure that the completion is visible to the
260+
* CPU waiting for this one.
261+
*/
262+
flush_cache_louis();
263+
264+
/*
265+
* The actual CPU shutdown procedure is at least platform (if not
266+
* CPU) specific. This may remove power, or it may simply spin.
267+
*
268+
* Platforms are generally expected *NOT* to return from this call,
269+
* although there are some which do because they have no way to
270+
* power down the CPU. These platforms are the _only_ reason we
271+
* have a return path which uses the fragment of assembly below.
272+
*
273+
* The return path should not be used for platforms which can
274+
* power off the CPU.
241275
*/
242276
if (smp_ops.cpu_die)
243277
smp_ops.cpu_die(cpu);

0 commit comments

Comments
 (0)