Skip to content

Commit 362e08f

Browse files
committed
gpio: xilinx: use raw_spinlock
The IRQ core holds a raw spinlock when calling into the driver callbacks, which leads to the following warning: [ 5.127179] ============================= [ 5.131218] [ BUG: Invalid wait context ] [ 5.135255] 6.5.10-xilinx-00026-g692b34c40d2f-dirty torvalds#482 Not tainted [ 5.141653] ----------------------------- [ 5.145695] swapper/0/1 is trying to lock: [ 5.149827] c18ecd78 (&chip->gpio_lock){....}-{3:3}, at: xgpio_irq_unmask+0x50/0xd4 [ 5.157602] other info that might help us debug this: [ 5.162687] context-{5:5} [ 5.165331] 3 locks held by swapper/0/1: [ 5.169287] #0: c1b6ec84 (&dev->mutex){....}-{4:4}, at: __driver_attach+0xd8/0xf8 [ 5.176984] #1: c1903364 (request_class){+.+.}-{4:4}, at: __setup_irq+0x20c/0x6dc [ 5.184673] #2: c190327c (lock_class#2){....}-{2:2}, at: __setup_irq+0x2cc/0x6dc Fix this by using a raw spinlock in the gpio-xilinx driver as well. Signed-off-by: Daniel Mack <[email protected]>
1 parent 8ca29e3 commit 362e08f

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

drivers/gpio/gpio-xilinx.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ struct xgpio_instance {
6666
DECLARE_BITMAP(state, 64);
6767
DECLARE_BITMAP(last_irq_read, 64);
6868
DECLARE_BITMAP(dir, 64);
69-
spinlock_t gpio_lock; /* For serializing operations */
69+
raw_spinlock_t gpio_lock; /* For serializing operations */
7070
int irq;
7171
DECLARE_BITMAP(enable, 64);
7272
DECLARE_BITMAP(rising_edge, 64);
@@ -180,14 +180,14 @@ static void xgpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
180180
struct xgpio_instance *chip = gpiochip_get_data(gc);
181181
int bit = xgpio_to_bit(chip, gpio);
182182

183-
spin_lock_irqsave(&chip->gpio_lock, flags);
183+
raw_spin_lock_irqsave(&chip->gpio_lock, flags);
184184

185185
/* Write to GPIO signal and set its direction to output */
186186
__assign_bit(bit, chip->state, val);
187187

188188
xgpio_write_ch(chip, XGPIO_DATA_OFFSET, bit, chip->state);
189189

190-
spin_unlock_irqrestore(&chip->gpio_lock, flags);
190+
raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
191191
}
192192

193193
/**
@@ -211,15 +211,15 @@ static void xgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask,
211211
bitmap_remap(hw_mask, mask, chip->sw_map, chip->hw_map, 64);
212212
bitmap_remap(hw_bits, bits, chip->sw_map, chip->hw_map, 64);
213213

214-
spin_lock_irqsave(&chip->gpio_lock, flags);
214+
raw_spin_lock_irqsave(&chip->gpio_lock, flags);
215215

216216
bitmap_replace(state, chip->state, hw_bits, hw_mask, 64);
217217

218218
xgpio_write_ch_all(chip, XGPIO_DATA_OFFSET, state);
219219

220220
bitmap_copy(chip->state, state, 64);
221221

222-
spin_unlock_irqrestore(&chip->gpio_lock, flags);
222+
raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
223223
}
224224

225225
/**
@@ -237,13 +237,13 @@ static int xgpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
237237
struct xgpio_instance *chip = gpiochip_get_data(gc);
238238
int bit = xgpio_to_bit(chip, gpio);
239239

240-
spin_lock_irqsave(&chip->gpio_lock, flags);
240+
raw_spin_lock_irqsave(&chip->gpio_lock, flags);
241241

242242
/* Set the GPIO bit in shadow register and set direction as input */
243243
__set_bit(bit, chip->dir);
244244
xgpio_write_ch(chip, XGPIO_TRI_OFFSET, bit, chip->dir);
245245

246-
spin_unlock_irqrestore(&chip->gpio_lock, flags);
246+
raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
247247

248248
return 0;
249249
}
@@ -266,7 +266,7 @@ static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
266266
struct xgpio_instance *chip = gpiochip_get_data(gc);
267267
int bit = xgpio_to_bit(chip, gpio);
268268

269-
spin_lock_irqsave(&chip->gpio_lock, flags);
269+
raw_spin_lock_irqsave(&chip->gpio_lock, flags);
270270

271271
/* Write state of GPIO signal */
272272
__assign_bit(bit, chip->state, val);
@@ -276,7 +276,7 @@ static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
276276
__clear_bit(bit, chip->dir);
277277
xgpio_write_ch(chip, XGPIO_TRI_OFFSET, bit, chip->dir);
278278

279-
spin_unlock_irqrestore(&chip->gpio_lock, flags);
279+
raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
280280

281281
return 0;
282282
}
@@ -404,7 +404,7 @@ static void xgpio_irq_mask(struct irq_data *irq_data)
404404
int bit = xgpio_to_bit(chip, irq_offset);
405405
u32 mask = BIT(bit / 32), temp;
406406

407-
spin_lock_irqsave(&chip->gpio_lock, flags);
407+
raw_spin_lock_irqsave(&chip->gpio_lock, flags);
408408

409409
__clear_bit(bit, chip->enable);
410410

@@ -414,7 +414,7 @@ static void xgpio_irq_mask(struct irq_data *irq_data)
414414
temp &= ~mask;
415415
xgpio_writereg(chip->regs + XGPIO_IPIER_OFFSET, temp);
416416
}
417-
spin_unlock_irqrestore(&chip->gpio_lock, flags);
417+
raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
418418

419419
gpiochip_disable_irq(&chip->gc, irq_offset);
420420
}
@@ -434,7 +434,7 @@ static void xgpio_irq_unmask(struct irq_data *irq_data)
434434

435435
gpiochip_enable_irq(&chip->gc, irq_offset);
436436

437-
spin_lock_irqsave(&chip->gpio_lock, flags);
437+
raw_spin_lock_irqsave(&chip->gpio_lock, flags);
438438

439439
__set_bit(bit, chip->enable);
440440

@@ -453,7 +453,7 @@ static void xgpio_irq_unmask(struct irq_data *irq_data)
453453
xgpio_writereg(chip->regs + XGPIO_IPIER_OFFSET, val);
454454
}
455455

456-
spin_unlock_irqrestore(&chip->gpio_lock, flags);
456+
raw_spin_unlock_irqrestore(&chip->gpio_lock, flags);
457457
}
458458

459459
/**
@@ -518,7 +518,7 @@ static void xgpio_irqhandler(struct irq_desc *desc)
518518

519519
chained_irq_enter(irqchip, desc);
520520

521-
spin_lock(&chip->gpio_lock);
521+
raw_spin_lock(&chip->gpio_lock);
522522

523523
xgpio_read_ch_all(chip, XGPIO_DATA_OFFSET, all);
524524

@@ -535,7 +535,7 @@ static void xgpio_irqhandler(struct irq_desc *desc)
535535
bitmap_copy(chip->last_irq_read, all, 64);
536536
bitmap_or(all, rising, falling, 64);
537537

538-
spin_unlock(&chip->gpio_lock);
538+
raw_spin_unlock(&chip->gpio_lock);
539539

540540
dev_dbg(gc->parent, "IRQ rising %*pb falling %*pb\n", 64, rising, 64, falling);
541541

@@ -626,7 +626,7 @@ static int xgpio_probe(struct platform_device *pdev)
626626
bitmap_set(chip->hw_map, 0, width[0]);
627627
bitmap_set(chip->hw_map, 32, width[1]);
628628

629-
spin_lock_init(&chip->gpio_lock);
629+
raw_spin_lock_init(&chip->gpio_lock);
630630

631631
chip->gc.base = -1;
632632
chip->gc.ngpio = bitmap_weight(chip->hw_map, 64);

0 commit comments

Comments
 (0)