Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: Arseniy Krasnov <avkrasnov@salutedevices.com>
Closes: https://lore.kernel.org/linux-amlogic/20240729131652.3012327-1-avkrasnov@salutedevices.com
Suggested-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Fixes: b11d26660dff ("ASoC: meson: axg-fifo: use threaded irq to check periods")
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Link: https://patch.msgid.link/20240807162705.4024136-1-jbrunet@baylibre.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Jerome Brunet and committed by
Mark Brown
5003d0ce 2f11f61f

+10 -16
+10 -16
sound/soc/meson/axg-fifo.c
··· 207 207 status = FIELD_GET(STATUS1_INT_STS, status); 208 208 axg_fifo_ack_irq(fifo, status); 209 209 210 - /* Use the thread to call period elapsed on nonatomic links */ 211 - if (status & FIFO_INT_COUNT_REPEAT) 212 - return IRQ_WAKE_THREAD; 210 + if (status & ~FIFO_INT_COUNT_REPEAT) 211 + dev_dbg(axg_fifo_dev(ss), "unexpected irq - STS 0x%02x\n", 212 + status); 213 213 214 - dev_dbg(axg_fifo_dev(ss), "unexpected irq - STS 0x%02x\n", 215 - status); 214 + if (status & FIFO_INT_COUNT_REPEAT) { 215 + snd_pcm_period_elapsed(ss); 216 + return IRQ_HANDLED; 217 + } 216 218 217 219 return IRQ_NONE; 218 - } 219 - 220 - static irqreturn_t axg_fifo_pcm_irq_block_thread(int irq, void *dev_id) 221 - { 222 - struct snd_pcm_substream *ss = dev_id; 223 - 224 - snd_pcm_period_elapsed(ss); 225 - 226 - return IRQ_HANDLED; 227 220 } 228 221 229 222 int axg_fifo_pcm_open(struct snd_soc_component *component, ··· 244 251 if (ret) 245 252 return ret; 246 253 247 - ret = request_threaded_irq(fifo->irq, axg_fifo_pcm_irq_block, 248 - axg_fifo_pcm_irq_block_thread, 254 + /* Use the threaded irq handler only with non-atomic links */ 255 + ret = request_threaded_irq(fifo->irq, NULL, 256 + axg_fifo_pcm_irq_block, 249 257 IRQF_ONESHOT, dev_name(dev), ss); 250 258 if (ret) 251 259 return ret;