ASoC: SOF: dma-trace: Pass pointer to params_ext struct in trace_init()
authorPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
Fri, 28 Jan 2022 12:36:23 +0000 (14:36 +0200)
committerMark Brown <broonie@kernel.org>
Tue, 8 Feb 2022 13:38:04 +0000 (13:38 +0000)
Instead of passing a pointer to the stream_tag within the
struct sof_ipc_dma_trace_params_ext, pass the pointer to the containing
struct.

AMD needs to update buffer.phy_addr (and don't really use the stream_tag)
for the trace implementation.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20220128123623.23569-3-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/amd/acp-trace.c
sound/soc/sof/amd/acp.h
sound/soc/sof/intel/hda-trace.c
sound/soc/sof/intel/hda.h
sound/soc/sof/ops.h
sound/soc/sof/sof-priv.h
sound/soc/sof/trace.c

index fa4da89471860b89faa29ca3de9c340116e7a3b4..903b6cc3dda36ef6b50c40e7b5299f12846be57e 100644 (file)
@@ -34,51 +34,31 @@ int acp_sof_trace_release(struct snd_sof_dev *sdev)
 }
 EXPORT_SYMBOL_NS(acp_sof_trace_release, SND_SOC_SOF_AMD_COMMON);
 
-static int acp_sof_trace_prepare(struct snd_sof_dev *sdev,
-                                struct sof_ipc_dma_trace_params_ext *params)
+int acp_sof_trace_init(struct snd_sof_dev *sdev,
+                      struct sof_ipc_dma_trace_params_ext *dtrace_params)
 {
        struct acp_dsp_stream *stream;
        struct acp_dev_data *adata;
        int ret;
 
        adata = sdev->pdata->hw_pdata;
-       stream = adata->dtrace_stream;
+       stream = acp_dsp_stream_get(sdev, ACP_LOGGER_STREAM);
+       if (!stream)
+               return -ENODEV;
+
        stream->dmab = &sdev->dmatb;
        stream->num_pages = NUM_PAGES;
 
        ret = acp_dsp_stream_config(sdev, stream);
        if (ret < 0) {
-               dev_err(sdev->dev, "Failed to configure trace stream\n");
+               acp_dsp_stream_put(sdev, stream);
                return ret;
        }
 
-       params->buffer.phy_addr = stream->reg_offset;
-       params->stream_tag = stream->stream_tag;
-
-       return 0;
-}
-
-int acp_sof_trace_init(struct snd_sof_dev *sdev, u32 *stream_tag)
-{
-       struct sof_ipc_dma_trace_params_ext *params;
-       struct acp_dsp_stream *stream;
-       struct acp_dev_data *adata;
-       int ret;
-
-       adata = sdev->pdata->hw_pdata;
-       stream = acp_dsp_stream_get(sdev, ACP_LOGGER_STREAM);
-       if (!stream)
-               return -ENODEV;
-
        adata->dtrace_stream = stream;
-       params = container_of(stream_tag, struct sof_ipc_dma_trace_params_ext, stream_tag);
-       ret = acp_sof_trace_prepare(sdev, params);
-       if (ret < 0) {
-               acp_dsp_stream_put(sdev, stream);
-               return ret;
-       }
+       dtrace_params->stream_tag = stream->stream_tag;
+       dtrace_params->buffer.phy_addr = stream->reg_offset;
 
-       *stream_tag = stream->stream_tag;
        return 0;
 }
 EXPORT_SYMBOL_NS(acp_sof_trace_init, SND_SOC_SOF_AMD_COMMON);
index a2f8e42190663c3b1789b424c2d0f9a6dd048282..7ceb8bee0d8f49453e03578d5e588cbd7178dd6e 100644 (file)
@@ -210,7 +210,8 @@ extern const struct snd_sof_dsp_ops sof_renoir_ops;
 int snd_amd_acp_find_config(struct pci_dev *pci);
 
 /* Trace */
-int acp_sof_trace_init(struct snd_sof_dev *sdev, u32 *stream_tag);
+int acp_sof_trace_init(struct snd_sof_dev *sdev,
+                      struct sof_ipc_dma_trace_params_ext *dtrace_params);
 int acp_sof_trace_release(struct snd_sof_dev *sdev);
 
 struct sof_amd_acp_desc {
index c5dc833b57b8fc97dd0dd3fcd8bafa8a06ce51b1..1791ec045a54a5bae972f11e194f9fd362a1fb2f 100644 (file)
@@ -36,7 +36,8 @@ static int hda_dsp_trace_prepare(struct snd_sof_dev *sdev, struct snd_dma_buffer
        return ret;
 }
 
-int hda_dsp_trace_init(struct snd_sof_dev *sdev, u32 *stream_tag)
+int hda_dsp_trace_init(struct snd_sof_dev *sdev,
+                      struct sof_ipc_dma_trace_params_ext *dtrace_params)
 {
        struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
        int ret;
@@ -50,7 +51,7 @@ int hda_dsp_trace_init(struct snd_sof_dev *sdev, u32 *stream_tag)
                return -ENODEV;
        }
 
-       *stream_tag = hda->dtrace_stream->hstream.stream_tag;
+       dtrace_params->stream_tag = hda->dtrace_stream->hstream.stream_tag;
 
        /*
         * initialize capture stream, set BDL address and return corresponding
@@ -59,9 +60,10 @@ int hda_dsp_trace_init(struct snd_sof_dev *sdev, u32 *stream_tag)
        ret = hda_dsp_trace_prepare(sdev, &sdev->dmatb);
        if (ret < 0) {
                dev_err(sdev->dev, "error: hdac trace init failed: %d\n", ret);
-               hda_dsp_stream_put(sdev, SNDRV_PCM_STREAM_CAPTURE, *stream_tag);
+               hda_dsp_stream_put(sdev, SNDRV_PCM_STREAM_CAPTURE,
+                                  dtrace_params->stream_tag);
                hda->dtrace_stream = NULL;
-               *stream_tag = 0;
+               dtrace_params->stream_tag = 0;
        }
 
        return ret;
index 7838a998ea95541450d2a687c3f239d7eabad608..2390561906dd29e3ff3f412def067bb8abad6f1b 100644 (file)
@@ -670,7 +670,8 @@ static inline int hda_codec_i915_exit(struct snd_sof_dev *sdev) { return 0; }
 /*
  * Trace Control.
  */
-int hda_dsp_trace_init(struct snd_sof_dev *sdev, u32 *stream_tag);
+int hda_dsp_trace_init(struct snd_sof_dev *sdev,
+                      struct sof_ipc_dma_trace_params_ext *dtrace_params);
 int hda_dsp_trace_release(struct snd_sof_dev *sdev);
 int hda_dsp_trace_trigger(struct snd_sof_dev *sdev, int cmd);
 
index ffe7456e77139e5d53b2545936dc937fa7df74cf..1f84d30296cf41153c4a73dc4d3670abdcd29a6c 100644 (file)
@@ -369,10 +369,10 @@ static inline int snd_sof_dsp_send_msg(struct snd_sof_dev *sdev,
 
 /* host DMA trace */
 static inline int snd_sof_dma_trace_init(struct snd_sof_dev *sdev,
-                                        u32 *stream_tag)
+                                        struct sof_ipc_dma_trace_params_ext *dtrace_params)
 {
        if (sof_ops(sdev)->trace_init)
-               return sof_ops(sdev)->trace_init(sdev, stream_tag);
+               return sof_ops(sdev)->trace_init(sdev, dtrace_params);
 
        return 0;
 }
index 29bb56b7267ab69d453bcac935b36baeb6401b2f..e48402ce4bdbaf5af95114db1c9e3412c8ae65ae 100644 (file)
@@ -281,7 +281,7 @@ struct snd_sof_dsp_ops {
 
        /* host DMA trace initialization */
        int (*trace_init)(struct snd_sof_dev *sdev,
-                         u32 *stream_tag); /* optional */
+                         struct sof_ipc_dma_trace_params_ext *dtrace_params); /* optional */
        int (*trace_release)(struct snd_sof_dev *sdev); /* optional */
        int (*trace_trigger)(struct snd_sof_dev *sdev,
                             int cmd); /* optional */
index 9b505c4fe79459c0acb7a35d47d804acc2f05fd1..2335d0f06d4239dafe290e9be3c3b72ea2e56fad 100644 (file)
@@ -409,7 +409,7 @@ int snd_sof_init_trace_ipc(struct snd_sof_dev *sdev)
        sdev->host_offset = 0;
        sdev->dtrace_draining = false;
 
-       ret = snd_sof_dma_trace_init(sdev, &params.stream_tag);
+       ret = snd_sof_dma_trace_init(sdev, &params);
        if (ret < 0) {
                dev_err(sdev->dev,
                        "error: fail in snd_sof_dma_trace_init %d\n", ret);