All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: wm_adsp: Avoid calling snd_compr_stop_error from WDT expiry
@ 2019-04-04 12:56 Charles Keepax
  2019-04-04 13:39 ` Mark Brown
  2019-04-04 13:58 ` Applied "ASoC: wm_adsp: Avoid calling snd_compr_stop_error from WDT expiry" to the asoc tree Mark Brown
  0 siblings, 2 replies; 4+ messages in thread
From: Charles Keepax @ 2019-04-04 12:56 UTC (permalink / raw)
  To: broonie, lgirdwood; +Cc: patches, alsa-devel

It is unsafe to call snd_compr_stop_error from outside of the
compressed ops. Firstly the compressed device lock needs to be held
and secondly it queues error work to issue a trigger stop which
should not happen after the stream has been freed. To avoid these
issues use the same trick used for the IRQ handling, simply send a
snd_compr_fragment_elapsed to cause user-space to wake on the poll,
then report the error when user-space issues the pointer request
after it wakes.

Fixes: 56bc22bd1dac ("ASoC: wm_adsp: Shutdown any compressed streams on DSP watchdog timeout")
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/wm_adsp.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index c8c49d5b8ac95..a9298bfddd9c7 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -4092,7 +4092,7 @@ int wm_adsp_compr_pointer(struct snd_compr_stream *stream,
 
 	buf = compr->buf;
 
-	if (!buf || buf->error) {
+	if (dsp->fatal_error || !buf || buf->error) {
 		snd_compr_stop_error(stream, SNDRV_PCM_STATE_XRUN);
 		ret = -EIO;
 		goto out;
@@ -4196,12 +4196,13 @@ static int wm_adsp_buffer_capture_block(struct wm_adsp_compr *compr, int target)
 static int wm_adsp_compr_read(struct wm_adsp_compr *compr,
 			      char __user *buf, size_t count)
 {
+	struct wm_adsp *dsp = compr->dsp;
 	int ntotal = 0;
 	int nwords, nbytes;
 
 	compr_dbg(compr, "Requested read of %zu bytes\n", count);
 
-	if (!compr->buf || compr->buf->error) {
+	if (dsp->fatal_error || !compr->buf || compr->buf->error) {
 		snd_compr_stop_error(compr->stream, SNDRV_PCM_STATE_XRUN);
 		return -EIO;
 	}
@@ -4262,11 +4263,8 @@ static void wm_adsp_fatal_error(struct wm_adsp *dsp)
 	dsp->fatal_error = true;
 
 	list_for_each_entry(compr, &dsp->compr_list, list) {
-		if (compr->stream) {
-			snd_compr_stop_error(compr->stream,
-					     SNDRV_PCM_STATE_XRUN);
+		if (compr->stream)
 			snd_compr_fragment_elapsed(compr->stream);
-		}
 	}
 }
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ASoC: wm_adsp: Avoid calling snd_compr_stop_error from WDT expiry
  2019-04-04 12:56 [PATCH] ASoC: wm_adsp: Avoid calling snd_compr_stop_error from WDT expiry Charles Keepax
@ 2019-04-04 13:39 ` Mark Brown
  2019-04-04 14:38   ` Charles Keepax
  2019-04-04 13:58 ` Applied "ASoC: wm_adsp: Avoid calling snd_compr_stop_error from WDT expiry" to the asoc tree Mark Brown
  1 sibling, 1 reply; 4+ messages in thread
From: Mark Brown @ 2019-04-04 13:39 UTC (permalink / raw)
  To: Charles Keepax; +Cc: patches, alsa-devel, lgirdwood


[-- Attachment #1.1: Type: text/plain, Size: 201 bytes --]

On Thu, Apr 04, 2019 at 01:56:01PM +0100, Charles Keepax wrote:

> Fixes: 56bc22bd1dac ("ASoC: wm_adsp: Shutdown any compressed streams on DSP watchdog timeout")

This commit doesn't exist upstream...

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Applied "ASoC: wm_adsp: Avoid calling snd_compr_stop_error from WDT expiry" to the asoc tree
  2019-04-04 12:56 [PATCH] ASoC: wm_adsp: Avoid calling snd_compr_stop_error from WDT expiry Charles Keepax
  2019-04-04 13:39 ` Mark Brown
@ 2019-04-04 13:58 ` Mark Brown
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Brown @ 2019-04-04 13:58 UTC (permalink / raw)
  To: Charles Keepax; +Cc: patches, alsa-devel, broonie, stable, lgirdwood

The patch

   ASoC: wm_adsp: Avoid calling snd_compr_stop_error from WDT expiry

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

>From aa612f2b006aa3552871dabcd6a8e90e33f65e09 Mon Sep 17 00:00:00 2001
From: Charles Keepax <ckeepax@opensource.cirrus.com>
Date: Thu, 4 Apr 2019 13:56:01 +0100
Subject: [PATCH] ASoC: wm_adsp: Avoid calling snd_compr_stop_error from WDT
 expiry

It is unsafe to call snd_compr_stop_error from outside of the
compressed ops. Firstly the compressed device lock needs to be held
and secondly it queues error work to issue a trigger stop which
should not happen after the stream has been freed. To avoid these
issues use the same trick used for the IRQ handling, simply send a
snd_compr_fragment_elapsed to cause user-space to wake on the poll,
then report the error when user-space issues the pointer request
after it wakes.

Fixes: a2bcbc1b9ac2f ("ASoC: wm_adsp: Shutdown any compressed streams on DSP watchdog timeout")
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@kernel.org
---
 sound/soc/codecs/wm_adsp.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index c8c49d5b8ac9..a9298bfddd9c 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -4092,7 +4092,7 @@ int wm_adsp_compr_pointer(struct snd_compr_stream *stream,
 
 	buf = compr->buf;
 
-	if (!buf || buf->error) {
+	if (dsp->fatal_error || !buf || buf->error) {
 		snd_compr_stop_error(stream, SNDRV_PCM_STATE_XRUN);
 		ret = -EIO;
 		goto out;
@@ -4196,12 +4196,13 @@ static int wm_adsp_buffer_capture_block(struct wm_adsp_compr *compr, int target)
 static int wm_adsp_compr_read(struct wm_adsp_compr *compr,
 			      char __user *buf, size_t count)
 {
+	struct wm_adsp *dsp = compr->dsp;
 	int ntotal = 0;
 	int nwords, nbytes;
 
 	compr_dbg(compr, "Requested read of %zu bytes\n", count);
 
-	if (!compr->buf || compr->buf->error) {
+	if (dsp->fatal_error || !compr->buf || compr->buf->error) {
 		snd_compr_stop_error(compr->stream, SNDRV_PCM_STATE_XRUN);
 		return -EIO;
 	}
@@ -4262,11 +4263,8 @@ static void wm_adsp_fatal_error(struct wm_adsp *dsp)
 	dsp->fatal_error = true;
 
 	list_for_each_entry(compr, &dsp->compr_list, list) {
-		if (compr->stream) {
-			snd_compr_stop_error(compr->stream,
-					     SNDRV_PCM_STATE_XRUN);
+		if (compr->stream)
 			snd_compr_fragment_elapsed(compr->stream);
-		}
 	}
 }
 
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ASoC: wm_adsp: Avoid calling snd_compr_stop_error from WDT expiry
  2019-04-04 13:39 ` Mark Brown
@ 2019-04-04 14:38   ` Charles Keepax
  0 siblings, 0 replies; 4+ messages in thread
From: Charles Keepax @ 2019-04-04 14:38 UTC (permalink / raw)
  To: Mark Brown; +Cc: patches, alsa-devel, lgirdwood

On Thu, Apr 04, 2019 at 08:39:20PM +0700, Mark Brown wrote:
> On Thu, Apr 04, 2019 at 01:56:01PM +0100, Charles Keepax wrote:
> 
> > Fixes: 56bc22bd1dac ("ASoC: wm_adsp: Shutdown any compressed streams on DSP watchdog timeout")
> 
> This commit doesn't exist upstream...

Argh... sorry about that thanks for fixing it up. Took the hash
from the wrong branch.

Thanks,
Charles

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-04-04 14:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-04 12:56 [PATCH] ASoC: wm_adsp: Avoid calling snd_compr_stop_error from WDT expiry Charles Keepax
2019-04-04 13:39 ` Mark Brown
2019-04-04 14:38   ` Charles Keepax
2019-04-04 13:58 ` Applied "ASoC: wm_adsp: Avoid calling snd_compr_stop_error from WDT expiry" to the asoc tree Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.