ASoC: meson: axg-fifo: fix irq scheduling issue with PREEMPT_RT
Jerome Brunet
maintainerPATCH 1/1 ASoC: meson: axg-fifo: fix irq scheduling issue with PREEMPT_RT
With PREEMPT_RT enabled, spinlocks become preemptible.
This is usually not a problem with spinlocks used in IRQ context since IRQ handlers get threaded. However, if IRQF_ONESHOT is set, the upper half of a threaded irq handler won't be threaded and this causes scheduling problems if spinlocks are used in the upper half, like with regmap when '.fast_io' is set.
In this particular instance, it is actually better to do everything in the bottom half and it solves the problem with PREEMPT_RT.
--- sound/soc/meson/axg-fifo.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-)
sound/soc/meson/axg-fifo.c +10 -16
@@ -207,25 +207,18 @@ static irqreturn_t axg_fifo_pcm_irq_block(int irq, void *dev_id) status =FIELD_GET (STATUS1_INT_STS , status);axg_fifo_ack_irq (fifo, status); -/* Use the thread to call period elapsed on nonatomic links */ -if (status &FIFO_INT_COUNT_REPEAT ) -return IRQ_WAKE_THREAD ; +if (status & ~FIFO_INT_COUNT_REPEAT ) +dev_dbg (axg_fifo_dev (ss),"unexpected irq - STS 0x%02x\n" , + status); -dev_dbg (axg_fifo_dev (ss),"unexpected irq - STS 0x%02x\n" , - status); +if (status &FIFO_INT_COUNT_REPEAT ) { +snd_pcm_period_elapsed (ss); +return IRQ_HANDLED ; + }return IRQ_NONE ; } -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); - -return IRQ_HANDLED ; -} -int axg_fifo_pcm_open (struct snd_soc_component *component,struct snd_pcm_substream *ss) {
@@ -251,8 +244,9 @@ int axg_fifo_pcm_open(struct snd_soc_component *component,if (ret)return ret; - ret =request_threaded_irq (fifo->irq, axg_fifo_pcm_irq_block, - axg_fifo_pcm_irq_block_thread, +/* Use the bottom half of a threaded irq with non-atomic links */ + ret =request_threaded_irq (fifo->irq,NULL , + axg_fifo_pcm_irq_block,IRQF_ONESHOT ,dev_name (dev), ss);if (ret)return ret;
Signature · 1 line
2.43.0
Quoted 1 line · Jerome Brunet
With
PREEMPT_RTenabled, spinlocks become preemptible.
With PREEMPT_RT enabled a spinlock_t becomes a sleeping lock.
Quoted 5 lines
This is usually not a problem with spinlocks used in IRQ context since IRQ handlers get threaded. However, if
IRQF_ONESHOTis set, the upper half of a threaded irq handler won't be threaded and this causes scheduling problems if spinlocks are used in the upper half, like with regmap when '.fast_io' is set.
… 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.
Quoted 2 lines
In this particular instance, it is actually better to do everything in the bottom half and it solves the problem with
PREEMPT_RT.
threaded handler
The term "bottom half" is usually used with softirq. The IRQ part has a primary handler and a threaded handler.
Quoted 14 lines
Reported-by Arseniy Krasnov <[email protected]>Suggested-by Sebastian Andrzej Siewior <[email protected]>Fixes b11d26660dff ("ASoC: meson: axg-fifo: use threaded irq to check periods")Signed-off-by Jerome Brunet <[email protected]>--- sound/soc/meson/axg-fifo.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-)sound/soc/meson/axg-fifo.c +0
-0
sound/soc/meson/axg-fifo.c int axg_fifo_pcm_open(struct snd_soc_component *component, · line 247
Quoted 6 lines
sound/soc/meson/axg-fifo.c +1
-2@@ -251,8 +244,9 @@ int axg_fifo_pcm_open(struct snd_soc_component *component,if (ret)return ret; - ret = request_threaded_irq(fifo->irq, axg_fifo_pcm_irq_block, - axg_fifo_pcm_irq_block_thread, +/* Use the bottom half of a threaded irq with non-atomic links */
This requests only a threaded handler. There is no "bottom half of a threaded IRQ".
sound/soc/meson/axg-fifo.c int axg_fifo_pcm_open(struct snd_soc_component *component, · line 252
Quoted 5 lines
sound/soc/meson/axg-fifo.c +2
-0+ ret =request_threaded_irq (fifo->irq,NULL , + axg_fifo_pcm_irq_block,IRQF_ONESHOT ,dev_name (dev), ss);if (ret)return ret;
Sebastian
Mark Brown
maintainerQuoted 8 lines · Jerome Brunet
With
PREEMPT_RTenabled, spinlocks become preemptible.
This is usually not a problem with spinlocks used in IRQ context since IRQ handlers get threaded. However, ifIRQF_ONESHOTis set, the upper half of a threaded irq handler won't be threaded and this causes scheduling problems if spinlocks are used in the upper half, like with regmap when '.fast_io' is set.[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/1] ASoC: meson: axg-fifo: fix irq scheduling issue with PREEMPT_RT
commit: 5003d0ce5c7da3a02c0aff771f516f99731e7390
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 10 lines · Mark Brown
Quoted 8 lines · Jerome Brunet
With
PREEMPT_RTenabled, spinlocks become preemptible.
This is usually not a problem with spinlocks used in IRQ context since IRQ handlers get threaded. However, ifIRQF_ONESHOTis set, the upper half of a threaded irq handler won't be threaded and this causes scheduling problems if spinlocks are used in the upper half, like with regmap when '.fast_io' is set.[...]
Quoted 8 lines
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/1] ASoC: meson: axg-fifo: fix irq scheduling issue with
PREEMPT_RTcommit: 5003d0ce5c7da3a02c0aff771f516f99731e7390
Didn't you already apply v2 of this?
Sebastian
Mark Brown
maintainerQuoted 6 lines · Sebastian Andrzej Siewior
Quoted 2 lines · Mark Brown
[1/1] ASoC: meson: axg-fifo: fix irq scheduling issue with
PREEMPT_RTcommit: 5003d0ce5c7da3a02c0aff771f516f99731e7390Didn't you already apply v2 of this?
Perhaps? There's a decent chance my copy of b4 just didn't spot a difference between the two versions and acked both.