Skip to contentSkip to conversation

ASoC: SOF: updates for 5.7

PATCH In review Pierre-Louis Bossart 2 participants 9 messages Feb 28, 2020 – Mar 2, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover ASoC: SOF: updates for 5.7

4 unrelated improvements grouped in one bundle.

Jaska Uimonen (1):
ASoC: SOF: ipc: check ipc return value before data copy

Keyon Jie (2):
ASoC: SOF: pcm: skip DMA buffer pre-allocation
ASoC: SOF: Intel: hda-loader: clear the IPC ack bit after FW_PURGE
done

Tomasz Lauda (1):
ASoC: SOF: add core id to sof_ipc_comp

 include/sound/sof/topology.h     |  3 ++-
 include/uapi/sound/sof/abi.h     |  2 +-
 sound/soc/sof/intel/hda-loader.c |  6 ++++++
 sound/soc/sof/ipc.c              | 12 +++++++-----
 sound/soc/sof/pcm.c              |  6 ++----
 5 files changed, 18 insertions(+), 11 deletions(-)

base-commit: 6941b0b5f919e9839e8c25efaeb53854efee14e5

Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/4 ASoC: SOF: pcm: skip DMA buffer pre-allocation

From: Keyon Jie <[email protected]>

As discussion in ALSA https://patchwork.kernel.org/patch/11336023/, it is suggested to skip DMA buffer pre-allocation with passing size=0 when calling snd_pcm_set_managed_buffer(), to make the full buffer_bytes range configured in topology file selectable from user space, here do the corresponding change in SOF PCM driver to implement it.

This change doesn't have dependency to the change that Takashi will do in the ALSA core by adding total_pcm_alloc_bytes limitation to the struct snd_card, it passes tests both with or without Takashi's coming change on SOF CML platform.

---
 sound/soc/sof/pcm.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
sound/soc/sof/pcm.c +2 -4
index b239bbff4b5c..f4769e19965a 100644
@@ -601,8 +601,7 @@ static int sof_pcm_new(struct snd_soc_component *component,
 
 	snd_pcm_set_managed_buffer(pcm->streams[stream].substream,
 				   SNDRV_DMA_TYPE_DEV_SG, sdev->dev,
-				   le32_to_cpu(caps->buffer_size_min),
-				   le32_to_cpu(caps->buffer_size_max));
+				   0, le32_to_cpu(caps->buffer_size_max));
 capture:
 	stream = SNDRV_PCM_STREAM_CAPTURE;
 
@@ -624,8 +623,7 @@ static int sof_pcm_new(struct snd_soc_component *component,
 
 	snd_pcm_set_managed_buffer(pcm->streams[stream].substream,
 				   SNDRV_DMA_TYPE_DEV_SG, sdev->dev,
-				   le32_to_cpu(caps->buffer_size_min),
-				   le32_to_cpu(caps->buffer_size_max));
+				   0, le32_to_cpu(caps->buffer_size_max));
 
 	return 0;
 }
Signature · 1 line
2.20.1
maintainer
#2 lore raw

Applied "ASoC: SOF: pcm: skip DMA buffer pre-allocation" to the asoc tree

The patch

ASoC: SOF: pcm: skip DMA buffer pre-allocation

has been applied to the asoc tree at

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

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

From e582f4832a9ee27d92502b58f3a1b3331457e8bb Mon Sep 17 00:00:00 2001
From: Keyon Jie <[email protected]>
Date: Fri, 28 Feb 2020 17:18:47 -0600
Subject: [PATCH] ASoC: SOF: pcm: skip DMA buffer pre-allocation

As discussion in ALSA https://patchwork.kernel.org/patch/11336023/, it is suggested to skip DMA buffer pre-allocation with passing size=0 when calling snd_pcm_set_managed_buffer(), to make the full buffer_bytes range configured in topology file selectable from user space, here do the corresponding change in SOF PCM driver to implement it.

This change doesn't have dependency to the change that Takashi will do in the ALSA core by adding total_pcm_alloc_bytes limitation to the struct snd_card, it passes tests both with or without Takashi's coming change on SOF CML platform.

---
 sound/soc/sof/pcm.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
sound/soc/sof/pcm.c +2 -4
index b239bbff4b5c..f4769e19965a 100644
@@ -601,8 +601,7 @@ static int sof_pcm_new(struct snd_soc_component *component,
 
 	snd_pcm_set_managed_buffer(pcm->streams[stream].substream,
 				   SNDRV_DMA_TYPE_DEV_SG, sdev->dev,
-				   le32_to_cpu(caps->buffer_size_min),
-				   le32_to_cpu(caps->buffer_size_max));
+				   0, le32_to_cpu(caps->buffer_size_max));
 capture:
 	stream = SNDRV_PCM_STREAM_CAPTURE;
 
@@ -624,8 +623,7 @@ static int sof_pcm_new(struct snd_soc_component *component,
 
 	snd_pcm_set_managed_buffer(pcm->streams[stream].substream,
 				   SNDRV_DMA_TYPE_DEV_SG, sdev->dev,
-				   le32_to_cpu(caps->buffer_size_min),
-				   le32_to_cpu(caps->buffer_size_max));
+				   0, le32_to_cpu(caps->buffer_size_max));
 
 	return 0;
 }
Signature · 1 line
2.20.1
#3 lore raw

PATCH 2/4 ASoC: SOF: ipc: check ipc return value before data copy

In reply to Pierre-Louis Bossart

From: Jaska Uimonen <[email protected]>

In tx_wait_done the ipc payload is copied before the DSP transaction error code is checked. This might lead to corrupted data in kernel side even though the error would be handled later. It is also pointless to copy the data in case of error. So change the order of error check and copy.

---
 sound/soc/sof/ipc.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
sound/soc/sof/ipc.c +7 -5
index 22d296f95761..cc5762706c9c 100644
@@ -214,15 +214,17 @@ static int tx_wait_done(struct snd_sof_ipc *ipc, struct snd_sof_ipc_msg *msg,
 		snd_sof_handle_fw_exception(ipc->sdev);
 		ret = -ETIMEDOUT;
 	} else {
-		/* copy the data returned from DSP */
 		ret = msg->reply_error;
-		if (msg->reply_size)
-			memcpy(reply_data, msg->reply_data, msg->reply_size);
-		if (ret < 0)
+		if (ret < 0) {
 			dev_err(sdev->dev, "error: ipc error for 0x%x size %zu\n",
 				hdr->cmd, msg->reply_size);
-		else
+		} else {
 			ipc_log_header(sdev->dev, "ipc tx succeeded", hdr->cmd);
+			if (msg->reply_size)
+				/* copy the data returned from DSP */
+				memcpy(reply_data, msg->reply_data,
+				       msg->reply_size);
+		}
 	}
 
 	return ret;
Signature · 1 line
2.20.1
maintainer
#4 lore raw

Applied "ASoC: SOF: ipc: check ipc return value before data copy" to the asoc tree

The patch

ASoC: SOF: ipc: check ipc return value before data copy

has been applied to the asoc tree at

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

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

From 1919b42ca4ad75a2397081164661af3ce5a7b8f4 Mon Sep 17 00:00:00 2001
From: Jaska Uimonen <[email protected]>
Date: Fri, 28 Feb 2020 17:18:48 -0600
Subject: [PATCH] ASoC: SOF: ipc: check ipc return value before data copy

In tx_wait_done the ipc payload is copied before the DSP transaction error code is checked. This might lead to corrupted data in kernel side even though the error would be handled later. It is also pointless to copy the data in case of error. So change the order of error check and copy.

---
 sound/soc/sof/ipc.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
sound/soc/sof/ipc.c +7 -5
index 22d296f95761..cc5762706c9c 100644
@@ -214,15 +214,17 @@ static int tx_wait_done(struct snd_sof_ipc *ipc, struct snd_sof_ipc_msg *msg,
 		snd_sof_handle_fw_exception(ipc->sdev);
 		ret = -ETIMEDOUT;
 	} else {
-		/* copy the data returned from DSP */
 		ret = msg->reply_error;
-		if (msg->reply_size)
-			memcpy(reply_data, msg->reply_data, msg->reply_size);
-		if (ret < 0)
+		if (ret < 0) {
 			dev_err(sdev->dev, "error: ipc error for 0x%x size %zu\n",
 				hdr->cmd, msg->reply_size);
-		else
+		} else {
 			ipc_log_header(sdev->dev, "ipc tx succeeded", hdr->cmd);
+			if (msg->reply_size)
+				/* copy the data returned from DSP */
+				memcpy(reply_data, msg->reply_data,
+				       msg->reply_size);
+		}
 	}
 
 	return ret;
Signature · 1 line
2.20.1
#5 lore raw

PATCH 3/4 ASoC: SOF: Intel: hda-loader: clear the IPC ack bit after FW_PURGE done

In reply to Pierre-Louis Bossart

From: Keyon Jie <[email protected]>

Set DONE bit after the FW_PURGE IPC is polled successfully, to clear the interrupt and avoid the arrival of the confusing unexpected ipc.

---
 sound/soc/sof/intel/hda-loader.c | 6 ++++++
 1 file changed, 6 insertions(+)
sound/soc/sof/intel/hda-loader.c +6 -0
index 8852184a2569..03b05d7f66da 100644
@@ -131,6 +131,12 @@ static int cl_dsp_init(struct snd_sof_dev *sdev, const void *fwdata,
 		goto err;
 	}
 
+	/* set DONE bit to clear the reply IPC message */
+	snd_sof_dsp_update_bits_forced(sdev, HDA_DSP_BAR,
+				       chip->ipc_ack,
+				       chip->ipc_ack_mask,
+				       chip->ipc_ack_mask);
+
 	/* step 5: power down corex */
 	ret = hda_dsp_core_power_down(sdev,
 				  chip->cores_mask & ~(HDA_DSP_CORE_MASK(0)));
Signature · 1 line
2.20.1
maintainer
#6 lore raw

Applied "ASoC: SOF: Intel: hda-loader: clear the IPC ack bit after FW_PURGE done" to the asoc tree

The patch

ASoC: SOF: Intel: hda-loader: clear the IPC ack bit after FW_PURGE done

has been applied to the asoc tree at

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

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

From 8354d9b44530b5f534146668ae641572dede79a4 Mon Sep 17 00:00:00 2001
From: Keyon Jie <[email protected]>
Date: Fri, 28 Feb 2020 17:18:49 -0600
Subject: [PATCH] ASoC: SOF: Intel: hda-loader: clear the IPC ack bit after
FW_PURGE done

Set DONE bit after the FW_PURGE IPC is polled successfully, to clear the interrupt and avoid the arrival of the confusing unexpected ipc.

---
 sound/soc/sof/intel/hda-loader.c | 6 ++++++
 1 file changed, 6 insertions(+)
sound/soc/sof/intel/hda-loader.c +6 -0
index 8852184a2569..03b05d7f66da 100644
@@ -131,6 +131,12 @@ static int cl_dsp_init(struct snd_sof_dev *sdev, const void *fwdata,
 		goto err;
 	}
 
+	/* set DONE bit to clear the reply IPC message */
+	snd_sof_dsp_update_bits_forced(sdev, HDA_DSP_BAR,
+				       chip->ipc_ack,
+				       chip->ipc_ack_mask,
+				       chip->ipc_ack_mask);
+
 	/* step 5: power down corex */
 	ret = hda_dsp_core_power_down(sdev,
 				  chip->cores_mask & ~(HDA_DSP_CORE_MASK(0)));
Signature · 1 line
2.20.1
#7 lore raw

PATCH 4/4 ASoC: SOF: add core id to sof_ipc_comp

In reply to Pierre-Louis Bossart

From: Tomasz Lauda <[email protected]>

Adds core id to sof_ipc_comp. The intention of this change is to inform FW on which core that particular component should run. Right now core id is only passed when pipeline is created, which is not flexible enough and doesn't allow for FW to handle this the right way.

---
 include/sound/sof/topology.h | 3 ++-
 include/uapi/sound/sof/abi.h | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
include/sound/sof/topology.h +2 -1
index 8e76178fedf0..402e0250c508 100644
@@ -53,9 +53,10 @@ struct sof_ipc_comp {
 	uint32_t id;
 	enum sof_comp_type type;
 	uint32_t pipeline_id;
+	uint32_t core;
 
 	/* reserved for future use */
-	uint32_t reserved[2];
+	uint32_t reserved[1];
 } __packed;
 
 /*
include/uapi/sound/sof/abi.h +1 -1
index c0ef1643c753..5995b79d6df1 100644
@@ -26,7 +26,7 @@
 
 /* SOF ABI version major, minor and patch numbers */
 #define SOF_ABI_MAJOR 3
-#define SOF_ABI_MINOR 12
+#define SOF_ABI_MINOR 13
 #define SOF_ABI_PATCH 0
 
 /* SOF ABI version number. Format within 32bit word is MMmmmppp */
Signature · 1 line
2.20.1
maintainer
#8 lore raw

Applied "ASoC: SOF: add core id to sof_ipc_comp" to the asoc tree

The patch

ASoC: SOF: add core id to sof_ipc_comp

has been applied to the asoc tree at

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

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

From 1a2289fdf678b780b2d68f408523c09b7074982e Mon Sep 17 00:00:00 2001
From: Tomasz Lauda <[email protected]>
Date: Fri, 28 Feb 2020 17:18:50 -0600
Subject: [PATCH] ASoC: SOF: add core id to sof_ipc_comp

Adds core id to sof_ipc_comp. The intention of this change is to inform FW on which core that particular component should run. Right now core id is only passed when pipeline is created, which is not flexible enough and doesn't allow for FW to handle this the right way.

---
 include/sound/sof/topology.h | 3 ++-
 include/uapi/sound/sof/abi.h | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
include/sound/sof/topology.h +2 -1
index 8e76178fedf0..402e0250c508 100644
@@ -53,9 +53,10 @@ struct sof_ipc_comp {
 	uint32_t id;
 	enum sof_comp_type type;
 	uint32_t pipeline_id;
+	uint32_t core;
 
 	/* reserved for future use */
-	uint32_t reserved[2];
+	uint32_t reserved[1];
 } __packed;
 
 /*
include/uapi/sound/sof/abi.h +1 -1
index c0ef1643c753..5995b79d6df1 100644
@@ -26,7 +26,7 @@
 
 /* SOF ABI version major, minor and patch numbers */
 #define SOF_ABI_MAJOR 3
-#define SOF_ABI_MINOR 12
+#define SOF_ABI_MINOR 13
 #define SOF_ABI_PATCH 0
 
 /* SOF ABI version number. Format within 32bit word is MMmmmppp */
Signature · 1 line
2.20.1