Skip to content

Commit 4bc265f

Browse files
committed
ASoC: SOF: Convert the dma-trace support to SOF client
Add a new client driver for dma trace support and move all related code from core to the new client driver. The dma trace is supported and used on all existing platform (intel and i.MX), thus the new client driver is selected by all platforms to be built and the CONFIG_SND_SOC_SOF_DEBUG_ENABLE_FIRMWARE_TRACE is used as a default value for enable/disable the functionality. The new module supports overriding the default state with 'enable' module parameter. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent a6bfb4f commit 4bc265f

30 files changed

+913
-740
lines changed

sound/soc/sof/Kconfig

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ config SND_SOC_SOF_DEBUG_PROBES
6060
This option is not user-selectable but automagically handled by
6161
'select' statements at a higher level.
6262

63+
config SND_SOC_SOF_DEBUG_DMA_TRACE
64+
tristate
65+
select SND_SOC_SOF_CLIENT
66+
help
67+
This option enables the dma-trace feature that can be used to
68+
gather trace information in close to real time from firmware, backed
69+
by DMA.
70+
This option is not user-selectable but automagically handled by
71+
'select' statements at a higher level.
72+
6373
config SND_SOC_SOF_CLIENT
6474
tristate
6575
select AUXILIARY_BUS
@@ -188,8 +198,8 @@ config SND_SOC_SOF_DEBUG_ENABLE_FIRMWARE_TRACE
188198
bool "SOF enable firmware trace"
189199
help
190200
The firmware trace can be enabled either at build-time with
191-
this option, or dynamically by setting flags in the SOF core
192-
module parameter (similar to dynamic debug).
201+
this option, or dynamically by setting the 'enable' module parameter
202+
for the snd_sof_dma_trace module.
193203
If unsure, select "N".
194204

195205
config SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST

sound/soc/sof/Makefile

Lines changed: 3 additions & 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-$(CONFIG_SND_SOC_SOF_COMPRESS) += compress.o
@@ -12,6 +12,7 @@ snd-sof-of-objs := sof-of-dev.o
1212

1313
snd-sof-ipc-test-objs := sof-client-ipc-test.o
1414
snd-sof-probes-objs := sof-client-probes.o
15+
snd-sof-dma-trace-objs := sof-client-dma-trace.o
1516

1617
snd-sof-nocodec-objs := nocodec.o
1718

@@ -28,6 +29,7 @@ obj-$(CONFIG_SND_SOC_SOF_PCI_DEV) += snd-sof-pci.o
2829

2930
obj-$(CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST) += snd-sof-ipc-test.o
3031
obj-$(CONFIG_SND_SOC_SOF_DEBUG_PROBES) += snd-sof-probes.o
32+
obj-$(CONFIG_SND_SOC_SOF_DEBUG_DMA_TRACE) += snd-sof-dma-trace.o
3133

3234
obj-$(CONFIG_SND_SOC_SOF_INTEL_TOPLEVEL) += intel/
3335
obj-$(CONFIG_SND_SOC_SOF_IMX_TOPLEVEL) += imx/

sound/soc/sof/core.c

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -220,20 +220,8 @@ static int sof_probe_continue(struct snd_sof_dev *sdev)
220220
goto fw_run_err;
221221
}
222222

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-
}
223+
if (sof_core_debug & SOF_DBG_ENABLE_TRACE)
224+
dev_dbg(sdev->dev, "SOF_DBG_ENABLE_TRACE is no longer used\n");
237225

238226
/* hereafter all FW boot flows are for PM reasons */
239227
sdev->first_boot = false;
@@ -245,14 +233,14 @@ static int sof_probe_continue(struct snd_sof_dev *sdev)
245233
if (ret < 0) {
246234
dev_err(sdev->dev,
247235
"error: failed to register DSP DAI driver %d\n", ret);
248-
goto fw_trace_err;
236+
goto fw_run_err;
249237
}
250238

251239
ret = snd_sof_machine_register(sdev, plat_data);
252240
if (ret < 0) {
253241
dev_err(sdev->dev,
254242
"error: failed to register machine driver %d\n", ret);
255-
goto fw_trace_err;
243+
goto fw_run_err;
256244
}
257245

258246
ret = sof_register_clients(sdev);
@@ -278,8 +266,6 @@ static int sof_probe_continue(struct snd_sof_dev *sdev)
278266

279267
sof_machine_err:
280268
snd_sof_machine_unregister(sdev, plat_data);
281-
fw_trace_err:
282-
snd_sof_free_trace(sdev);
283269
fw_run_err:
284270
snd_sof_fw_unload(sdev);
285271
fw_load_err:
@@ -412,7 +398,6 @@ int snd_sof_device_remove(struct device *dev)
412398

413399
snd_sof_ipc_free(sdev);
414400
snd_sof_free_debug(sdev);
415-
snd_sof_free_trace(sdev);
416401
}
417402

418403
/*

sound/soc/sof/debug.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,5 @@ void snd_sof_handle_fw_exception(struct snd_sof_dev *sdev)
407407
/* dump vital information to the logs */
408408
snd_sof_ipc_dump(sdev);
409409
snd_sof_dsp_dbg_dump(sdev, SOF_DBG_DUMP_REGS | SOF_DBG_DUMP_MBOX);
410-
snd_sof_trace_notify_for_error(sdev);
411410
}
412411
EXPORT_SYMBOL(snd_sof_handle_fw_exception);

sound/soc/sof/imx/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ config SND_SOC_SOF_IMX_TOPLEVEL
44
bool "SOF support for NXP i.MX audio DSPs"
55
depends on ARM64|| COMPILE_TEST
66
depends on SND_SOC_SOF_OF
7+
select SND_SOC_SOF_DEBUG_DMA_TRACE
78
help
89
This adds support for Sound Open Firmware for NXP i.MX platforms.
910
Say Y if you have such a device.

sound/soc/sof/imx/imx-common.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <linux/module.h>
88
#include <sound/sof/xtensa.h>
99
#include "../ops.h"
10+
#include "../sof-client-dma-trace.h"
1011

1112
#include "imx-common.h"
1213

@@ -74,4 +75,17 @@ void imx8_dump(struct snd_sof_dev *sdev, u32 flags)
7475
}
7576
EXPORT_SYMBOL(imx8_dump);
7677

78+
int imx8_dma_trace_register(struct snd_sof_dev *sdev)
79+
{
80+
return sof_client_dev_register(sdev, "imx8-dma-trace", 0, NULL, 0);
81+
}
82+
EXPORT_SYMBOL(imx8_dma_trace_register);
83+
84+
void imx8_dma_trace_unregister(struct snd_sof_dev *sdev)
85+
{
86+
sof_client_dev_unregister(sdev, "imx8-dma-trace", 0);
87+
}
88+
EXPORT_SYMBOL(imx8_dma_trace_unregister);
89+
90+
MODULE_IMPORT_NS(SND_SOC_SOF_CLIENT);
7791
MODULE_LICENSE("Dual BSD/GPL");

sound/soc/sof/imx/imx-common.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,7 @@ void imx8_get_registers(struct snd_sof_dev *sdev,
1313

1414
void imx8_dump(struct snd_sof_dev *sdev, u32 flags);
1515

16+
int imx8_dma_trace_register(struct snd_sof_dev *sdev);
17+
void imx8_dma_trace_unregister(struct snd_sof_dev *sdev);
18+
1619
#endif

sound/soc/sof/imx/imx8.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,10 @@ struct snd_sof_dsp_ops sof_imx8_ops = {
433433
/* firmware loading */
434434
.load_firmware = snd_sof_load_firmware_memcpy,
435435

436+
/* client ops */
437+
.register_ipc_clients = imx8_dma_trace_register,
438+
.unregister_ipc_clients = imx8_dma_trace_unregister,
439+
436440
/* Debug information */
437441
.dbg_dump = imx8_dump,
438442
.debugfs_add_region_item = snd_sof_debugfs_add_region_item_iomem,
@@ -488,6 +492,10 @@ struct snd_sof_dsp_ops sof_imx8x_ops = {
488492
/* firmware loading */
489493
.load_firmware = snd_sof_load_firmware_memcpy,
490494

495+
/* client ops */
496+
.register_ipc_clients = imx8_dma_trace_register,
497+
.unregister_ipc_clients = imx8_dma_trace_unregister,
498+
491499
/* Debug information */
492500
.dbg_dump = imx8_dump,
493501
.debugfs_add_region_item = snd_sof_debugfs_add_region_item_iomem,

sound/soc/sof/imx/imx8m.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,10 @@ struct snd_sof_dsp_ops sof_imx8m_ops = {
296296
/* firmware loading */
297297
.load_firmware = snd_sof_load_firmware_memcpy,
298298

299+
/* client ops */
300+
.register_ipc_clients = imx8_dma_trace_register,
301+
.unregister_ipc_clients = imx8_dma_trace_unregister,
302+
299303
/* Debug information */
300304
.dbg_dump = imx8_dump,
301305
.debugfs_add_region_item = snd_sof_debugfs_add_region_item_iomem,

sound/soc/sof/intel/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +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+
bool
20+
select SND_SOC_SOF_DEBUG_DMA_TRACE
21+
help
22+
This option is not user-selectable but following the higher level
23+
SND_SOC_SOF_DEBUG_ENABLE_FIRMWARE_TRACE option.
24+
1825
config SND_SOC_SOF_INTEL_ATOM_HIFI_EP
1926
tristate
2027
select SND_SOC_SOF_INTEL_COMMON
@@ -31,6 +38,7 @@ config SND_SOC_SOF_INTEL_COMMON
3138
select SND_SOC_INTEL_MACH
3239
select SND_SOC_ACPI if ACPI
3340
select SND_INTEL_DSP_CONFIG
41+
select SND_SOC_SOF_DEBUG_DMA_TRACE
3442
help
3543
This option is not user-selectable but automagically handled by
3644
'select' statements at a higher level.
@@ -216,6 +224,7 @@ config SND_SOC_SOF_HDA_COMMON
216224
select SND_INTEL_DSP_CONFIG
217225
select SND_SOC_SOF_HDA_LINK_BASELINE
218226
select SND_SOC_SOF_HDA_PROBES
227+
select SND_SOC_SOF_HDA_DMA_TRACE
219228
help
220229
This option is not user-selectable but automagically handled by
221230
'select' statements at a higher level.

0 commit comments

Comments
 (0)