Skip to content

Commit e2b47aa

Browse files
Niklas Söderlundmehmetb0
authored andcommitted
gpio: rcar: Use raw_spinlock to protect register access
BugLink: https://bugs.launchpad.net/bugs/2106026 commit f02c41f upstream. Use raw_spinlock in order to fix spurious messages about invalid context when spinlock debugging is enabled. The lock is only used to serialize register access. [ 4.239592] ============================= [ 4.239595] [ BUG: Invalid wait context ] [ 4.239599] 6.13.0-rc7-arm64-renesas-05496-gd088502a519f #35 Not tainted [ 4.239603] ----------------------------- [ 4.239606] kworker/u8:5/76 is trying to lock: [ 4.239609] ffff0000091898a0 (&p->lock){....}-{3:3}, at: gpio_rcar_config_interrupt_input_mode+0x34/0x164 [ 4.239641] other info that might help us debug this: [ 4.239643] context-{5:5} [ 4.239646] 5 locks held by kworker/u8:5/76: [ 4.239651] #0: ffff0000080fb148 ((wq_completion)async){+.+.}-{0:0}, at: process_one_work+0x190/0x62c [ 4.250180] OF: /soc/sound@ec500000/ports/port@0/endpoint: Read of boolean property 'frame-master' with a value. [ 4.254094] #1: ffff80008299bd80 ((work_completion)(&entry->work)){+.+.}-{0:0}, at: process_one_work+0x1b8/0x62c [ 4.254109] #2: ffff00000920c8f8 [ 4.258345] OF: /soc/sound@ec500000/ports/port@1/endpoint: Read of boolean property 'bitclock-master' with a value. [ 4.264803] (&dev->mutex){....}-{4:4}, at: __device_attach_async_helper+0x3c/0xdc [ 4.264820] #3: ffff00000a50ca40 (request_class#2){+.+.}-{4:4}, at: __setup_irq+0xa0/0x690 [ 4.264840] #4: [ 4.268872] OF: /soc/sound@ec500000/ports/port@1/endpoint: Read of boolean property 'frame-master' with a value. [ 4.273275] ffff00000a50c8c8 (lock_class){....}-{2:2}, at: __setup_irq+0xc4/0x690 [ 4.296130] renesas_sdhi_internal_dmac ee100000.mmc: mmc1 base at 0x00000000ee100000, max clock rate 200 MHz [ 4.304082] stack backtrace: [ 4.304086] CPU: 1 UID: 0 PID: 76 Comm: kworker/u8:5 Not tainted 6.13.0-rc7-arm64-renesas-05496-gd088502a519f #35 [ 4.304092] Hardware name: Renesas Salvator-X 2nd version board based on r8a77965 (DT) [ 4.304097] Workqueue: async async_run_entry_fn [ 4.304106] Call trace: [ 4.304110] show_stack+0x14/0x20 (C) [ 4.304122] dump_stack_lvl+0x6c/0x90 [ 4.304131] dump_stack+0x14/0x1c [ 4.304138] __lock_acquire+0xdfc/0x1584 [ 4.426274] lock_acquire+0x1c4/0x33c [ 4.429942] _raw_spin_lock_irqsave+0x5c/0x80 [ 4.434307] gpio_rcar_config_interrupt_input_mode+0x34/0x164 [ 4.440061] gpio_rcar_irq_set_type+0xd4/0xd8 [ 4.444422] __irq_set_trigger+0x5c/0x178 [ 4.448435] __setup_irq+0x2e4/0x690 [ 4.452012] request_threaded_irq+0xc4/0x190 [ 4.456285] devm_request_threaded_irq+0x7c/0xf4 [ 4.459398] ata1: link resume succeeded after 1 retries [ 4.460902] mmc_gpiod_request_cd_irq+0x68/0xe0 [ 4.470660] mmc_start_host+0x50/0xac [ 4.474327] mmc_add_host+0x80/0xe4 [ 4.477817] tmio_mmc_host_probe+0x2b0/0x440 [ 4.482094] renesas_sdhi_probe+0x488/0x6f4 [ 4.486281] renesas_sdhi_internal_dmac_probe+0x60/0x78 [ 4.491509] platform_probe+0x64/0xd8 [ 4.495178] really_probe+0xb8/0x2a8 [ 4.498756] __driver_probe_device+0x74/0x118 [ 4.503116] driver_probe_device+0x3c/0x154 [ 4.507303] __device_attach_driver+0xd4/0x160 [ 4.511750] bus_for_each_drv+0x84/0xe0 [ 4.515588] __device_attach_async_helper+0xb0/0xdc [ 4.520470] async_run_entry_fn+0x30/0xd8 [ 4.524481] process_one_work+0x210/0x62c [ 4.528494] worker_thread+0x1ac/0x340 [ 4.532245] kthread+0x10c/0x110 [ 4.535476] ret_from_fork+0x10/0x20 Signed-off-by: Niklas Söderlund <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Tested-by: Geert Uytterhoeven <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Manuel Diewald <[email protected]> Signed-off-by: Mehmet Basaran <[email protected]>
1 parent 1277b6a commit e2b47aa

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

drivers/gpio/gpio-rcar.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ struct gpio_rcar_info {
4141

4242
struct gpio_rcar_priv {
4343
void __iomem *base;
44-
spinlock_t lock;
44+
raw_spinlock_t lock;
4545
struct device *dev;
4646
struct gpio_chip gpio_chip;
4747
struct irq_chip irq_chip;
@@ -121,7 +121,7 @@ static void gpio_rcar_config_interrupt_input_mode(struct gpio_rcar_priv *p,
121121
* "Setting Level-Sensitive Interrupt Input Mode"
122122
*/
123123

124-
spin_lock_irqsave(&p->lock, flags);
124+
raw_spin_lock_irqsave(&p->lock, flags);
125125

126126
/* Configure positive or negative logic in POSNEG */
127127
gpio_rcar_modify_bit(p, POSNEG, hwirq, !active_high_rising_edge);
@@ -140,7 +140,7 @@ static void gpio_rcar_config_interrupt_input_mode(struct gpio_rcar_priv *p,
140140
if (!level_trigger)
141141
gpio_rcar_write(p, INTCLR, BIT(hwirq));
142142

143-
spin_unlock_irqrestore(&p->lock, flags);
143+
raw_spin_unlock_irqrestore(&p->lock, flags);
144144
}
145145

146146
static int gpio_rcar_irq_set_type(struct irq_data *d, unsigned int type)
@@ -233,7 +233,7 @@ static void gpio_rcar_config_general_input_output_mode(struct gpio_chip *chip,
233233
* "Setting General Input Mode"
234234
*/
235235

236-
spin_lock_irqsave(&p->lock, flags);
236+
raw_spin_lock_irqsave(&p->lock, flags);
237237

238238
/* Configure positive logic in POSNEG */
239239
gpio_rcar_modify_bit(p, POSNEG, gpio, false);
@@ -248,7 +248,7 @@ static void gpio_rcar_config_general_input_output_mode(struct gpio_chip *chip,
248248
if (p->info.has_outdtsel && output)
249249
gpio_rcar_modify_bit(p, OUTDTSEL, gpio, false);
250250

251-
spin_unlock_irqrestore(&p->lock, flags);
251+
raw_spin_unlock_irqrestore(&p->lock, flags);
252252
}
253253

254254
static int gpio_rcar_request(struct gpio_chip *chip, unsigned offset)
@@ -334,7 +334,7 @@ static int gpio_rcar_get_multiple(struct gpio_chip *chip, unsigned long *mask,
334334
return 0;
335335
}
336336

337-
spin_lock_irqsave(&p->lock, flags);
337+
raw_spin_lock_irqsave(&p->lock, flags);
338338
outputs = gpio_rcar_read(p, INOUTSEL);
339339
m = outputs & bankmask;
340340
if (m)
@@ -343,7 +343,7 @@ static int gpio_rcar_get_multiple(struct gpio_chip *chip, unsigned long *mask,
343343
m = ~outputs & bankmask;
344344
if (m)
345345
val |= gpio_rcar_read(p, INDT) & m;
346-
spin_unlock_irqrestore(&p->lock, flags);
346+
raw_spin_unlock_irqrestore(&p->lock, flags);
347347

348348
bits[0] = val;
349349
return 0;
@@ -354,9 +354,9 @@ static void gpio_rcar_set(struct gpio_chip *chip, unsigned offset, int value)
354354
struct gpio_rcar_priv *p = gpiochip_get_data(chip);
355355
unsigned long flags;
356356

357-
spin_lock_irqsave(&p->lock, flags);
357+
raw_spin_lock_irqsave(&p->lock, flags);
358358
gpio_rcar_modify_bit(p, OUTDT, offset, value);
359-
spin_unlock_irqrestore(&p->lock, flags);
359+
raw_spin_unlock_irqrestore(&p->lock, flags);
360360
}
361361

362362
static void gpio_rcar_set_multiple(struct gpio_chip *chip, unsigned long *mask,
@@ -373,12 +373,12 @@ static void gpio_rcar_set_multiple(struct gpio_chip *chip, unsigned long *mask,
373373
if (!bankmask)
374374
return;
375375

376-
spin_lock_irqsave(&p->lock, flags);
376+
raw_spin_lock_irqsave(&p->lock, flags);
377377
val = gpio_rcar_read(p, OUTDT);
378378
val &= ~bankmask;
379379
val |= (bankmask & bits[0]);
380380
gpio_rcar_write(p, OUTDT, val);
381-
spin_unlock_irqrestore(&p->lock, flags);
381+
raw_spin_unlock_irqrestore(&p->lock, flags);
382382
}
383383

384384
static int gpio_rcar_direction_output(struct gpio_chip *chip, unsigned offset,
@@ -491,7 +491,7 @@ static int gpio_rcar_probe(struct platform_device *pdev)
491491
return -ENOMEM;
492492

493493
p->dev = dev;
494-
spin_lock_init(&p->lock);
494+
raw_spin_lock_init(&p->lock);
495495

496496
/* Get device configuration from DT node */
497497
ret = gpio_rcar_parse_dt(p, &npins);

0 commit comments

Comments
 (0)