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,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
	Kai Vehmanen <kai.vehmanen@linux.intel.com>
Subject: [PATCH 17/21] ASoC: SOF: Intel: hda: reset link DMA state in prepare
Date: Mon, 22 Jul 2019 09:13:58 -0500	[thread overview]
Message-ID: <20190722141402.7194-18-pierre-louis.bossart@linux.intel.com> (raw)
In-Reply-To: <20190722141402.7194-1-pierre-louis.bossart@linux.intel.com>

From: Kai Vehmanen <kai.vehmanen@linux.intel.com>

When application goes through SUSPEND/STOP->PREPARE->START
cycle, we should always reprogram the DAI link DMA to ensure
it is in sync with the host PCM DMA.

Use same state tracking logic to handle both restart and
system resume flows. Use link_prepared field of
'struct hdac_ext_stream' to store the state, instead of
adding redundant fields to SOF specific structs.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/sof/intel/hda-dai.c |  8 +++-----
 sound/soc/sof/intel/hda-dsp.c | 17 ++++++-----------
 sound/soc/sof/intel/hda.h     |  1 -
 3 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/sound/soc/sof/intel/hda-dai.c b/sound/soc/sof/intel/hda-dai.c
index a514f9cf5c9a..a448be60f6dd 100644
--- a/sound/soc/sof/intel/hda-dai.c
+++ b/sound/soc/sof/intel/hda-dai.c
@@ -226,8 +226,6 @@ static int hda_link_hw_params(struct snd_pcm_substream *substream,
 
 	snd_soc_dai_set_dma_data(dai, substream, (void *)link_dev);
 
-	hda_stream->hw_params_upon_resume = 0;
-
 	link = snd_hdac_ext_bus_get_link(bus, codec_dai->component->name);
 	if (!link)
 		return -EINVAL;
@@ -267,8 +265,7 @@ static int hda_link_pcm_prepare(struct snd_pcm_substream *substream,
 
 	hda_stream = hstream_to_sof_hda_stream(link_dev);
 
-	/* setup hw_params again only if resuming from system suspend */
-	if (!hda_stream->hw_params_upon_resume)
+	if (link_dev->link_prepared)
 		return 0;
 
 	dev_dbg(sdev->dev, "hda: prepare stream dir %d\n", substream->stream);
@@ -317,6 +314,7 @@ static int hda_link_pcm_trigger(struct snd_pcm_substream *substream,
 		snd_hdac_ext_link_stream_start(link_dev);
 		break;
 	case SNDRV_PCM_TRIGGER_SUSPEND:
+	case SNDRV_PCM_TRIGGER_STOP:
 		/*
 		 * clear and release link DMA channel. It will be assigned when
 		 * hw_params is set up again after resume.
@@ -329,10 +327,10 @@ static int hda_link_pcm_trigger(struct snd_pcm_substream *substream,
 		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 */
 	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
-	case SNDRV_PCM_TRIGGER_STOP:
 		snd_hdac_ext_link_stream_clear(link_dev);
 		break;
 	default:
diff --git a/sound/soc/sof/intel/hda-dsp.c b/sound/soc/sof/intel/hda-dsp.c
index f08a5d649346..e82ecaad1763 100644
--- a/sound/soc/sof/intel/hda-dsp.c
+++ b/sound/soc/sof/intel/hda-dsp.c
@@ -425,25 +425,19 @@ int hda_dsp_suspend(struct snd_sof_dev *sdev)
 
 int hda_dsp_set_hw_params_upon_resume(struct snd_sof_dev *sdev)
 {
-	struct hdac_bus *bus = sof_to_bus(sdev);
-	struct sof_intel_hda_stream *hda_stream;
-	struct hdac_ext_stream *stream;
-	struct hdac_stream *s;
-
 #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
+	struct hdac_bus *bus = sof_to_bus(sdev);
 	struct snd_soc_pcm_runtime *rtd;
+	struct hdac_ext_stream *stream;
 	struct hdac_ext_link *link;
+	struct hdac_stream *s;
 	const char *name;
 	int stream_tag;
-#endif
 
 	/* set internal flag for BE */
 	list_for_each_entry(s, &bus->stream_list, list) {
 		stream = stream_to_hdac_ext_stream(s);
-		hda_stream = container_of(stream, struct sof_intel_hda_stream,
-					  hda_stream);
-		hda_stream->hw_params_upon_resume = 1;
-#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
+
 		/*
 		 * clear and release stream. This should already be taken care
 		 * for running streams when the SUSPEND trigger is called.
@@ -460,8 +454,9 @@ int hda_dsp_set_hw_params_upon_resume(struct snd_sof_dev *sdev)
 			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;
 		}
-#endif
 	}
+#endif
 	return 0;
 }
diff --git a/sound/soc/sof/intel/hda.h b/sound/soc/sof/intel/hda.h
index 028e865d5e20..ceaaa8d467f4 100644
--- a/sound/soc/sof/intel/hda.h
+++ b/sound/soc/sof/intel/hda.h
@@ -418,7 +418,6 @@ struct sof_intel_hda_stream {
 	struct snd_sof_dev *sdev;
 	struct hdac_ext_stream hda_stream;
 	struct sof_intel_stream stream;
-	int hw_params_upon_resume; /* set up hw_params upon resume */
 	int host_reserved; /* reserve host DMA channel */
 };
 
-- 
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 ` Pierre-Louis Bossart [this message]
2019-07-23 11:29   ` Applied "ASoC: SOF: Intel: hda: reset link DMA state in prepare" " Mark Brown
2019-07-22 14:13 ` [PATCH 18/21] ASoC: SOF: Intel: hda: fix link DMA config Pierre-Louis Bossart
2019-07-23 11:15   ` 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-18-pierre-louis.bossart@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=kai.vehmanen@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.