Skip to content

Commit 1016f98

Browse files
brglgregkh
authored andcommitted
irqchip/irq-mtk-sysirq: Replace spinlock with raw_spinlock
[ Upstream commit 6eeb997 ] This driver may take a regular spinlock when a raw spinlock (irq_desc->lock) is already taken which results in the following lockdep splat: ============================= [ BUG: Invalid wait context ] 5.7.0-rc7 #1 Not tainted ----------------------------- swapper/0/0 is trying to lock: ffffff800303b798 (&chip_data->lock){....}-{3:3}, at: mtk_sysirq_set_type+0x48/0xc0 other info that might help us debug this: context-{5:5} 2 locks held by swapper/0/0: #0: ffffff800302ee68 (&desc->request_mutex){....}-{4:4}, at: __setup_irq+0xc4/0x8a0 #1: ffffff800302ecf0 (&irq_desc_lock_class){....}-{2:2}, at: __setup_irq+0xe4/0x8a0 stack backtrace: CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.7.0-rc7 #1 Hardware name: Pumpkin MT8516 (DT) Call trace: dump_backtrace+0x0/0x180 show_stack+0x14/0x20 dump_stack+0xd0/0x118 __lock_acquire+0x8c8/0x2270 lock_acquire+0xf8/0x470 _raw_spin_lock_irqsave+0x50/0x78 mtk_sysirq_set_type+0x48/0xc0 __irq_set_trigger+0x58/0x170 __setup_irq+0x420/0x8a0 request_threaded_irq+0xd8/0x190 timer_of_init+0x1e8/0x2c4 mtk_gpt_init+0x5c/0x1dc timer_probe+0x74/0xf4 time_init+0x14/0x44 start_kernel+0x394/0x4f0 Replace the spinlock_t with raw_spinlock_t to avoid this warning. Signed-off-by: Bartosz Golaszewski <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sasha Levin <[email protected]>
1 parent 2b8064d commit 1016f98

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/irqchip/irq-mtk-sysirq.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <linux/spinlock.h>
2424

2525
struct mtk_sysirq_chip_data {
26-
spinlock_t lock;
26+
raw_spinlock_t lock;
2727
u32 nr_intpol_bases;
2828
void __iomem **intpol_bases;
2929
u32 *intpol_words;
@@ -45,7 +45,7 @@ static int mtk_sysirq_set_type(struct irq_data *data, unsigned int type)
4545
reg_index = chip_data->which_word[hwirq];
4646
offset = hwirq & 0x1f;
4747

48-
spin_lock_irqsave(&chip_data->lock, flags);
48+
raw_spin_lock_irqsave(&chip_data->lock, flags);
4949
value = readl_relaxed(base + reg_index * 4);
5050
if (type == IRQ_TYPE_LEVEL_LOW || type == IRQ_TYPE_EDGE_FALLING) {
5151
if (type == IRQ_TYPE_LEVEL_LOW)
@@ -61,7 +61,7 @@ static int mtk_sysirq_set_type(struct irq_data *data, unsigned int type)
6161

6262
data = data->parent_data;
6363
ret = data->chip->irq_set_type(data, type);
64-
spin_unlock_irqrestore(&chip_data->lock, flags);
64+
raw_spin_unlock_irqrestore(&chip_data->lock, flags);
6565
return ret;
6666
}
6767

@@ -220,7 +220,7 @@ static int __init mtk_sysirq_of_init(struct device_node *node,
220220
ret = -ENOMEM;
221221
goto out_free_which_word;
222222
}
223-
spin_lock_init(&chip_data->lock);
223+
raw_spin_lock_init(&chip_data->lock);
224224

225225
return 0;
226226

0 commit comments

Comments
 (0)