All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: alsa-devel@alsa-project.org
Cc: tiwai@suse.de, broonie@kernel.org,
	Rander Wang <rander.wang@linux.intel.com>,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Subject: [PATCH 18/21] ASoC: SOF: Intel: hda: fix link DMA config
Date: Mon, 22 Jul 2019 09:13:59 -0500	[thread overview]
Message-ID: <20190722141402.7194-19-pierre-louis.bossart@linux.intel.com> (raw)
In-Reply-To: <20190722141402.7194-1-pierre-louis.bossart@linux.intel.com>

From: Rander Wang <rander.wang@linux.intel.com>

For this bug, there are two capture pcm streams active, with one
stream and its related stream tag released before suspend. Later
when system suspend is done, the stream tag for the remaining
active stream is released by SOF driver. After system resume, hda
codec driver restores the stream tag for the active pcm stream,
but SOF goes to assign a new one, which now doesn't match with the
stream tag used by codec driver, and this causes DMA to fail
receiving data, leading to unrecoverable XRUN condition in FW.

For stream tag is stored in both hda codec and SOF driver, it
shouldn't be released only in SOF driver. This patch just keeps the
stream information in dma data and checks whether there is a stored
DMA data for stream resuming from S3 and restores it. And it also
removes DMA data when the stream is released.

Tested on Whiskey Lake platform.

GitHub issue: https://github.com/thesofproject/sof/issues/1594
Signed-off-by: Rander Wang <rander.wang@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/sof/intel/hda-dai.c | 15 +++++++++------
 sound/soc/sof/intel/hda-dsp.c | 10 ++++------
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/sound/soc/sof/intel/hda-dai.c b/sound/soc/sof/intel/hda-dai.c
index a448be60f6dd..2b5e2b8c69c2 100644
--- a/sound/soc/sof/intel/hda-dai.c
+++ b/sound/soc/sof/intel/hda-dai.c
@@ -210,9 +210,13 @@ static int hda_link_hw_params(struct snd_pcm_substream *substream,
 	int stream_tag;
 	int ret;
 
-	link_dev = hda_link_stream_assign(bus, substream);
-	if (!link_dev)
-		return -EBUSY;
+	/* get stored dma data if resuming from system suspend */
+	link_dev = snd_soc_dai_get_dma_data(dai, substream);
+	if (!link_dev) {
+		link_dev = hda_link_stream_assign(bus, substream);
+		if (!link_dev)
+			return -EBUSY;
+	}
 
 	stream_tag = hdac_stream(link_dev)->stream_tag;
 
@@ -316,7 +320,7 @@ static int hda_link_pcm_trigger(struct snd_pcm_substream *substream,
 	case SNDRV_PCM_TRIGGER_SUSPEND:
 	case SNDRV_PCM_TRIGGER_STOP:
 		/*
-		 * clear and release link DMA channel. It will be assigned when
+		 * clear link DMA channel. It will be assigned when
 		 * hw_params is set up again after resume.
 		 */
 		ret = hda_link_config_ipc(hda_stream, dai->name,
@@ -325,8 +329,6 @@ static int hda_link_pcm_trigger(struct snd_pcm_substream *substream,
 			return ret;
 		stream_tag = hdac_stream(link_dev)->stream_tag;
 		snd_hdac_ext_link_clear_stream_id(link, stream_tag);
-		snd_hdac_ext_stream_release(link_dev,
-					    HDAC_EXT_STREAM_TYPE_LINK);
 		link_dev->link_prepared = 0;
 
 		/* fallthrough */
@@ -369,6 +371,7 @@ static int hda_link_hw_free(struct snd_pcm_substream *substream,
 
 	stream_tag = hdac_stream(link_dev)->stream_tag;
 	snd_hdac_ext_link_clear_stream_id(link, stream_tag);
+	snd_soc_dai_set_dma_data(dai, substream, NULL);
 	snd_hdac_ext_stream_release(link_dev, HDAC_EXT_STREAM_TYPE_LINK);
 	link_dev->link_prepared = 0;
 
diff --git a/sound/soc/sof/intel/hda-dsp.c b/sound/soc/sof/intel/hda-dsp.c
index e82ecaad1763..e38008194574 100644
--- a/sound/soc/sof/intel/hda-dsp.c
+++ b/sound/soc/sof/intel/hda-dsp.c
@@ -439,10 +439,10 @@ int hda_dsp_set_hw_params_upon_resume(struct snd_sof_dev *sdev)
 		stream = stream_to_hdac_ext_stream(s);
 
 		/*
-		 * clear and release stream. This should already be taken care
-		 * for running streams when the SUSPEND trigger is called.
-		 * But paused streams do not get suspended, so this needs to be
-		 * done explicitly during suspend.
+		 * clear stream. This should already be taken care for running
+		 * streams when the SUSPEND trigger is called. But paused
+		 * streams do not get suspended, so this needs to be done
+		 * explicitly during suspend.
 		 */
 		if (stream->link_substream) {
 			rtd = snd_pcm_substream_chip(stream->link_substream);
@@ -452,8 +452,6 @@ int hda_dsp_set_hw_params_upon_resume(struct snd_sof_dev *sdev)
 				return -EINVAL;
 			stream_tag = hdac_stream(stream)->stream_tag;
 			snd_hdac_ext_link_clear_stream_id(link, stream_tag);
-			snd_hdac_ext_stream_release(stream,
-						    HDAC_EXT_STREAM_TYPE_LINK);
 			stream->link_prepared = 0;
 		}
 	}
-- 
2.20.1

  parent reply	other threads:[~2019-07-22 14:14 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-22 14:13 [PATCH 00/21] ASoC: SOF: updates for 5.4 Pierre-Louis Bossart
2019-07-22 14:13 ` [PATCH 01/21] ASoC: SOF: pci: mark last_busy value at runtime PM init Pierre-Louis Bossart
2019-07-23 11:29   ` Applied "ASoC: SOF: pci: mark last_busy value at runtime PM init" to the asoc tree Mark Brown
2019-07-22 14:13 ` [PATCH 02/21] ASoC: SOF: reset DMA state in prepare Pierre-Louis Bossart
2019-07-23 11:29   ` Applied "ASoC: SOF: reset DMA state in prepare" to the asoc tree Mark Brown
2019-07-22 14:13 ` [PATCH 03/21] ASoC: SOF: use common code to send PCM_FREE IPC Pierre-Louis Bossart
2019-07-23 11:29   ` Applied "ASoC: SOF: use common code to send PCM_FREE IPC" to the asoc tree Mark Brown
2019-07-22 14:13 ` [PATCH 04/21] ASoC: SOF: ipc: use timeout configured at probe Pierre-Louis Bossart
2019-07-23 11:29   ` Applied "ASoC: SOF: ipc: use timeout configured at probe" to the asoc tree Mark Brown
2019-07-22 14:13 ` [PATCH 05/21] ASoC: SOF: core: increase default IPC timeouts Pierre-Louis Bossart
2019-07-23 11:29   ` Applied "ASoC: SOF: core: increase default IPC timeouts" to the asoc tree Mark Brown
2019-07-22 14:13 ` [PATCH 06/21] ASoC: SOF: Introduce snd_sof_dsp_get_bar_index ops Pierre-Louis Bossart
2019-07-23 11:29   ` Applied "ASoC: SOF: Introduce snd_sof_dsp_get_bar_index ops" to the asoc tree Mark Brown
2019-07-22 14:13 ` [PATCH 07/21] ASoC: SOF: loader: Use the BAR provided by FW Pierre-Louis Bossart
2019-07-23 11:29   ` Applied "ASoC: SOF: loader: Use the BAR provided by FW" to the asoc tree Mark Brown
2019-07-22 14:13 ` [PATCH 08/21] ASoC: SOF: loader: Don't ignore SRAM block types Pierre-Louis Bossart
2019-07-23 11:29   ` Applied "ASoC: SOF: loader: Don't ignore SRAM block types" to the asoc tree Mark Brown
2019-07-22 14:13 ` [PATCH 09/21] ASoC: SOF: remove unused state variable in suspend function Pierre-Louis Bossart
2019-07-23 11:29   ` Applied "ASoC: SOF: remove unused state variable in suspend function" to the asoc tree Mark Brown
2019-07-22 14:13 ` [PATCH 10/21] ASoC: SOF: Intel: hda: correct ROM state mask Pierre-Louis Bossart
2019-07-23 11:29   ` Applied "ASoC: SOF: Intel: hda: correct ROM state mask" to the asoc tree Mark Brown
2019-07-22 14:13 ` [PATCH 11/21] ASoC: SOF: Intel: hda: reduce ifdef usage for hda Pierre-Louis Bossart
2019-07-23 11:29   ` Applied "ASoC: SOF: Intel: hda: reduce ifdef usage for hda" to the asoc tree Mark Brown
2019-07-22 14:13 ` [PATCH 12/21] ASoC: SOF: Intel: hda: Enable jack detection Pierre-Louis Bossart
2019-07-23 11:29   ` Applied "ASoC: SOF: Intel: hda: Enable jack detection" to the asoc tree Mark Brown
2019-07-22 14:13 ` [PATCH 13/21] ASoC: SOF: Intel: hda: set position buffer in init chip Pierre-Louis Bossart
2019-07-23 11:29   ` Applied "ASoC: SOF: Intel: hda: set position buffer in init chip" to the asoc tree Mark Brown
2019-07-22 14:13 ` [PATCH 14/21] ASoC: SOF: Intel: hda: use SOF defined init chip in resume Pierre-Louis Bossart
2019-07-23 11:29   ` Applied "ASoC: SOF: Intel: hda: use SOF defined init chip in resume" to the asoc tree Mark Brown
2019-07-22 14:13 ` [PATCH 15/21] ASoC: SOF: Intel: hda: remove duplicated clear WAKESTS Pierre-Louis Bossart
2019-07-23 11:29   ` Applied "ASoC: SOF: Intel: hda: remove duplicated clear WAKESTS" to the asoc tree Mark Brown
2019-07-22 14:13 ` [PATCH 16/21] ASoC: SOF: Intel: hda: add a parameter to disable MSI Pierre-Louis Bossart
2019-07-23 11:29   ` Applied "ASoC: SOF: Intel: hda: add a parameter to disable MSI" to the asoc tree Mark Brown
2019-07-22 14:13 ` [PATCH 17/21] ASoC: SOF: Intel: hda: reset link DMA state in prepare Pierre-Louis Bossart
2019-07-23 11:29   ` Applied "ASoC: SOF: Intel: hda: reset link DMA state in prepare" to the asoc tree Mark Brown
2019-07-22 14:13 ` Pierre-Louis Bossart [this message]
2019-07-23 11:15   ` [PATCH 18/21] ASoC: SOF: Intel: hda: fix link DMA config Mark Brown
2019-07-23 14:37     ` Pierre-Louis Bossart
2019-07-23 16:30       ` Mark Brown
2019-07-23 11:29   ` Applied "ASoC: SOF: Intel: hda: fix link DMA config" to the asoc tree Mark Brown
2019-07-22 14:14 ` [PATCH 19/21] ASoC: SOF: Intel: hda: fix stream id setting Pierre-Louis Bossart
2019-07-23 11:29   ` Applied "ASoC: SOF: Intel: hda: fix stream id setting" to the asoc tree Mark Brown
2019-07-22 14:14 ` [PATCH 20/21] ASoC: SOF: Intel: hda: remove misleading error trace from IRQ thread Pierre-Louis Bossart
2019-07-23 11:29   ` Applied "ASoC: SOF: Intel: hda: remove misleading error trace from IRQ thread" to the asoc tree Mark Brown
2019-07-22 14:14 ` [PATCH 21/21] ASoC: SOF: Intel: ssp: BCLK delay parameter Pierre-Louis Bossart
2019-07-23 11:29   ` Applied "ASoC: SOF: Intel: ssp: BCLK delay parameter" to the asoc tree Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190722141402.7194-19-pierre-louis.bossart@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=rander.wang@linux.intel.com \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.