Skip to content

Commit f872d4a

Browse files
Arseniy KrasnovKAGA-KOKO
Arseniy Krasnov
authored andcommitted
irqchip/meson-gpio: Convert meson_gpio_irq_controller::lock to 'raw_spinlock_t'
This lock is acquired under irq_desc::lock with interrupts disabled. When PREEMPT_RT is enabled, 'spinlock_t' becomes preemptible, which results in invalid lock acquire context; [ BUG: Invalid wait context ] swapper/0/1 is trying to lock: ffff0000008fed30 (&ctl->lock){....}-{3:3}, at: meson_gpio_irq_update_bits0 other info that might help us debug this: context-{5:5} 3 locks held by swapper/0/1: #0: ffff0000003cd0f8 (&dev->mutex){....}-{4:4}, at: __driver_attach+0x90c #1: ffff000004714650 (&desc->request_mutex){+.+.}-{4:4}, at: __setup_irq0 #2: ffff0000047144c8 (&irq_desc_lock_class){-.-.}-{2:2}, at: __setup_irq0 stack backtrace: CPU: 1 PID: 1 Comm: swapper/0 Not tainted 6.9.9-sdkernel #1 Call trace: _raw_spin_lock_irqsave+0x60/0x88 meson_gpio_irq_update_bits+0x34/0x70 meson8_gpio_irq_set_type+0x78/0xc4 meson_gpio_irq_set_type+0x30/0x60 __irq_set_trigger+0x60/0x180 __setup_irq+0x30c/0x6e0 request_threaded_irq+0xec/0x1a4 Fixes: 215f4cc ("irqchip/meson: Add support for gpio interrupt controller") Signed-off-by: Arseniy Krasnov <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/all/[email protected]
1 parent a4765eb commit f872d4a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

drivers/irqchip/irq-meson-gpio.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ struct meson_gpio_irq_controller {
178178
void __iomem *base;
179179
u32 channel_irqs[MAX_NUM_CHANNEL];
180180
DECLARE_BITMAP(channel_map, MAX_NUM_CHANNEL);
181-
spinlock_t lock;
181+
raw_spinlock_t lock;
182182
};
183183

184184
static void meson_gpio_irq_update_bits(struct meson_gpio_irq_controller *ctl,
@@ -187,14 +187,14 @@ static void meson_gpio_irq_update_bits(struct meson_gpio_irq_controller *ctl,
187187
unsigned long flags;
188188
u32 tmp;
189189

190-
spin_lock_irqsave(&ctl->lock, flags);
190+
raw_spin_lock_irqsave(&ctl->lock, flags);
191191

192192
tmp = readl_relaxed(ctl->base + reg);
193193
tmp &= ~mask;
194194
tmp |= val;
195195
writel_relaxed(tmp, ctl->base + reg);
196196

197-
spin_unlock_irqrestore(&ctl->lock, flags);
197+
raw_spin_unlock_irqrestore(&ctl->lock, flags);
198198
}
199199

200200
static void meson_gpio_irq_init_dummy(struct meson_gpio_irq_controller *ctl)
@@ -244,20 +244,20 @@ meson_gpio_irq_request_channel(struct meson_gpio_irq_controller *ctl,
244244
unsigned long flags;
245245
unsigned int idx;
246246

247-
spin_lock_irqsave(&ctl->lock, flags);
247+
raw_spin_lock_irqsave(&ctl->lock, flags);
248248

249249
/* Find a free channel */
250250
idx = find_first_zero_bit(ctl->channel_map, ctl->params->nr_channels);
251251
if (idx >= ctl->params->nr_channels) {
252-
spin_unlock_irqrestore(&ctl->lock, flags);
252+
raw_spin_unlock_irqrestore(&ctl->lock, flags);
253253
pr_err("No channel available\n");
254254
return -ENOSPC;
255255
}
256256

257257
/* Mark the channel as used */
258258
set_bit(idx, ctl->channel_map);
259259

260-
spin_unlock_irqrestore(&ctl->lock, flags);
260+
raw_spin_unlock_irqrestore(&ctl->lock, flags);
261261

262262
/*
263263
* Setup the mux of the channel to route the signal of the pad
@@ -567,7 +567,7 @@ static int meson_gpio_irq_of_init(struct device_node *node, struct device_node *
567567
if (!ctl)
568568
return -ENOMEM;
569569

570-
spin_lock_init(&ctl->lock);
570+
raw_spin_lock_init(&ctl->lock);
571571

572572
ctl->base = of_iomap(node, 0);
573573
if (!ctl->base) {

0 commit comments

Comments
 (0)