Skip to content

Commit de29a96

Browse files
wenspaulmckrcu
authored andcommitted
notifier: Initialize new struct srcu_usage field
In commit 95433f7 ("srcu: Begin offloading srcu_struct fields to srcu_update"), a new struct srcu_usage field was added, but was not properly initialized. This led to a "spinlock bad magic" BUG when the SRCU notifier was ever used. This was observed in the MediaTek CCI devfreq driver on next-20230525. The trimmed stack trace is as follows: BUG: spinlock bad magic on CPU#4, swapper/0/1 lock: 0xffffff80ff529ac0, .magic: 00000000, .owner: <none>/-1, .owner_cpu: 0 Call trace: spin_bug+0xa4/0xe8 do_raw_spin_lock+0xec/0x120 _raw_spin_lock_irqsave+0x78/0xb8 synchronize_srcu+0x3c/0x168 srcu_notifier_chain_unregister+0x5c/0xa0 cpufreq_unregister_notifier+0x94/0xe0 devfreq_passive_event_handler+0x7c/0x3e0 devfreq_remove_device+0x48/0xe8 Add __SRCU_USAGE_INIT() to SRCU_NOTIFIER_INIT() so that srcu_usage gets initialized properly. Reported-by: Jon Hunter <[email protected]> Fixes: 95433f7 ("srcu: Begin offloading srcu_struct fields to srcu_update") Signed-off-by: Chen-Yu Tsai <[email protected]> Tested-by: AngeloGioacchino Del Regno <[email protected]> Cc: Matthias Brugger <[email protected]> Cc: "Rafael J. Wysocki" <[email protected]> Cc: "Michał Mirosław" <[email protected]> Cc: Dmitry Osipenko <[email protected]> Cc: Sachin Sant <[email protected]> Cc: Joel Fernandes (Google) <[email protected] Tested-by: Jon Hunter <[email protected]> Acked-by: Zqiang <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent ac9a786 commit de29a96

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

include/linux/notifier.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,22 @@ extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);
106106
#define RAW_NOTIFIER_INIT(name) { \
107107
.head = NULL }
108108

109+
#ifdef CONFIG_TREE_SRCU
109110
#define SRCU_NOTIFIER_INIT(name, pcpu) \
110111
{ \
111112
.mutex = __MUTEX_INITIALIZER(name.mutex), \
112113
.head = NULL, \
114+
.srcuu = __SRCU_USAGE_INIT(name.srcuu), \
113115
.srcu = __SRCU_STRUCT_INIT(name.srcu, name.srcuu, pcpu), \
114116
}
117+
#else
118+
#define SRCU_NOTIFIER_INIT(name, pcpu) \
119+
{ \
120+
.mutex = __MUTEX_INITIALIZER(name.mutex), \
121+
.head = NULL, \
122+
.srcu = __SRCU_STRUCT_INIT(name.srcu, name.srcuu, pcpu), \
123+
}
124+
#endif
115125

116126
#define ATOMIC_NOTIFIER_HEAD(name) \
117127
struct atomic_notifier_head name = \

0 commit comments

Comments
 (0)