Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] ASoC: SOF: Implement support for DMA trace free IPC command
@ 2021-11-02 10:10 Peter Ujfalusi
  2021-11-02 10:10 ` [PATCH 1/3] ASoC: SOF: IPC: Add new IPC command to free trace DMA Peter Ujfalusi
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Peter Ujfalusi @ 2021-11-02 10:10 UTC (permalink / raw)
  To: lgirdwood, broonie
  Cc: alsa-devel, pierre-louis.bossart, kai.vehmanen, ranjani.sridharan

Hi,

This series adds support for the new DMA_TRACE_FREE IPC message to gracefully
stop and free the DMA trace related resources on the firmware side.

Regards,
Peter
---
Ranjani Sridharan (3):
  ASoC: SOF: IPC: Add new IPC command to free trace DMA
  ASoC: SOF: IPC: update ipc_log_header()
  ASoC: SOF: trace: send DMA_TRACE_FREE IPC during release

 include/sound/sof/header.h |  1 +
 sound/soc/sof/core.c       |  2 +-
 sound/soc/sof/ipc.c        | 17 ++++++++++++++++-
 sound/soc/sof/trace.c      | 18 ++++++++++++++++++
 4 files changed, 36 insertions(+), 2 deletions(-)

-- 
2.33.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] ASoC: SOF: IPC: Add new IPC command to free trace DMA
  2021-11-02 10:10 [PATCH 0/3] ASoC: SOF: Implement support for DMA trace free IPC command Peter Ujfalusi
@ 2021-11-02 10:10 ` Peter Ujfalusi
  2021-11-02 10:10 ` [PATCH 2/3] ASoC: SOF: IPC: update ipc_log_header() Peter Ujfalusi
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Peter Ujfalusi @ 2021-11-02 10:10 UTC (permalink / raw)
  To: lgirdwood, broonie
  Cc: alsa-devel, pierre-louis.bossart, kai.vehmanen, ranjani.sridharan

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

Add a new SOF_IPC_TRACE_DMA_FREE IPC command to stop and free trace DMA
in the FW.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
---
 include/sound/sof/header.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/sound/sof/header.h b/include/sound/sof/header.h
index 4c747c52e01b..b97a76bcb655 100644
--- a/include/sound/sof/header.h
+++ b/include/sound/sof/header.h
@@ -119,6 +119,7 @@
 #define SOF_IPC_TRACE_DMA_POSITION		SOF_CMD_TYPE(0x002)
 #define SOF_IPC_TRACE_DMA_PARAMS_EXT		SOF_CMD_TYPE(0x003)
 #define SOF_IPC_TRACE_FILTER_UPDATE		SOF_CMD_TYPE(0x004) /**< ABI3.17 */
+#define SOF_IPC_TRACE_DMA_FREE		SOF_CMD_TYPE(0x005) /**< ABI3.20 */
 
 /* debug */
 #define SOF_IPC_DEBUG_MEM_USAGE			SOF_CMD_TYPE(0x001)
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] ASoC: SOF: IPC: update ipc_log_header()
  2021-11-02 10:10 [PATCH 0/3] ASoC: SOF: Implement support for DMA trace free IPC command Peter Ujfalusi
  2021-11-02 10:10 ` [PATCH 1/3] ASoC: SOF: IPC: Add new IPC command to free trace DMA Peter Ujfalusi
@ 2021-11-02 10:10 ` Peter Ujfalusi
  2021-11-02 10:10 ` [PATCH 3/3] ASoC: SOF: trace: send DMA_TRACE_FREE IPC during release Peter Ujfalusi
  2021-11-15 20:18 ` [PATCH 0/3] ASoC: SOF: Implement support for DMA trace free IPC command Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: Peter Ujfalusi @ 2021-11-02 10:10 UTC (permalink / raw)
  To: lgirdwood, broonie
  Cc: alsa-devel, pierre-louis.bossart, kai.vehmanen, ranjani.sridharan

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

Parse all the trace DMA IPC commands in ipc_log_header().

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
---
 sound/soc/sof/ipc.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/sound/soc/sof/ipc.c b/sound/soc/sof/ipc.c
index e6c53c6c470e..a4036d0b3d3a 100644
--- a/sound/soc/sof/ipc.c
+++ b/sound/soc/sof/ipc.c
@@ -173,7 +173,22 @@ static void ipc_log_header(struct device *dev, u8 *text, u32 cmd)
 		}
 		break;
 	case SOF_IPC_GLB_TRACE_MSG:
-		str = "GLB_TRACE_MSG"; break;
+		str = "GLB_TRACE_MSG";
+		switch (type) {
+		case SOF_IPC_TRACE_DMA_PARAMS:
+			str2 = "DMA_PARAMS"; break;
+		case SOF_IPC_TRACE_DMA_POSITION:
+			str2 = "DMA_POSITION"; break;
+		case SOF_IPC_TRACE_DMA_PARAMS_EXT:
+			str2 = "DMA_PARAMS_EXT"; break;
+		case SOF_IPC_TRACE_FILTER_UPDATE:
+			str2 = "FILTER_UPDATE"; break;
+		case SOF_IPC_TRACE_DMA_FREE:
+			str2 = "DMA_FREE"; break;
+		default:
+			str2 = "unknown type"; break;
+		}
+		break;
 	case SOF_IPC_GLB_TEST_MSG:
 		str = "GLB_TEST_MSG";
 		switch (type) {
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] ASoC: SOF: trace: send DMA_TRACE_FREE IPC during release
  2021-11-02 10:10 [PATCH 0/3] ASoC: SOF: Implement support for DMA trace free IPC command Peter Ujfalusi
  2021-11-02 10:10 ` [PATCH 1/3] ASoC: SOF: IPC: Add new IPC command to free trace DMA Peter Ujfalusi
  2021-11-02 10:10 ` [PATCH 2/3] ASoC: SOF: IPC: update ipc_log_header() Peter Ujfalusi
@ 2021-11-02 10:10 ` Peter Ujfalusi
  2021-11-15 20:18 ` [PATCH 0/3] ASoC: SOF: Implement support for DMA trace free IPC command Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: Peter Ujfalusi @ 2021-11-02 10:10 UTC (permalink / raw)
  To: lgirdwood, broonie
  Cc: alsa-devel, pierre-louis.bossart, kai.vehmanen, ranjani.sridharan

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

Send the DMA_TRACE_FREE IPC during release to stop and free the trace
DMA in the DSP.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
---
 sound/soc/sof/core.c  |  2 +-
 sound/soc/sof/trace.c | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c
index af5bbc861297..40549cdd6d58 100644
--- a/sound/soc/sof/core.c
+++ b/sound/soc/sof/core.c
@@ -370,6 +370,7 @@ int snd_sof_device_remove(struct device *dev)
 	snd_sof_machine_unregister(sdev, pdata);
 
 	if (sdev->fw_state > SOF_FW_BOOT_NOT_STARTED) {
+		snd_sof_free_trace(sdev);
 		ret = snd_sof_dsp_power_down_notify(sdev);
 		if (ret < 0)
 			dev_warn(dev, "error: %d failed to prepare DSP for device removal",
@@ -377,7 +378,6 @@ int snd_sof_device_remove(struct device *dev)
 
 		snd_sof_ipc_free(sdev);
 		snd_sof_free_debug(sdev);
-		snd_sof_free_trace(sdev);
 	}
 
 	/*
diff --git a/sound/soc/sof/trace.c b/sound/soc/sof/trace.c
index e3afc3dac7d1..f13024c8ebf2 100644
--- a/sound/soc/sof/trace.c
+++ b/sound/soc/sof/trace.c
@@ -539,6 +539,10 @@ EXPORT_SYMBOL(snd_sof_trace_notify_for_error);
 
 void snd_sof_release_trace(struct snd_sof_dev *sdev)
 {
+	struct sof_ipc_fw_ready *ready = &sdev->fw_ready;
+	struct sof_ipc_fw_version *v = &ready->version;
+	struct sof_ipc_cmd_hdr hdr;
+	struct sof_ipc_reply ipc_reply;
 	int ret;
 
 	if (!sdev->dtrace_is_supported || !sdev->dtrace_is_enabled)
@@ -549,6 +553,20 @@ void snd_sof_release_trace(struct snd_sof_dev *sdev)
 		dev_err(sdev->dev,
 			"error: snd_sof_dma_trace_trigger: stop: %d\n", ret);
 
+	/*
+	 * stop and free trace DMA in the DSP. TRACE_DMA_FREE is only supported from
+	 * ABI 3.20.0 onwards
+	 */
+	if (v->abi_version >= SOF_ABI_VER(3, 20, 0)) {
+		hdr.size = sizeof(hdr);
+		hdr.cmd = SOF_IPC_GLB_TRACE_MSG | SOF_IPC_TRACE_DMA_FREE;
+
+		ret = sof_ipc_tx_message(sdev->ipc, hdr.cmd, &hdr, hdr.size,
+					 &ipc_reply, sizeof(ipc_reply));
+		if (ret < 0)
+			dev_err(sdev->dev, "DMA_TRACE_FREE failed with error: %d\n", ret);
+	}
+
 	ret = snd_sof_dma_trace_release(sdev);
 	if (ret < 0)
 		dev_err(sdev->dev,
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/3] ASoC: SOF: Implement support for DMA trace free IPC command
  2021-11-02 10:10 [PATCH 0/3] ASoC: SOF: Implement support for DMA trace free IPC command Peter Ujfalusi
                   ` (2 preceding siblings ...)
  2021-11-02 10:10 ` [PATCH 3/3] ASoC: SOF: trace: send DMA_TRACE_FREE IPC during release Peter Ujfalusi
@ 2021-11-15 20:18 ` Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2021-11-15 20:18 UTC (permalink / raw)
  To: Peter Ujfalusi, lgirdwood
  Cc: alsa-devel, pierre-louis.bossart, kai.vehmanen, ranjani.sridharan

On Tue, 2 Nov 2021 12:10:16 +0200, Peter Ujfalusi wrote:
> This series adds support for the new DMA_TRACE_FREE IPC message to gracefully
> stop and free the DMA trace related resources on the firmware side.
> 
> Regards,
> Peter
> 

Applied to

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

Thanks!

[1/3] ASoC: SOF: IPC: Add new IPC command to free trace DMA
      commit: 168eed447129899611098219b70ef97b605bc6e1
[2/3] ASoC: SOF: IPC: update ipc_log_header()
      commit: b4e2d7ce132bc4337916662f8e699420377132d9
[3/3] ASoC: SOF: trace: send DMA_TRACE_FREE IPC during release
      commit: 48b5b6a56002569881d18be56deaddad045df918

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-11-15 20:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-02 10:10 [PATCH 0/3] ASoC: SOF: Implement support for DMA trace free IPC command Peter Ujfalusi
2021-11-02 10:10 ` [PATCH 1/3] ASoC: SOF: IPC: Add new IPC command to free trace DMA Peter Ujfalusi
2021-11-02 10:10 ` [PATCH 2/3] ASoC: SOF: IPC: update ipc_log_header() Peter Ujfalusi
2021-11-02 10:10 ` [PATCH 3/3] ASoC: SOF: trace: send DMA_TRACE_FREE IPC during release Peter Ujfalusi
2021-11-15 20:18 ` [PATCH 0/3] ASoC: SOF: Implement support for DMA trace free IPC command Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox