Skip to contentSkip to conversation

ASoC: Use snd_pcm_stop_xrun() helper

PATCH In review Takashi Iwai 2 participants 9 messages Jul 4, 2018

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

cover ASoC: Use snd_pcm_stop_xrun() helper

Hi,

this is a series of trivial fixes to replace some open codes with the standard snd_pcm_stop_xrun() helper. Functionally same, but it addresses the potential stream lock issues automagically, too.

Takashi

===

Takashi Iwai (4):
ASoC: davinci: Use snd_pcm_stop_xrun() helper
ASoC: qcom: Use snd_pcm_stop_xrun() helper
ASoC: sti: Use snd_pcm_stop_xrun() helper
ASoC: stm32: Use snd_pcm_stop_xrun() helper

 sound/soc/davinci/davinci-mcasp.c | 16 ++++------------
 sound/soc/qcom/lpass-platform.c   |  2 +-
 sound/soc/sti/uniperif_player.c   |  6 +++---
 sound/soc/sti/uniperif_reader.c   |  2 +-
 sound/soc/stm/stm32_sai_sub.c     |  7 ++-----
 5 files changed, 11 insertions(+), 22 deletions(-)
Signature · 1 line
2.18.0
#1 lore raw

PATCH 1/4 ASoC: davinci: Use snd_pcm_stop_xrun() helper

Replace open-codes with the standard snd_pcm_stop_xrun() helper. It simplifies codes a lot.

---
 sound/soc/davinci/davinci-mcasp.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
sound/soc/davinci/davinci-mcasp.c +4 -12
index 47c0c821d325..f70db8412c7c 100644
@@ -320,12 +320,8 @@ static irqreturn_t davinci_mcasp_tx_irq_handler(int irq, void *data)
 		handled_mask |= XUNDRN;
 
 		substream = mcasp->substreams[SNDRV_PCM_STREAM_PLAYBACK];
-		if (substream) {
-			snd_pcm_stream_lock_irq(substream);
-			if (snd_pcm_running(substream))
-				snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
-			snd_pcm_stream_unlock_irq(substream);
-		}
+		if (substream)
+			snd_pcm_stop_xrun(substream);
 	}
 
 	if (!handled_mask)
@@ -355,12 +351,8 @@ static irqreturn_t davinci_mcasp_rx_irq_handler(int irq, void *data)
 		handled_mask |= ROVRN;
 
 		substream = mcasp->substreams[SNDRV_PCM_STREAM_CAPTURE];
-		if (substream) {
-			snd_pcm_stream_lock_irq(substream);
-			if (snd_pcm_running(substream))
-				snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
-			snd_pcm_stream_unlock_irq(substream);
-		}
+		if (substream)
+			snd_pcm_stop_xrun(substream);
 	}
 
 	if (!handled_mask)
Signature · 1 line
2.18.0
maintainer
#2 lore raw

Applied "ASoC: davinci: Use snd_pcm_stop_xrun() helper" to the asoc tree

The patch

ASoC: davinci: Use snd_pcm_stop_xrun() helper

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

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 1 line

From dae35d1f4f7dab9ccef20037df91c43e680bad0f Mon Sep 17 00:00:00 2001

From: Takashi Iwai <[email protected]>
Date: Wed, 4 Jul 2018 16:01:43 +0200
Subject: [PATCH] ASoC: davinci: Use snd_pcm_stop_xrun() helper

Replace open-codes with the standard snd_pcm_stop_xrun() helper. It simplifies codes a lot.

---
 sound/soc/davinci/davinci-mcasp.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
sound/soc/davinci/davinci-mcasp.c +4 -12
index 47c0c821d325..f70db8412c7c 100644
@@ -320,12 +320,8 @@ static irqreturn_t davinci_mcasp_tx_irq_handler(int irq, void *data)
 		handled_mask |= XUNDRN;
 
 		substream = mcasp->substreams[SNDRV_PCM_STREAM_PLAYBACK];
-		if (substream) {
-			snd_pcm_stream_lock_irq(substream);
-			if (snd_pcm_running(substream))
-				snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
-			snd_pcm_stream_unlock_irq(substream);
-		}
+		if (substream)
+			snd_pcm_stop_xrun(substream);
 	}
 
 	if (!handled_mask)
@@ -355,12 +351,8 @@ static irqreturn_t davinci_mcasp_rx_irq_handler(int irq, void *data)
 		handled_mask |= ROVRN;
 
 		substream = mcasp->substreams[SNDRV_PCM_STREAM_CAPTURE];
-		if (substream) {
-			snd_pcm_stream_lock_irq(substream);
-			if (snd_pcm_running(substream))
-				snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
-			snd_pcm_stream_unlock_irq(substream);
-		}
+		if (substream)
+			snd_pcm_stop_xrun(substream);
 	}
 
 	if (!handled_mask)
Signature · 1 line
2.18.0.rc2
#3 lore raw

PATCH 2/4 ASoC: qcom: Use snd_pcm_stop_xrun() helper

In reply to Takashi Iwai

The XRUN trigger from the driver should be done via snd_pcm_stop_xrun(). It fixes the missing stream locking as a gratis, too.

---
 sound/soc/qcom/lpass-platform.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/qcom/lpass-platform.c +1 -1
index 31fe78aa207f..d07271ea4c45 100644
@@ -458,7 +458,7 @@ static irqreturn_t lpass_dma_interrupt_handler(
 			return IRQ_NONE;
 		}
 		dev_warn(soc_runtime->dev, "xrun warning\n");
-		snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
+		snd_pcm_stop_xrun(substream);
 		ret = IRQ_HANDLED;
 	}
 
Signature · 1 line
2.18.0
maintainer
#4 lore raw

Applied "ASoC: qcom: Use snd_pcm_stop_xrun() helper" to the asoc tree

The patch

ASoC: qcom: Use snd_pcm_stop_xrun() helper

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

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 1 line

From 1a42e7e3aff1aa4789378020318dff7432317d25 Mon Sep 17 00:00:00 2001

From: Takashi Iwai <[email protected]>
Date: Wed, 4 Jul 2018 16:01:44 +0200
Subject: [PATCH] ASoC: qcom: Use snd_pcm_stop_xrun() helper

The XRUN trigger from the driver should be done via snd_pcm_stop_xrun(). It fixes the missing stream locking as a gratis, too.

---
 sound/soc/qcom/lpass-platform.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/qcom/lpass-platform.c +1 -1
index 31fe78aa207f..d07271ea4c45 100644
@@ -458,7 +458,7 @@ static irqreturn_t lpass_dma_interrupt_handler(
 			return IRQ_NONE;
 		}
 		dev_warn(soc_runtime->dev, "xrun warning\n");
-		snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
+		snd_pcm_stop_xrun(substream);
 		ret = IRQ_HANDLED;
 	}
 
Signature · 1 line
2.18.0.rc2
#5 lore raw

PATCH 3/4 ASoC: sti: Use snd_pcm_stop_xrun() helper

In reply to Takashi Iwai

The XRUN trigger from the driver should be done via snd_pcm_stop_xrun(). It fixes the missing stream locking as a gratis, too.

---
 sound/soc/sti/uniperif_player.c | 6 +++---
 sound/soc/sti/uniperif_reader.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
sound/soc/sti/uniperif_player.c +3 -3
index d8b6936e544e..313dab2857ef 100644
@@ -91,7 +91,7 @@ static irqreturn_t uni_player_irq_handler(int irq, void *dev_id)
 			SET_UNIPERIF_ITM_BCLR_FIFO_ERROR(player);
 
 			/* Stop the player */
-			snd_pcm_stop(player->substream, SNDRV_PCM_STATE_XRUN);
+			snd_pcm_stop_xrun(player->substream);
 		}
 
 		ret = IRQ_HANDLED;
@@ -105,7 +105,7 @@ static irqreturn_t uni_player_irq_handler(int irq, void *dev_id)
 		SET_UNIPERIF_ITM_BCLR_DMA_ERROR(player);
 
 		/* Stop the player */
-		snd_pcm_stop(player->substream, SNDRV_PCM_STATE_XRUN);
+		snd_pcm_stop_xrun(player->substream);
 
 		ret = IRQ_HANDLED;
 	}
@@ -138,7 +138,7 @@ static irqreturn_t uni_player_irq_handler(int irq, void *dev_id)
 		dev_err(player->dev, "Underflow recovery failed\n");
 
 		/* Stop the player */
-		snd_pcm_stop(player->substream, SNDRV_PCM_STATE_XRUN);
+		snd_pcm_stop_xrun(player->substream);
 
 		ret = IRQ_HANDLED;
 	}
sound/soc/sti/uniperif_reader.c +1 -1
index ee0055e60852..7b63d35ef428 100644
@@ -65,7 +65,7 @@ static irqreturn_t uni_reader_irq_handler(int irq, void *dev_id)
 	if (unlikely(status & UNIPERIF_ITS_FIFO_ERROR_MASK(reader))) {
 		dev_err(reader->dev, "FIFO error detected\n");
 
-		snd_pcm_stop(reader->substream, SNDRV_PCM_STATE_XRUN);
+		snd_pcm_stop_xrun(reader->substream);
 
 		ret = IRQ_HANDLED;
 	}
Signature · 1 line
2.18.0
maintainer
#6 lore raw

Applied "ASoC: sti: Use snd_pcm_stop_xrun() helper" to the asoc tree

The patch

ASoC: sti: Use snd_pcm_stop_xrun() helper

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

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 1 line

From dc865fb9e7c2251c9585ff6a7bf185d499db13e4 Mon Sep 17 00:00:00 2001

From: Takashi Iwai <[email protected]>
Date: Wed, 4 Jul 2018 16:01:45 +0200
Subject: [PATCH] ASoC: sti: Use snd_pcm_stop_xrun() helper

The XRUN trigger from the driver should be done via snd_pcm_stop_xrun(). It fixes the missing stream locking as a gratis, too.

---
 sound/soc/sti/uniperif_player.c | 6 +++---
 sound/soc/sti/uniperif_reader.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
sound/soc/sti/uniperif_player.c +3 -3
index d8b6936e544e..313dab2857ef 100644
@@ -91,7 +91,7 @@ static irqreturn_t uni_player_irq_handler(int irq, void *dev_id)
 			SET_UNIPERIF_ITM_BCLR_FIFO_ERROR(player);
 
 			/* Stop the player */
-			snd_pcm_stop(player->substream, SNDRV_PCM_STATE_XRUN);
+			snd_pcm_stop_xrun(player->substream);
 		}
 
 		ret = IRQ_HANDLED;
@@ -105,7 +105,7 @@ static irqreturn_t uni_player_irq_handler(int irq, void *dev_id)
 		SET_UNIPERIF_ITM_BCLR_DMA_ERROR(player);
 
 		/* Stop the player */
-		snd_pcm_stop(player->substream, SNDRV_PCM_STATE_XRUN);
+		snd_pcm_stop_xrun(player->substream);
 
 		ret = IRQ_HANDLED;
 	}
@@ -138,7 +138,7 @@ static irqreturn_t uni_player_irq_handler(int irq, void *dev_id)
 		dev_err(player->dev, "Underflow recovery failed\n");
 
 		/* Stop the player */
-		snd_pcm_stop(player->substream, SNDRV_PCM_STATE_XRUN);
+		snd_pcm_stop_xrun(player->substream);
 
 		ret = IRQ_HANDLED;
 	}
sound/soc/sti/uniperif_reader.c +1 -1
index ee0055e60852..7b63d35ef428 100644
@@ -65,7 +65,7 @@ static irqreturn_t uni_reader_irq_handler(int irq, void *dev_id)
 	if (unlikely(status & UNIPERIF_ITS_FIFO_ERROR_MASK(reader))) {
 		dev_err(reader->dev, "FIFO error detected\n");
 
-		snd_pcm_stop(reader->substream, SNDRV_PCM_STATE_XRUN);
+		snd_pcm_stop_xrun(reader->substream);
 
 		ret = IRQ_HANDLED;
 	}
Signature · 1 line
2.18.0.rc2
#7 lore raw

PATCH 4/4 ASoC: stm32: Use snd_pcm_stop_xrun() helper

In reply to Takashi Iwai

The XRUN trigger from the driver should be done via snd_pcm_stop_xrun(). It simplifies the locking as well.

---
 sound/soc/stm/stm32_sai_sub.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
sound/soc/stm/stm32_sai_sub.c +2 -5
index cfeb219e1d78..6fea8a684da2 100644
@@ -259,11 +259,8 @@ static irqreturn_t stm32_sai_isr(int irq, void *devid)
 		status = SNDRV_PCM_STATE_XRUN;
 	}
 
-	if (status != SNDRV_PCM_STATE_RUNNING) {
-		snd_pcm_stream_lock(sai->substream);
-		snd_pcm_stop(sai->substream, SNDRV_PCM_STATE_XRUN);
-		snd_pcm_stream_unlock(sai->substream);
-	}
+	if (status != SNDRV_PCM_STATE_RUNNING)
+		snd_pcm_stop_xrun(sai->substream);
 
 	return IRQ_HANDLED;
 }
Signature · 1 line
2.18.0
maintainer
#8 lore raw

Applied "ASoC: stm32: Use snd_pcm_stop_xrun() helper" to the asoc tree

The patch

ASoC: stm32: Use snd_pcm_stop_xrun() helper

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

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 1 line

From b1625fbb3b87affbedf14545b65d69ff182a0611 Mon Sep 17 00:00:00 2001

From: Takashi Iwai <[email protected]>
Date: Wed, 4 Jul 2018 16:01:46 +0200
Subject: [PATCH] ASoC: stm32: Use snd_pcm_stop_xrun() helper

The XRUN trigger from the driver should be done via snd_pcm_stop_xrun(). It simplifies the locking as well.

---
 sound/soc/stm/stm32_sai_sub.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
sound/soc/stm/stm32_sai_sub.c +2 -5
index c4f15ea14197..06fba9650ac4 100644
@@ -300,11 +300,8 @@ static irqreturn_t stm32_sai_isr(int irq, void *devid)
 		status = SNDRV_PCM_STATE_XRUN;
 	}
 
-	if (status != SNDRV_PCM_STATE_RUNNING) {
-		snd_pcm_stream_lock(sai->substream);
-		snd_pcm_stop(sai->substream, SNDRV_PCM_STATE_XRUN);
-		snd_pcm_stream_unlock(sai->substream);
-	}
+	if (status != SNDRV_PCM_STATE_RUNNING)
+		snd_pcm_stop_xrun(sai->substream);
 
 	return IRQ_HANDLED;
 }
Signature · 1 line
2.18.0.rc2