Commit 5003d0ce authored by Jerome Brunet's avatar Jerome Brunet Committed by Mark Brown

ASoC: meson: axg-fifo: fix irq scheduling issue with PREEMPT_RT

With PREEMPT_RT enabled a spinlock_t becomes a sleeping lock.

This is usually not a problem with spinlocks used in IRQ context since
IRQ handlers get threaded. However, if IRQF_ONESHOT is set, the primary
handler won't be force-threaded and runs always in hardirq context. This is
a problem because spinlock_t requires a preemptible context on PREEMPT_RT.

In this particular instance, regmap mmio uses spinlock_t to protect the
register access and IRQF_ONESHOT is set on the IRQ. In this case, it is
actually better to do everything in threaded handler and it solves the
problem with PREEMPT_RT.
Reported-by: default avatarArseniy Krasnov <avkrasnov@salutedevices.com>
Closes: https://lore.kernel.org/linux-amlogic/20240729131652.3012327-1-avkrasnov@salutedevices.comSuggested-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Fixes: b11d2666 ("ASoC: meson: axg-fifo: use threaded irq to check periods")
Signed-off-by: default avatarJerome Brunet <jbrunet@baylibre.com>
Reviewed-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Link: https://patch.msgid.link/20240807162705.4024136-1-jbrunet@baylibre.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 2f11f61f
...@@ -207,23 +207,16 @@ static irqreturn_t axg_fifo_pcm_irq_block(int irq, void *dev_id) ...@@ -207,23 +207,16 @@ static irqreturn_t axg_fifo_pcm_irq_block(int irq, void *dev_id)
status = FIELD_GET(STATUS1_INT_STS, status); status = FIELD_GET(STATUS1_INT_STS, status);
axg_fifo_ack_irq(fifo, status); axg_fifo_ack_irq(fifo, status);
/* Use the thread to call period elapsed on nonatomic links */ if (status & ~FIFO_INT_COUNT_REPEAT)
if (status & FIFO_INT_COUNT_REPEAT)
return IRQ_WAKE_THREAD;
dev_dbg(axg_fifo_dev(ss), "unexpected irq - STS 0x%02x\n", dev_dbg(axg_fifo_dev(ss), "unexpected irq - STS 0x%02x\n",
status); status);
return IRQ_NONE; if (status & FIFO_INT_COUNT_REPEAT) {
}
static irqreturn_t axg_fifo_pcm_irq_block_thread(int irq, void *dev_id)
{
struct snd_pcm_substream *ss = dev_id;
snd_pcm_period_elapsed(ss); snd_pcm_period_elapsed(ss);
return IRQ_HANDLED; return IRQ_HANDLED;
}
return IRQ_NONE;
} }
int axg_fifo_pcm_open(struct snd_soc_component *component, int axg_fifo_pcm_open(struct snd_soc_component *component,
...@@ -251,8 +244,9 @@ int axg_fifo_pcm_open(struct snd_soc_component *component, ...@@ -251,8 +244,9 @@ int axg_fifo_pcm_open(struct snd_soc_component *component,
if (ret) if (ret)
return ret; return ret;
ret = request_threaded_irq(fifo->irq, axg_fifo_pcm_irq_block, /* Use the threaded irq handler only with non-atomic links */
axg_fifo_pcm_irq_block_thread, ret = request_threaded_irq(fifo->irq, NULL,
axg_fifo_pcm_irq_block,
IRQF_ONESHOT, dev_name(dev), ss); IRQF_ONESHOT, dev_name(dev), ss);
if (ret) if (ret)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment