Skip to content

Commit e8bab41

Browse files
committed
ASoC: SOF: Switch to the client driver for dma-trace support
Switch to the SOF client version of the dma-trace. In order to not introduce regression the SND_SOC_SOF_DEBUG_ENABLE_FIRMWARE_TRACE is used to enable the new driver. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent 9e6b984 commit e8bab41

18 files changed

Lines changed: 41 additions & 794 deletions

File tree

sound/soc/sof/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
22

33
snd-sof-objs := core.o ops.o loader.o ipc.o pcm.o pm.o debug.o topology.o\
4-
control.o trace.o iomem-utils.o sof-audio.o stream-ipc.o
4+
control.o iomem-utils.o sof-audio.o stream-ipc.o
55
snd-sof-$(CONFIG_SND_SOC_SOF_CLIENT) += sof-client.o
66

77
snd-sof-pci-objs := sof-pci-dev.o

sound/soc/sof/core.c

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -216,25 +216,8 @@ static int sof_probe_continue(struct snd_sof_dev *sdev)
216216
goto fw_run_err;
217217
}
218218

219-
#if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_DMA_TRACE)
220-
/* trace support via SOF client */
221-
sdev->dtrace_is_supported = false;
222-
#else
223-
if (sof_core_debug & SOF_DBG_ENABLE_TRACE) {
224-
sdev->dtrace_is_supported = true;
225-
226-
/* init DMA trace */
227-
ret = snd_sof_init_trace(sdev);
228-
if (ret < 0) {
229-
/* non fatal */
230-
dev_warn(sdev->dev,
231-
"warning: failed to initialize trace %d\n",
232-
ret);
233-
}
234-
} else {
235-
dev_dbg(sdev->dev, "SOF firmware trace disabled\n");
236-
}
237-
#endif
219+
if (sof_core_debug & SOF_DBG_ENABLE_TRACE)
220+
dev_dbg(sdev->dev, "SOF_DBG_ENABLE_TRACE is no longer used\n");
238221

239222
/* hereafter all FW boot flows are for PM reasons */
240223
sdev->first_boot = false;
@@ -246,14 +229,14 @@ static int sof_probe_continue(struct snd_sof_dev *sdev)
246229
if (ret < 0) {
247230
dev_err(sdev->dev,
248231
"error: failed to register DSP DAI driver %d\n", ret);
249-
goto fw_trace_err;
232+
goto fw_run_err;
250233
}
251234

252235
ret = snd_sof_machine_register(sdev, plat_data);
253236
if (ret < 0) {
254237
dev_err(sdev->dev,
255238
"error: failed to register machine driver %d\n", ret);
256-
goto fw_trace_err;
239+
goto fw_run_err;
257240
}
258241

259242
ret = sof_register_clients(sdev);
@@ -279,8 +262,6 @@ static int sof_probe_continue(struct snd_sof_dev *sdev)
279262

280263
sof_machine_err:
281264
snd_sof_machine_unregister(sdev, plat_data);
282-
fw_trace_err:
283-
snd_sof_free_trace(sdev);
284265
fw_run_err:
285266
snd_sof_fw_unload(sdev);
286267
fw_load_err:
@@ -413,7 +394,6 @@ int snd_sof_device_remove(struct device *dev)
413394

414395
snd_sof_ipc_free(sdev);
415396
snd_sof_free_debug(sdev);
416-
snd_sof_free_trace(sdev);
417397
}
418398

419399
/*

sound/soc/sof/debug.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,5 @@ void snd_sof_handle_fw_exception(struct snd_sof_dev *sdev)
408408
snd_sof_ipc_dump(sdev);
409409
snd_sof_dsp_dbg_dump(sdev, SOF_DBG_DUMP_REGS | SOF_DBG_DUMP_MBOX);
410410
sof_set_fw_state(sdev, SOF_FW_CRASHED);
411-
snd_sof_trace_notify_for_error(sdev);
412411
}
413412
EXPORT_SYMBOL(snd_sof_handle_fw_exception);

sound/soc/sof/intel/Kconfig

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,13 @@ config SND_SOC_SOF_INTEL_HIFI_EP_IPC
1515
This option is not user-selectable but automagically handled by
1616
'select' statements at a higher level.
1717

18-
#config SND_SOC_SOF_HDA_DMA_TRACE
19-
# tristate
20-
# select SND_SOC_SOF_DEBUG_DMA_TRACE
21-
# help
22-
# This option is not user-selectable but automagically handled by
23-
# 'select' statements at a higher level.
24-
2518
config SND_SOC_SOF_HDA_DMA_TRACE
26-
bool "Enable dma-trace for HDA"
19+
bool
20+
default SND_SOC_SOF_DEBUG_ENABLE_FIRMWARE_TRACE
2721
select SND_SOC_SOF_DEBUG_DMA_TRACE
2822
help
29-
This option is not user-selectable but automagically handled by
30-
'select' statements at a higher level.
23+
This option is not user-selectable but following the higher level
24+
SND_SOC_SOF_DEBUG_ENABLE_FIRMWARE_TRACE option.
3125

3226
config SND_SOC_SOF_INTEL_ATOM_HIFI_EP
3327
tristate
@@ -45,7 +39,6 @@ config SND_SOC_SOF_INTEL_COMMON
4539
select SND_SOC_INTEL_MACH
4640
select SND_SOC_ACPI if ACPI
4741
select SND_INTEL_DSP_CONFIG
48-
# select SND_SOC_SOF_HDA_DMA_TRACE
4942
help
5043
This option is not user-selectable but automagically handled by
5144
'select' statements at a higher level.

sound/soc/sof/intel/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ snd-sof-intel-hda-common-objs := hda.o hda-loader.o hda-stream.o hda-dsp.o \
77
hda-ipc.o hda-ctrl.o hda-pcm.o hda-dai.o \
88
hda-bus.o apl.o cnl.o tgl.o icl.o
99
snd-sof-intel-hda-common-$(CONFIG_SND_SOC_SOF_HDA_PROBES) += hda-probes.o
10-
# snd-sof-intel-hda-common-$(CONFIG_SND_SOC_SOF_HDA_DMA_TRACE) += hda-trace.o
11-
snd-sof-intel-hda-common-objs += hda-trace.o
10+
snd-sof-intel-hda-common-$(CONFIG_SND_SOC_SOF_HDA_DMA_TRACE) += hda-trace.o
1211

1312
snd-sof-intel-hda-objs := hda-codec.o
1413

sound/soc/sof/intel/apl.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,6 @@ const struct snd_sof_dsp_ops sof_apl_ops = {
114114
.core_get = hda_dsp_core_get,
115115
.core_put = hda_dsp_core_put,
116116

117-
/* trace callback */
118-
.trace_init = hda_dsp_trace_init,
119-
.trace_release = hda_dsp_trace_release,
120-
.trace_trigger = hda_dsp_trace_trigger,
121-
122117
/* client ops */
123118
.register_ipc_clients = apl_register_clients,
124119
.unregister_ipc_clients = apl_unregister_clients,

sound/soc/sof/intel/cnl.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,6 @@ const struct snd_sof_dsp_ops sof_cnl_ops = {
319319
/* firmware run */
320320
.run = hda_dsp_cl_boot_firmware,
321321

322-
/* trace callback */
323-
.trace_init = hda_dsp_trace_init,
324-
.trace_release = hda_dsp_trace_release,
325-
.trace_trigger = hda_dsp_trace_trigger,
326-
327322
/* client ops */
328323
.register_ipc_clients = cnl_register_clients,
329324
.unregister_ipc_clients = cnl_unregister_clients,

sound/soc/sof/intel/hda-dsp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ static int hda_dsp_set_D0_state(struct snd_sof_dev *sdev,
433433
* when the DSP enters D0I3 while the system is in S0
434434
* for debug purpose.
435435
*/
436-
if (!sdev->dtrace_is_supported ||
436+
if (!sdev->dtrace_is_available ||
437437
!hda_enable_trace_D0I3_S0 ||
438438
sdev->system_suspend_target != SOF_SUSPEND_NONE)
439439
flags = HDA_PM_NO_DMA_TRACE;

sound/soc/sof/intel/hda-trace.c

Lines changed: 27 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,23 @@ static int hda_dsp_trace_prepare(struct snd_sof_dev *sdev, struct snd_dma_buffer
3333

3434
ret = hda_dsp_stream_hw_params(sdev, stream, dmab, NULL);
3535
if (ret < 0)
36-
dev_err(sdev->dev, "error: hdac prepare failed: %d\n", ret);
36+
dev_err(sdev->dev, "hdac prepare failed: %d\n", ret);
3737

3838
return ret;
3939
}
4040

41-
int hda_dsp_trace_init(struct snd_sof_dev *sdev, u32 *stream_tag)
41+
static int hda_dma_trace_init(struct sof_client_dev *cdev,
42+
struct snd_dma_buffer *dmab, u32 *stream_tag)
4243
{
44+
struct snd_sof_dev *sdev = sof_client_dev_to_sof_dev(cdev);
4345
struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
4446
int ret;
4547

4648
hda->dtrace_stream = hda_dsp_stream_get(sdev, SNDRV_PCM_STREAM_CAPTURE,
4749
SOF_HDA_STREAM_DMI_L1_COMPATIBLE);
4850

4951
if (!hda->dtrace_stream) {
50-
dev_err(sdev->dev,
51-
"error: no available capture stream for DMA trace\n");
52+
dev_err(sdev->dev, "no available capture stream for DMA trace\n");
5253
return -ENODEV;
5354
}
5455

@@ -58,9 +59,9 @@ int hda_dsp_trace_init(struct snd_sof_dev *sdev, u32 *stream_tag)
5859
* initialize capture stream, set BDL address and return corresponding
5960
* stream tag which will be sent to the firmware by IPC message.
6061
*/
61-
ret = hda_dsp_trace_prepare(sdev, &sdev->dmatb);
62+
ret = hda_dsp_trace_prepare(sdev, dmab);
6263
if (ret < 0) {
63-
dev_err(sdev->dev, "error: hdac trace init failed: %d\n", ret);
64+
dev_err(sdev->dev, "hdac trace init failed: %d\n", ret);
6465
hda_dsp_stream_put(sdev, SNDRV_PCM_STREAM_CAPTURE, *stream_tag);
6566
hda->dtrace_stream = NULL;
6667
*stream_tag = 0;
@@ -69,91 +70,57 @@ int hda_dsp_trace_init(struct snd_sof_dev *sdev, u32 *stream_tag)
6970
return ret;
7071
}
7172

72-
int hda_dsp_trace_release(struct snd_sof_dev *sdev)
73-
{
74-
struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
75-
struct hdac_stream *hstream;
76-
77-
if (hda->dtrace_stream) {
78-
hstream = &hda->dtrace_stream->hstream;
79-
hda_dsp_stream_put(sdev,
80-
SNDRV_PCM_STREAM_CAPTURE,
81-
hstream->stream_tag);
82-
hda->dtrace_stream = NULL;
83-
return 0;
84-
}
85-
86-
dev_dbg(sdev->dev, "DMA trace stream is not opened!\n");
87-
return -ENODEV;
88-
}
89-
90-
int hda_dsp_trace_trigger(struct snd_sof_dev *sdev, int cmd)
91-
{
92-
struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
93-
94-
return hda_dsp_stream_trigger(sdev, hda->dtrace_stream, cmd);
95-
}
96-
97-
#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_DMA_TRACE)
98-
static int hda_dma_trace_init(struct sof_client_dev *cdev,
99-
struct snd_dma_buffer *dmab, u32 *stream_tag)
73+
static int hda_dma_trace_release(struct sof_client_dev *cdev)
10074
{
10175
struct snd_sof_dev *sdev = sof_client_dev_to_sof_dev(cdev);
10276
struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
103-
int ret;
104-
105-
hda->dtrace_stream = hda_dsp_stream_get(sdev, SNDRV_PCM_STREAM_CAPTURE,
106-
SOF_HDA_STREAM_DMI_L1_COMPATIBLE);
77+
struct hdac_stream *hstream;
10778

10879
if (!hda->dtrace_stream) {
109-
dev_err(sdev->dev,
110-
"error: no available capture stream for DMA trace\n");
80+
dev_dbg(sdev->dev, "DMA trace stream is not opened!\n");
11181
return -ENODEV;
11282
}
11383

114-
*stream_tag = hda->dtrace_stream->hstream.stream_tag;
115-
116-
/*
117-
* initialize capture stream, set BDL address and return corresponding
118-
* stream tag which will be sent to the firmware by IPC message.
119-
*/
120-
ret = hda_dsp_trace_prepare(sdev, dmab);
121-
if (ret < 0) {
122-
dev_err(sdev->dev, "error: hdac trace init failed: %d\n", ret);
123-
hda_dsp_stream_put(sdev, SNDRV_PCM_STREAM_CAPTURE, *stream_tag);
124-
hda->dtrace_stream = NULL;
125-
*stream_tag = 0;
126-
}
84+
hstream = &hda->dtrace_stream->hstream;
85+
hda_dsp_stream_put(sdev, SNDRV_PCM_STREAM_CAPTURE, hstream->stream_tag);
86+
hda->dtrace_stream = NULL;
12787

128-
return ret;
88+
return 0;
12989
}
13090

131-
static int hda_dma_trace_release(struct sof_client_dev *cdev)
91+
static int hda_dsp_trace_trigger(struct sof_client_dev *cdev, int cmd)
13292
{
13393
struct snd_sof_dev *sdev = sof_client_dev_to_sof_dev(cdev);
94+
struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
13495

135-
return hda_dsp_trace_release(sdev);
96+
return hda_dsp_stream_trigger(sdev, hda->dtrace_stream, cmd);
13697
}
13798

13899
static int hda_dma_trace_start(struct sof_client_dev *cdev)
139100
{
140-
struct snd_sof_dev *sdev = sof_client_dev_to_sof_dev(cdev);
141-
142-
return hda_dsp_trace_trigger(sdev, SNDRV_PCM_TRIGGER_START);
101+
return hda_dsp_trace_trigger(cdev, SNDRV_PCM_TRIGGER_START);
143102
}
144103

145104
static int hda_dma_trace_stop(struct sof_client_dev *cdev)
105+
{
106+
return hda_dsp_trace_trigger(cdev, SNDRV_PCM_TRIGGER_STOP);
107+
}
108+
109+
static void hda_dma_trace_is_available(struct sof_client_dev *cdev,
110+
bool available)
146111
{
147112
struct snd_sof_dev *sdev = sof_client_dev_to_sof_dev(cdev);
148113

149-
return hda_dsp_trace_trigger(sdev, SNDRV_PCM_TRIGGER_STOP);
114+
sdev->dtrace_is_available = available;
150115
}
151116

152117
static const struct sof_dma_trace_host_ops hda_dma_trace_ops = {
153118
.init = hda_dma_trace_init,
154119
.release = hda_dma_trace_release,
155120
.start = hda_dma_trace_start,
156121
.stop = hda_dma_trace_stop,
122+
123+
.available = hda_dma_trace_is_available,
157124
};
158125

159126
int hda_dma_trace_register(struct snd_sof_dev *sdev)
@@ -168,4 +135,3 @@ void hda_dma_trace_unregister(struct snd_sof_dev *sdev)
168135
}
169136

170137
MODULE_IMPORT_NS(SND_SOC_SOF_CLIENT);
171-
#endif

sound/soc/sof/intel/hda.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -638,13 +638,6 @@ static inline int hda_codec_i915_exit(struct snd_sof_dev *sdev) { return 0; }
638638

639639
#endif
640640

641-
/*
642-
* Trace Control.
643-
*/
644-
int hda_dsp_trace_init(struct snd_sof_dev *sdev, u32 *stream_tag);
645-
int hda_dsp_trace_release(struct snd_sof_dev *sdev);
646-
int hda_dsp_trace_trigger(struct snd_sof_dev *sdev, int cmd);
647-
648641
/*
649642
* SoundWire support
650643
*/

0 commit comments

Comments
 (0)