fd47690
From 2eed19b99c8e95ff87afe6c140ed895c3fac5937 Mon Sep 17 00:00:00 2001
fd47690
From: Takashi Iwai <tiwai@suse.de>
fd47690
Date: Sat, 14 Sep 2019 17:24:05 +0200
fd47690
Subject: staging: bcm2835-audio: Fix draining behavior regression
fd47690
fd47690
The PCM draining behavior got broken since the recent refactoring, and
fd47690
this turned out to be the incorrect expectation of the firmware
fd47690
behavior regarding "draining".  While I expected the "drain" flag at
fd47690
the stop operation would do processing the queued samples, it seems
fd47690
rather dropping the samples.
fd47690
fd47690
As a quick fix, just drop the SNDRV_PCM_INFO_DRAIN_TRIGGER flag, so
fd47690
that the driver uses the normal PCM draining procedure.  Also, put
fd47690
some caution comment to the function for future readers not to fall
fd47690
into the same pitfall.
fd47690
fd47690
Fixes: d7ca3a71545b ("staging: bcm2835-audio: Operate non-atomic PCM ops")
fd47690
BugLink: https://github.com/raspberrypi/linux/issues/2983
fd47690
Cc: stable@vger.kernel.org
fd47690
Signed-off-by: Takashi Iwai <tiwai@suse.de>
fd47690
Acked-by: Stefan Wahren <wahrenst@gmx.net>
fd47690
Link: https://lore.kernel.org/r/20190914152405.7416-1-tiwai@suse.de
fd47690
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fd47690
---
fd47690
 drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c   | 4 ++--
fd47690
 drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c | 1 +
fd47690
 2 files changed, 3 insertions(+), 2 deletions(-)
fd47690
fd47690
diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
fd47690
index bc1eaa3a0773..826016c3431a 100644
fd47690
--- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
fd47690
+++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
fd47690
@@ -12,7 +12,7 @@
fd47690
 static const struct snd_pcm_hardware snd_bcm2835_playback_hw = {
fd47690
 	.info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
fd47690
 		 SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
fd47690
-		 SNDRV_PCM_INFO_DRAIN_TRIGGER | SNDRV_PCM_INFO_SYNC_APPLPTR),
fd47690
+		 SNDRV_PCM_INFO_SYNC_APPLPTR),
fd47690
 	.formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE,
fd47690
 	.rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000,
fd47690
 	.rate_min = 8000,
fd47690
@@ -29,7 +29,7 @@ static const struct snd_pcm_hardware snd_bcm2835_playback_hw = {
fd47690
 static const struct snd_pcm_hardware snd_bcm2835_playback_spdif_hw = {
fd47690
 	.info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
fd47690
 		 SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
fd47690
-		 SNDRV_PCM_INFO_DRAIN_TRIGGER | SNDRV_PCM_INFO_SYNC_APPLPTR),
fd47690
+		 SNDRV_PCM_INFO_SYNC_APPLPTR),
fd47690
 	.formats = SNDRV_PCM_FMTBIT_S16_LE,
fd47690
 	.rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_44100 |
fd47690
 	SNDRV_PCM_RATE_48000,
fd47690
diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
fd47690
index 23fba01107b9..c6f9cf1913d2 100644
fd47690
--- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
fd47690
+++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
fd47690
@@ -289,6 +289,7 @@ int bcm2835_audio_stop(struct bcm2835_alsa_stream *alsa_stream)
fd47690
 					 VC_AUDIO_MSG_TYPE_STOP, false);
fd47690
 }
fd47690
 
fd47690
+/* FIXME: this doesn't seem working as expected for "draining" */
fd47690
 int bcm2835_audio_drain(struct bcm2835_alsa_stream *alsa_stream)
fd47690
 {
fd47690
 	struct vc_audio_msg m = {
fd47690
-- 
fd47690
cgit 1.2-0.3.lf.el7