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,
	Ranjani Sridharan <ranjani.sridharan@linux.intel.com>,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Subject: [PATCH 05/15] ASoC: SOF: Intel: hda: reserve host DMA channel for hostless streams
Date: Wed, 12 Jun 2019 12:23:37 -0500	[thread overview]
Message-ID: <20190612172347.22338-6-pierre-louis.bossart@linux.intel.com> (raw)
In-Reply-To: <20190612172347.22338-1-pierre-louis.bossart@linux.intel.com>

From: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>

Due to the HW programming sequence requirement that the host
and link DMA channels need to be coupled/decoupled during pcm
hw_params, the host DMA channel corresponding to the link
DMA channel in use for hostless streams needs to be reserved.
This is achieved by adding a host_reserved flag in the
sof_intel_hda_stream structure which is checked when assigning
a host DMA channel.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/sof/intel/hda-dai.c    | 11 ++++++++++-
 sound/soc/sof/intel/hda-stream.c | 10 +++++++++-
 sound/soc/sof/intel/hda.h        |  1 +
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/sound/soc/sof/intel/hda-dai.c b/sound/soc/sof/intel/hda-dai.c
index c270fd7a0878..a514f9cf5c9a 100644
--- a/sound/soc/sof/intel/hda-dai.c
+++ b/sound/soc/sof/intel/hda-dai.c
@@ -75,7 +75,7 @@ static struct hdac_ext_stream *
 
 		hda_stream = hstream_to_sof_hda_stream(hstream);
 
-		/* check if available */
+		/* check if link is available */
 		if (!hstream->link_locked) {
 			if (stream->opened) {
 				/*
@@ -89,6 +89,12 @@ static struct hdac_ext_stream *
 				}
 			} else {
 				res = hstream;
+
+				/*
+				 * This must be a hostless stream.
+				 * So reserve the host DMA channel.
+				 */
+				hda_stream->host_reserved = 1;
 				break;
 			}
 		}
@@ -368,6 +374,9 @@ static int hda_link_hw_free(struct snd_pcm_substream *substream,
 	snd_hdac_ext_stream_release(link_dev, HDAC_EXT_STREAM_TYPE_LINK);
 	link_dev->link_prepared = 0;
 
+	/* free the host DMA channel reserved by hostless streams */
+	hda_stream->host_reserved = 0;
+
 	return 0;
 }
 
diff --git a/sound/soc/sof/intel/hda-stream.c b/sound/soc/sof/intel/hda-stream.c
index 1cd94e7631a8..a3f7c91469ec 100644
--- a/sound/soc/sof/intel/hda-stream.c
+++ b/sound/soc/sof/intel/hda-stream.c
@@ -155,6 +155,7 @@ struct hdac_ext_stream *
 hda_dsp_stream_get(struct snd_sof_dev *sdev, int direction)
 {
 	struct hdac_bus *bus = sof_to_bus(sdev);
+	struct sof_intel_hda_stream *hda_stream;
 	struct hdac_ext_stream *stream = NULL;
 	struct hdac_stream *s;
 
@@ -163,8 +164,15 @@ hda_dsp_stream_get(struct snd_sof_dev *sdev, int direction)
 	/* get an unused stream */
 	list_for_each_entry(s, &bus->stream_list, list) {
 		if (s->direction == direction && !s->opened) {
-			s->opened = true;
 			stream = stream_to_hdac_ext_stream(s);
+			hda_stream = container_of(stream,
+						  struct sof_intel_hda_stream,
+						  hda_stream);
+			/* check if the host DMA channel is reserved */
+			if (hda_stream->host_reserved)
+				continue;
+
+			s->opened = true;
 			break;
 		}
 	}
diff --git a/sound/soc/sof/intel/hda.h b/sound/soc/sof/intel/hda.h
index 376b1ca51e2b..2862b4b3b07c 100644
--- a/sound/soc/sof/intel/hda.h
+++ b/sound/soc/sof/intel/hda.h
@@ -413,6 +413,7 @@ struct sof_intel_hda_stream {
 	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 */
 };
 
 #define hstream_to_sof_hda_stream(hstream) \
-- 
2.20.1

  parent reply	other threads:[~2019-06-12 17:23 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-12 17:23 [PATCH 00/15] ASoC: SOF: Intel: HDaudio fixes and improvements Pierre-Louis Bossart
2019-06-12 17:23 ` [PATCH 01/15] ASoC: SOF: Intel: hda: save handle to sdev in sof_intel_hda_stream Pierre-Louis Bossart
2019-06-13  8:00   ` Amadeusz Sławiński
2019-06-17 15:24   ` Applied "ASoC: SOF: Intel: hda: save handle to sdev in sof_intel_hda_stream" to the asoc tree Mark Brown
2019-06-12 17:23 ` [PATCH 02/15] ASoC: SOF: Intel: hda: add new macro hstream_to_sof_hda_stream() Pierre-Louis Bossart
2019-06-17 15:24   ` Applied "ASoC: SOF: Intel: hda: add new macro hstream_to_sof_hda_stream()" to the asoc tree Mark Brown
2019-06-12 17:23 ` [PATCH 03/15] ASoC: SOF: topology: add cpu_dai_name for DAIs Pierre-Louis Bossart
2019-06-17 15:24   ` Applied "ASoC: SOF: topology: add cpu_dai_name for DAIs" to the asoc tree Mark Brown
2019-06-12 17:23 ` [PATCH 04/15] ASoC: SOF: Intel: hda: assign link DMA channel at run-time Pierre-Louis Bossart
2019-06-17 15:24   ` Applied "ASoC: SOF: Intel: hda: assign link DMA channel at run-time" to the asoc tree Mark Brown
2019-06-12 17:23 ` Pierre-Louis Bossart [this message]
2019-06-17 15:24   ` Applied "ASoC: SOF: Intel: hda: reserve host DMA channel for hostless streams" " Mark Brown
2019-06-12 17:23 ` [PATCH 06/15] ASoC: SOF: Intel: hda: release link DMA for paused streams during suspend Pierre-Louis Bossart
2019-06-17 15:24   ` Applied "ASoC: SOF: Intel: hda: release link DMA for paused streams during suspend" to the asoc tree Mark Brown
2019-06-12 17:23 ` [PATCH 07/15] ASoC: SOF: Intel: hda: couple host and link DMA during FE hw_free Pierre-Louis Bossart
2019-06-17 15:24   ` Applied "ASoC: SOF: Intel: hda: couple host and link DMA during FE hw_free" to the asoc tree Mark Brown
2019-06-12 17:23 ` [PATCH 08/15] ASoC: SOF: Intel: hda: modify stream interrupt handler Pierre-Louis Bossart
2019-06-17 15:24   ` Applied "ASoC: SOF: Intel: hda: modify stream interrupt handler" to the asoc tree Mark Brown
2019-06-12 17:23 ` [PATCH 09/15] ASoC: SOF: Intel: hda-stream: fix a deadlock with bus->reg_lock Pierre-Louis Bossart
2019-06-17 15:24   ` Applied "ASoC: SOF: Intel: hda-stream: fix a deadlock with bus->reg_lock" to the asoc tree Mark Brown
2019-06-12 17:23 ` [PATCH 10/15] ASoC: SOF: Intel: hda: use the SOF defined ppcap functions Pierre-Louis Bossart
2019-06-17 15:24   ` Applied "ASoC: SOF: Intel: hda: use the SOF defined ppcap functions" to the asoc tree Mark Brown
2019-06-12 17:23 ` [PATCH 11/15] ASoC: SOF: Intel: hda: add function for hda stop chip Pierre-Louis Bossart
2019-06-17 15:24   ` Applied "ASoC: SOF: Intel: hda: add function for hda stop chip" to the asoc tree Mark Brown
2019-06-12 17:23 ` [PATCH 12/15] ASoC: SOF: Intel: hda: use the defined stop chip in suspend Pierre-Louis Bossart
2019-06-17 15:24   ` Applied "ASoC: SOF: Intel: hda: use the defined stop chip in suspend" to the asoc tree Mark Brown
2019-06-12 17:23 ` [PATCH 13/15] ASoC: SOF: Intel: hda: clear stream status and wakests properly Pierre-Louis Bossart
2019-06-17 15:24   ` Applied "ASoC: SOF: Intel: hda: clear stream status and wakests properly" to the asoc tree Mark Brown
2019-06-12 17:23 ` [PATCH 14/15] ASoC: SOF: Intel: hda: make sure DMA is start/stop by read the RUN bit Pierre-Louis Bossart
2019-06-17 15:24   ` Applied "ASoC: SOF: Intel: hda: make sure DMA is start/stop by read the RUN bit" to the asoc tree Mark Brown
2019-06-12 17:23 ` [PATCH 15/15] ASoC: SOF: Intel: hda: make sure RUN bit setting to 0 during clear stream status Pierre-Louis Bossart
2019-06-17 15:24   ` Applied "ASoC: SOF: Intel: hda: make sure RUN bit setting to 0 during clear stream status" 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=20190612172347.22338-6-pierre-louis.bossart@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=ranjani.sridharan@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.