Propagate errors out from compressed streams
Subsystems (4)
v7 cover Propagate errors out from compressed streams
If the DSP suffers an unrecoverable error, the driver likely knows about this, however the framework may not get informed because errors returned from pointer requests are ignored within the framework.
Things work out fine if user-space is doing a read as reads return error status back to user-space so the user can find out that things have gone bad. However, if user-space is doing an avail request there is no path for the error to come back up to user-space. The pointer request returns zero available data, so a read never happens and we basically just end up sitting waiting for data on a stream that we know full well has died.
This patch set attempts to address this and ensure that errors are fully propagated to user-space and we don't ever end up wait for data that will never come.
Changes since v6:
- Series rebased on top of my other series fixing the return values from snd_compr_poll
These are based on Takashi's tree, as all the ADSP conflicts are now straightened out, although there is a reasonable chance we will do more ADSP during this cycle.
Thanks,
Charles
Charles Keepax (3):
ALSA: compress: Add function to indicate the stream has gone bad
ASoC: wm_adsp: Use new snd_compr_stop_error to signal stream failure
ASoC: wm_adsp: Treat missing compressed buffer as a fatal error
include/sound/compress_driver.h | 5 +++ sound/core/compress_offload.c | 67 +++++++++++++++++++++++++++++++++++++++-- sound/soc/codecs/wm_adsp.c | 21 ++++++------- 3 files changed, 80 insertions(+), 13 deletions(-)
Signature · 1 line
2.1.4
PATCH v7 1/3 ALSA: compress: Add function to indicate the stream has gone bad
Currently, the avail IOCTL doesn't pass any error status, which means typically on error it simply shows no data available. This can lead to situations where user-space is waiting indefinitely for data that will never come as the DSP has suffered an unrecoverable error.
Add snd_compr_stop_error which end drivers can call to indicate the stream has suffered an unrecoverable error and stop it. The avail and poll IOCTLs are then updated to report if the stream is in an error state to user-space. Allowing the error to propagate out. Processing of the actual snd_compr_stop needs to be deferred to a worker thread as the end driver may detect the errors during an existing operation callback.
--- include/sound/compress_driver.h | 5 +++ sound/core/compress_offload.c | 67 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 70 insertions(+), 2 deletions(-)
include/sound/compress_driver.h +5 -0
@@ -68,6 +68,7 @@ struct snd_compr_runtime {* @ops: pointer to DSP callbacks * @runtime: pointer to runtime structure * @device: device pointer +* @error_work: delayed work used when closing the stream due to an error * @direction: stream direction, playback/recording * @metadata_set: metadata set flag, true when set * @next_track: has userspace signal next track transition, true when set
@@ -78,6 +79,7 @@ struct snd_compr_stream {struct snd_compr_ops *ops;struct snd_compr_runtime *runtime;struct snd_compr *device; +struct delayed_work error_work;enum snd_compr_direction direction;bool metadata_set;bool next_track;
@@ -187,4 +189,7 @@ static inline void snd_compr_drain_notify(struct snd_compr_stream *stream) wake_up(&stream->runtime->sleep); } +int snd_compr_stop_error (struct snd_compr_stream *stream, +snd_pcm_state_t state); +#endif
sound/core/compress_offload.c +65 -2
116 lines not on this page · raw message
Signature · 1 line
2.1.4
Mark Brown
maintainerApplied "ALSA: compress: Add function to indicate the stream has gone bad" to the asoc tree
The patch
ALSA: compress: Add function to indicate the stream has gone bad
has been applied to the asoc tree at
git://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
a4f2d87c63571d4cd9467d369f2fbf2362646043Mon Sep 17 00:00:00 2001
From: Charles Keepax <[email protected]>
Date: Mon, 13 Jun 2016 14:17:10 +0100
Subject: [PATCH] ALSA: compress: Add function to indicate the stream has gone
bad
Currently, the avail IOCTL doesn't pass any error status, which means typically on error it simply shows no data available. This can lead to situations where user-space is waiting indefinitely for data that will never come as the DSP has suffered an unrecoverable error.
Add snd_compr_stop_error which end drivers can call to indicate the stream has suffered an unrecoverable error and stop it. The avail and poll IOCTLs are then updated to report if the stream is in an error state to user-space. Allowing the error to propagate out. Processing of the actual snd_compr_stop needs to be deferred to a worker thread as the end driver may detect the errors during an existing operation callback.
--- include/sound/compress_driver.h | 5 +++ sound/core/compress_offload.c | 67 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 70 insertions(+), 2 deletions(-)
include/sound/compress_driver.h +5 -0
@@ -68,6 +68,7 @@ struct snd_compr_runtime {* @ops: pointer to DSP callbacks * @runtime: pointer to runtime structure * @device: device pointer +* @error_work: delayed work used when closing the stream due to an error * @direction: stream direction, playback/recording * @metadata_set: metadata set flag, true when set * @next_track: has userspace signal next track transition, true when set
@@ -78,6 +79,7 @@ struct snd_compr_stream {struct snd_compr_ops *ops;struct snd_compr_runtime *runtime;struct snd_compr *device; +struct delayed_work error_work;enum snd_compr_direction direction;bool metadata_set;bool next_track;
@@ -187,4 +189,7 @@ static inline void snd_compr_drain_notify(struct snd_compr_stream *stream) wake_up(&stream->runtime->sleep); } +int snd_compr_stop_error (struct snd_compr_stream *stream, +snd_pcm_state_t state); +#endif
sound/core/compress_offload.c +65 -2
116 lines not on this page · raw message
Signature · 1 line
2.8.1
PATCH v7 2/3 ASoC: wm_adsp: Use new snd_compr_stop_error to signal stream failure
In reply to Charles KeepaxIf we encounter a fatal error on the compressed stream call the new snd_compr_stop_error to shutdown the stream and allow the core to inform user-space that the stream is no longer valid.
--- sound/soc/codecs/wm_adsp.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
sound/soc/codecs/wm_adsp.c +9 -2
@@ -3043,6 +3043,7 @@ int wm_adsp_compr_pointer(struct snd_compr_stream *stream, }if (compr->buf->error) { +snd_compr_stop_error (stream,SNDRV_PCM_STATE_XRUN ); ret = -EIO ; goto out; }
@@ -3060,8 +3061,12 @@ int wm_adsp_compr_pointer(struct snd_compr_stream *stream,*/ if (buf->avail <wm_adsp_compr_frag_words (compr)) { ret =wm_adsp_buffer_get_error (buf); -if (ret <0 ) +if (ret <0 ) { +if (compr->buf->error) +snd_compr_stop_error (stream, +SNDRV_PCM_STATE_XRUN ); goto out; + } ret =wm_adsp_buffer_reenable_irq (buf);if (ret <0 ) {
@@ -3159,8 +3164,10 @@ static int wm_adsp_compr_read(struct wm_adsp_compr *compr,if (!compr->buf)return -ENXIO ; -if (compr->buf->error) +if (compr->buf->error) { +snd_compr_stop_error (compr->stream,SNDRV_PCM_STATE_XRUN );return -EIO ; + } count /=WM_ADSP_DATA_WORD_SIZE ;
Signature · 1 line
2.1.4
PATCH v7 3/3 ASoC: wm_adsp: Treat missing compressed buffer as a fatal error
In reply to Charles KeepaxIf the DSP is powered down whilst a compressed stream is being processed we should treat this as a fatal error, clearly the stream is no longer valid.
--- sound/soc/codecs/wm_adsp.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)
sound/soc/codecs/wm_adsp.c +2 -10
@@ -3037,12 +3037,7 @@ int wm_adsp_compr_pointer(struct snd_compr_stream *stream, buf = compr->buf; -if (!compr->buf) { - ret = -ENXIO ; - goto out; - } - -if (compr->buf->error) { +if (!compr->buf || compr->buf->error) {snd_compr_stop_error (stream,SNDRV_PCM_STATE_XRUN ); ret = -EIO ; goto out;
@@ -3161,10 +3156,7 @@ static int wm_adsp_compr_read(struct wm_adsp_compr *compr,adsp_dbg (dsp,"Requested read of %zu bytes\n" , count); -if (!compr->buf) -return -ENXIO ; - -if (compr->buf->error) { +if (!compr->buf || compr->buf->error) {snd_compr_stop_error (compr->stream,SNDRV_PCM_STATE_XRUN );return -EIO ; }
Signature · 1 line
2.1.4
Mark Brown
maintainerApplied "ASoC: wm_adsp: Treat missing compressed buffer as a fatal error" to the asoc tree
The patch
ASoC: wm_adsp: Treat missing compressed buffer as a fatal error
has been applied to the asoc tree at
git://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
28ee3d73773e2d9ae922f7496723ab5c92cc16deMon Sep 17 00:00:00 2001
From: Charles Keepax <[email protected]>
Date: Mon, 13 Jun 2016 14:17:12 +0100
Subject: [PATCH] ASoC: wm_adsp: Treat missing compressed buffer as a fatal
error
If the DSP is powered down whilst a compressed stream is being processed we should treat this as a fatal error, clearly the stream is no longer valid.
--- sound/soc/codecs/wm_adsp.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)
sound/soc/codecs/wm_adsp.c +2 -10
@@ -3037,12 +3037,7 @@ int wm_adsp_compr_pointer(struct snd_compr_stream *stream, buf = compr->buf; -if (!compr->buf) { - ret = -ENXIO ; - goto out; - } - -if (compr->buf->error) { +if (!compr->buf || compr->buf->error) {snd_compr_stop_error (stream,SNDRV_PCM_STATE_XRUN ); ret = -EIO ; goto out;
@@ -3161,10 +3156,7 @@ static int wm_adsp_compr_read(struct wm_adsp_compr *compr,adsp_dbg (dsp,"Requested read of %zu bytes\n" , count); -if (!compr->buf) -return -ENXIO ; - -if (compr->buf->error) { +if (!compr->buf || compr->buf->error) {snd_compr_stop_error (compr->stream,SNDRV_PCM_STATE_XRUN );return -EIO ; }
Signature · 1 line
2.8.1