Re: [PATCH v1] ASoC: meson: axg-fifo: set option to use raw spinlock

From: Jerome Brunet
Date: Mon Jul 29 2024 - 10:15:46 EST


On Mon 29 Jul 2024 at 16:16, Arseniy Krasnov <avkrasnov@xxxxxxxxxxxxxxxxx> wrote:

> Raw spinlock is needed here, because with enabled PREEMPT_RT,
> spinlock_t become preemptible, but this regmap lock could be
> acquired in IRQ handler. Found by lockdep:

Assuming I understand the problem correctly, any driver with an IRQ and
using mmio regmaps would be subject to this problem, isn't it ?

That does not seems particularily specific to this driver, so changing
just this one like that does not make a lot of sense to me.

Maybe mmio regmap should '.use_raw_spinlock = true' by default when
'.fast_io' is set ?

Mark, what is your opinion on this ? I guess it is not the first time
this occurs ?

>
> [ ] =============================
> [ ] [ BUG: Invalid wait context ]
> [ ] 6.9.9-sdkernel #1 Tainted: G O
> [ ] -----------------------------
> [ ] aplay/413 is trying to lock:
> [ ] ffff000003930018 (axg_fifo:356:(&axg_fifo_regmap_cfg)->lock){....}-{3:3},c
> [ ] other info that might help us debug this:
> [ ] context-{2:2}
> [ ] no locks held by aplay/413.
> [ ] stack backtrace:
> [ ] CPU: 0 PID: 413 Comm: aplay Tainted: G O 6.9.9-kernel #1
> [ ] Hardware name: SberDevices SberBoom Mini (DT)
> [ ] Call trace:
> [ ] dump_backtrace+0x98/0xf0
> [ ] show_stack+0x18/0x24
> [ ] dump_stack_lvl+0x90/0xd0
> [ ] dump_stack+0x18/0x24
> [ ] __lock_acquire+0x9dc/0x1f10
> [ ] lock_acquire.part.0+0xe8/0x228
> [ ] lock_acquire+0x68/0x84
> [ ] _raw_spin_lock_irqsave+0x60/0x88
> [ ] regmap_lock_spinlock+0x18/0x2c
> [ ] regmap_read+0x3c/0x78
> [ ] axg_fifo_pcm_irq_block+0x4c/0xc8
> [ ] __handle_irq_event_percpu+0xa4/0x2f8
> [ ] handle_irq_event+0x4c/0xbc
> [ ] handle_fasteoi_irq+0xa4/0x23c
> [ ] generic_handle_domain_irq+0x2c/0x44
> [ ] gic_handle_irq+0x40/0xc4
> [ ] call_on_irq_stack+0x24/0x4c
> [ ] do_interrupt_handler+0x80/0x84
> [ ] el0_interrupt+0x5c/0x124
> [ ] __el0_irq_handler_common+0x18/0x24
> [ ] el0t_32_irq_handler+0x10/0x1c
> [ ] el0t_32_irq+0x194/0x198
>
> Signed-off-by: Arseniy Krasnov <avkrasnov@xxxxxxxxxxxxxxxxx>
> ---
> sound/soc/meson/axg-fifo.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/sound/soc/meson/axg-fifo.c b/sound/soc/meson/axg-fifo.c
> index ecb3eb7a9723d..a22298f74b35a 100644
> --- a/sound/soc/meson/axg-fifo.c
> +++ b/sound/soc/meson/axg-fifo.c
> @@ -328,6 +328,7 @@ static const struct regmap_config axg_fifo_regmap_cfg = {
> .val_bits = 32,
> .reg_stride = 4,
> .max_register = FIFO_CTRL2,
> + .use_raw_spinlock = true,
> };
>
> int axg_fifo_probe(struct platform_device *pdev)

--
Jerome