Skip to contentSkip to conversation

ASoC: SOF: Intel: reset spib_addr in stream cleanup

PATCH In review Bard Liao 2 participants 4 messages Jul 13 – Jul 14

Subsystems (3)
lore
Share & tools
lore

Bard Liao

author maintainer
#0 lore raw

v2 cover ASoC: SOF: Intel: reset spib_addr in stream cleanup

The spib_addr register indicates the current position in the buffer being processed by the host software to the host DMA. It must be reset before being disabled. Also, add the missing disable call in hda_data_stream_cleanup().

v2: Check is_icccmax in hda_data_stream_cleanup() to avoid disabling
SPIB in ICCMAX stream.

Bard Liao (2):
ASoC: SOF: Intel: reset spib_addr before disabling SPIB
ASoC: SOF: Intel: Disable SPIB in non ICCMAX stream

 sound/soc/sof/intel/hda-loader.c  | 11 ++++++-----
 sound/soc/sof/intel/hda-sdw-bpt.c |  2 +-
 sound/soc/sof/intel/hda-stream.c  | 15 +++++++++++----
 sound/soc/sof/intel/hda.h         |  5 +++--
 4 files changed, 21 insertions(+), 12 deletions(-)
Signature · 1 line
2.43.0
author maintainer
#1 lore raw

PATCH v2 1/2 ASoC: SOF: Intel: reset spib_addr before disabling SPIB

The spib_addr register will indicate to the host DMA where the position is in the buffer currently processed by host SW. The register is ignored by the host DMA if SPIB is disabled. Reset it to 0 before disabling SPIB.

---
 sound/soc/sof/intel/hda-stream.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
sound/soc/sof/intel/hda-stream.c +6 -1
index 5c1f3b427cdb..4a46e35c3eac 100644
@@ -198,13 +198,18 @@ int hda_dsp_stream_spib_config(struct snd_sof_dev *sdev,
 
 	mask = (1 << hstream->index);
 
+	/* Reset the spib_addr before disabling SPIB */
+	if (!enable)
+		sof_io_write(sdev, hstream->spib_addr, 0);
+
 	/* enable/disable SPIB for the stream */
 	snd_sof_dsp_update_bits(sdev, HDA_DSP_SPIB_BAR,
 				SOF_HDA_ADSP_REG_CL_SPBFIFO_SPBFCCTL, mask,
 				enable << hstream->index);
 
 	/* set the SPIB value */
-	sof_io_write(sdev, hstream->spib_addr, size);
+	if (enable)
+		sof_io_write(sdev, hstream->spib_addr, size);
 
 	return 0;
 }
Signature · 1 line
2.43.0
author maintainer
#2 lore raw

PATCH v2 2/2 ASoC: SOF: Intel: Disable SPIB in non ICCMAX stream

In reply to Bard Liao

The existing code disable SPIB in the playback direction only because previously the hda data stream is only used for SOF firmware download and we prepare capture stream for ICCMAX and prepare playback stream for non ICCMAX case. But now the hda data stream is also used for SoundWire BPT which will use both directions. The SPIB is enabled in non ICCMAX cases and we should disable in clean up.
Add a is_iccmax flag in the hda_data_stream_cleanup() function to align with the hda_data_stream_prepare() function to enable/disable the SPIB.

---
 sound/soc/sof/intel/hda-loader.c  | 11 ++++++-----
 sound/soc/sof/intel/hda-sdw-bpt.c |  2 +-
 sound/soc/sof/intel/hda-stream.c  |  8 +++++---
 sound/soc/sof/intel/hda.h         |  5 +++--
 4 files changed, 15 insertions(+), 11 deletions(-)
sound/soc/sof/intel/hda-loader.c +6 -5
index 2b3abcf75d55..4347e71337f9 100644
@@ -216,9 +216,10 @@ int hda_cl_trigger(struct device *dev, struct hdac_ext_stream *hext_stream, int
 EXPORT_SYMBOL_NS(hda_cl_trigger, "SND_SOC_SOF_INTEL_HDA_COMMON");
 
 int hda_cl_cleanup(struct device *dev, struct snd_dma_buffer *dmab,
-			  bool persistent_buffer, struct hdac_ext_stream *hext_stream)
+		   bool persistent_buffer, struct hdac_ext_stream *hext_stream, bool is_iccmax)
 {
-	return hda_data_stream_cleanup(dev, dmab, persistent_buffer, hext_stream, false);
+	return hda_data_stream_cleanup(dev, dmab, persistent_buffer, hext_stream,
+				       is_iccmax, false);
 }
 EXPORT_SYMBOL_NS(hda_cl_cleanup, "SND_SOC_SOF_INTEL_HDA_COMMON");
 
@@ -302,7 +303,7 @@ int hda_dsp_cl_boot_firmware_iccmax(struct snd_sof_dev *sdev)
 	 * If the cleanup also fails, we return the initial error
 	 */
 	ret1 = hda_cl_cleanup(sdev->dev, &hda->iccmax_dmab,
-			      persistent_cl_buffer, iccmax_stream);
+			      persistent_cl_buffer, iccmax_stream, true);
 	if (ret1 < 0) {
 		dev_err(sdev->dev, "error: ICCMAX stream cleanup failed\n");
 
@@ -458,7 +459,7 @@ int hda_dsp_cl_boot_firmware(struct snd_sof_dev *sdev)
 	 * If the cleanup also fails, we return the initial error
 	 */
 	ret1 = hda_cl_cleanup(sdev->dev, &hda->cl_dmab,
-			      persistent_cl_buffer, hext_stream);
+			      persistent_cl_buffer, hext_stream, false);
 	if (ret1 < 0) {
 		dev_err(sdev->dev, "error: Code loader DSP cleanup failed\n");
 
@@ -587,7 +588,7 @@ int hda_dsp_ipc4_load_library(struct snd_sof_dev *sdev,
 cleanup:
 	/* clean up even in case of error and return the first error */
 	ret1 = hda_cl_cleanup(sdev->dev, &hda->cl_dmab, persistent_cl_buffer,
-			      hext_stream);
+			      hext_stream, false);
 	if (ret1 < 0) {
 		dev_err(sdev->dev, "%s: Code loader DSP cleanup failed\n", __func__);
 
sound/soc/sof/intel/hda-sdw-bpt.c +1 -1
index 728ffe7ae54d..c10648f56f23 100644
@@ -163,7 +163,7 @@ static int hda_sdw_bpt_dma_deprepare(struct device *dev, struct hdac_ext_stream
 	u32 mask;
 	int ret;
 
-	ret = hda_data_stream_cleanup(sdev->dev, dmab_bdl, false, sdw_bpt_stream, true);
+	ret = hda_data_stream_cleanup(sdev->dev, dmab_bdl, false, sdw_bpt_stream, false, true);
 	if (ret < 0) {
 		dev_err(sdev->dev, "%s: SDW BPT DMA cleanup failed\n",
 			__func__);
sound/soc/sof/intel/hda-stream.c +5 -3
index 4a46e35c3eac..0778002e2bd6 100644
@@ -1328,16 +1328,18 @@ hda_data_stream_prepare(struct device *dev, unsigned int format, unsigned int si
 EXPORT_SYMBOL_NS(hda_data_stream_prepare, "SND_SOC_SOF_INTEL_HDA_COMMON");
 
 int hda_data_stream_cleanup(struct device *dev, struct snd_dma_buffer *dmab,
-			    bool persistent_buffer, struct hdac_ext_stream *hext_stream, bool pair)
+			    bool persistent_buffer, struct hdac_ext_stream *hext_stream,
+			    bool is_iccmax, bool pair)
 {
 	struct snd_sof_dev *sdev =  dev_get_drvdata(dev);
 	struct hdac_stream *hstream = hdac_stream(hext_stream);
 	int sd_offset = SOF_STREAM_SD_OFFSET(hstream);
 	int ret = 0;
 
-	if (hstream->direction == SNDRV_PCM_STREAM_PLAYBACK)
+	if (!is_iccmax)
 		ret = hda_dsp_stream_spib_config(sdev, hext_stream, HDA_DSP_SPIB_DISABLE, 0);
-	else
+
+	if (hstream->direction == SNDRV_PCM_STREAM_CAPTURE)
 		snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, sd_offset,
 					SOF_HDA_SD_CTL_DMA_START, 0);
 
sound/soc/sof/intel/hda.h +3 -2
index 3f0966477ace..799e49539b4a 100644
@@ -739,7 +739,7 @@ struct hdac_ext_stream *hda_cl_prepare(struct device *dev, unsigned int format,
 int hda_cl_trigger(struct device *dev, struct hdac_ext_stream *hext_stream, int cmd);
 
 int hda_cl_cleanup(struct device *dev, struct snd_dma_buffer *dmab,
-		   bool persistent_buffer, struct hdac_ext_stream *hext_stream);
+		   bool persistent_buffer, struct hdac_ext_stream *hext_stream, bool is_iccmax);
 int cl_dsp_init(struct snd_sof_dev *sdev, int stream_tag, bool imr_boot);
 #define HDA_CL_STREAM_FORMAT 0x40
 
@@ -911,7 +911,8 @@ hda_data_stream_prepare(struct device *dev, unsigned int format, unsigned int si
 			bool is_iccmax, bool pair);
 
 int hda_data_stream_cleanup(struct device *dev, struct snd_dma_buffer *dmab,
-			    bool persistent_buffer, struct hdac_ext_stream *hext_stream, bool pair);
+			    bool persistent_buffer, struct hdac_ext_stream *hext_stream,
+			    bool is_iccmax, bool pair);
 
 /* common dai driver */
 extern struct snd_soc_dai_driver skl_dai[];
Signature · 1 line
2.43.0
maintainer
#3 lore raw
In reply to Bard Liao
Quoted 8 lines · Bard Liao

ASoC: SOF: Intel: reset spib_addr in stream cleanup

The spib_addr register indicates the current position in the buffer being processed by the host software to the host DMA. It must be reset before being disabled. Also, add the missing disable call in hda_data_stream_cleanup().

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.3

Thanks!

[1/2] ASoC: SOF: Intel: reset spib_addr before disabling SPIB

      https://git.kernel.org/broonie/sound/c/552d9559cae2
[2/2] ASoC: SOF: Intel: Disable SPIB in non ICCMAX stream
      https://git.kernel.org/broonie/sound/c/0507d956c4ce

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