diff options
author | David Daney <david.daney@cavium.com> | 2013-06-14 14:13:59 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-06-15 01:24:42 -0400 |
commit | f21afc25f9ed45b8ffe200d0f071b0caec3ed2ef (patch) | |
tree | e3cd202f0830cc0f0b5fbe9318bfeebbc43ce4ea /include/linux | |
parent | d0ff9348810c5bc9fc7a3f022bdfae9b44b62f00 (diff) |
smp.h: Use local_irq_{save,restore}() in !SMP version of on_each_cpu().
Thanks to commit f91eb62f71b3 ("init: scream bloody murder if interrupts
are enabled too early"), "bloody murder" is now being screamed.
With a MIPS OCTEON config, we use on_each_cpu() in our
irq_chip.irq_bus_sync_unlock() function. This gets called in early as a
result of the time_init() call. Because the !SMP version of
on_each_cpu() unconditionally enables irqs, we get:
WARNING: at init/main.c:560 start_kernel+0x250/0x410()
Interrupts were enabled early
CPU: 0 PID: 0 Comm: swapper Not tainted 3.10.0-rc5-Cavium-Octeon+ #801
Call Trace:
show_stack+0x68/0x80
warn_slowpath_common+0x78/0xb0
warn_slowpath_fmt+0x38/0x48
start_kernel+0x250/0x410
Suggested fix: Do what we already do in the SMP version of
on_each_cpu(), and use local_irq_save/local_irq_restore. Because we
need a flags variable, make it a static inline to avoid name space
issues.
[ Change from v1: Convert on_each_cpu to a static inline function, add
#include <linux/irqflags.h> to avoid build breakage on some files.
on_each_cpu_mask() and on_each_cpu_cond() suffer the same problem as
on_each_cpu(), but they are not causing !SMP bugs for me, so I will
defer changing them to a less urgent patch. ]
Signed-off-by: David Daney <david.daney@cavium.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/smp.h | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/include/linux/smp.h b/include/linux/smp.h index e6564c1dc552..c8488763277f 100644 --- a/include/linux/smp.h +++ b/include/linux/smp.h | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/list.h> | 11 | #include <linux/list.h> |
12 | #include <linux/cpumask.h> | 12 | #include <linux/cpumask.h> |
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/irqflags.h> | ||
14 | 15 | ||
15 | extern void cpu_idle(void); | 16 | extern void cpu_idle(void); |
16 | 17 | ||
@@ -139,13 +140,17 @@ static inline int up_smp_call_function(smp_call_func_t func, void *info) | |||
139 | } | 140 | } |
140 | #define smp_call_function(func, info, wait) \ | 141 | #define smp_call_function(func, info, wait) \ |
141 | (up_smp_call_function(func, info)) | 142 | (up_smp_call_function(func, info)) |
142 | #define on_each_cpu(func,info,wait) \ | 143 | |
143 | ({ \ | 144 | static inline int on_each_cpu(smp_call_func_t func, void *info, int wait) |
144 | local_irq_disable(); \ | 145 | { |
145 | func(info); \ | 146 | unsigned long flags; |
146 | local_irq_enable(); \ | 147 | |
147 | 0; \ | 148 | local_irq_save(flags); |
148 | }) | 149 | func(info); |
150 | local_irq_restore(flags); | ||
151 | return 0; | ||
152 | } | ||
153 | |||
149 | /* | 154 | /* |
150 | * Note we still need to test the mask even for UP | 155 | * Note we still need to test the mask even for UP |
151 | * because we actually can get an empty mask from | 156 | * because we actually can get an empty mask from |