Skip to content

Commit 39459f7

Browse files
committed
ASoC: SOF: Add optional SOF client for dma-trace support
Add a new client driver to implement the dma-trace functionality outside of the SOF core. This is optional for now, if the dma-trace client is enabled via the SND_SOC_SOF_HDA_DMA_TRACE kconfig option then the core's built in implementation is force disabled. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent 68d6c63 commit 39459f7

17 files changed

Lines changed: 870 additions & 8 deletions

File tree

sound/soc/sof/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ config SND_SOC_SOF_DEBUG_PROBES
5656
This option is not user-selectable but automagically handled by
5757
'select' statements at a higher level.
5858

59+
config SND_SOC_SOF_DEBUG_DMA_TRACE
60+
tristate
61+
select SND_SOC_SOF_CLIENT
62+
help
63+
This option enables the dma-trace feature that can be used to
64+
gather trace information in close to real time from firmware, backed
65+
by DMA.
66+
This option is not user-selectable but automagically handled by
67+
'select' statements at a higher level.
68+
5969
config SND_SOC_SOF_CLIENT
6070
tristate
6171
select AUXILIARY_BUS

sound/soc/sof/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ snd-sof-of-objs := sof-of-dev.o
1010

1111
snd-sof-ipc-test-objs := sof-client-ipc-test.o
1212
snd-sof-probes-objs := sof-client-probes.o
13+
snd-sof-dma-trace-objs := sof-client-dma-trace.o
1314

1415
snd-sof-nocodec-objs := nocodec.o
1516

@@ -26,6 +27,7 @@ obj-$(CONFIG_SND_SOC_SOF_PCI_DEV) += snd-sof-pci.o
2627

2728
obj-$(CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST) += snd-sof-ipc-test.o
2829
obj-$(CONFIG_SND_SOC_SOF_DEBUG_PROBES) += snd-sof-probes.o
30+
obj-$(CONFIG_SND_SOC_SOF_DEBUG_DMA_TRACE) += snd-sof-dma-trace.o
2931

3032
obj-$(CONFIG_SND_SOC_SOF_INTEL_TOPLEVEL) += intel/
3133
obj-$(CONFIG_SND_SOC_SOF_IMX_TOPLEVEL) += imx/

sound/soc/sof/core.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ 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
219223
if (sof_core_debug & SOF_DBG_ENABLE_TRACE) {
220224
sdev->dtrace_is_supported = true;
221225

@@ -230,6 +234,7 @@ static int sof_probe_continue(struct snd_sof_dev *sdev)
230234
} else {
231235
dev_dbg(sdev->dev, "SOF firmware trace disabled\n");
232236
}
237+
#endif
233238

234239
/* hereafter all FW boot flows are for PM reasons */
235240
sdev->first_boot = false;

sound/soc/sof/intel/Kconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,20 @@ 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+
25+
config SND_SOC_SOF_HDA_DMA_TRACE
26+
bool "Enable dma-trace for HDA"
27+
select SND_SOC_SOF_DEBUG_DMA_TRACE
28+
help
29+
This option is not user-selectable but automagically handled by
30+
'select' statements at a higher level.
31+
1832
config SND_SOC_SOF_INTEL_ATOM_HIFI_EP
1933
tristate
2034
select SND_SOC_SOF_INTEL_COMMON
@@ -31,6 +45,7 @@ config SND_SOC_SOF_INTEL_COMMON
3145
select SND_SOC_INTEL_MACH
3246
select SND_SOC_ACPI if ACPI
3347
select SND_INTEL_DSP_CONFIG
48+
# select SND_SOC_SOF_HDA_DMA_TRACE
3449
help
3550
This option is not user-selectable but automagically handled by
3651
'select' statements at a higher level.

sound/soc/sof/intel/Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
snd-sof-acpi-intel-byt-objs := byt.o
44
snd-sof-acpi-intel-bdw-objs := bdw.o
55

6-
snd-sof-intel-hda-common-objs := hda.o hda-loader.o hda-stream.o hda-trace.o \
7-
hda-dsp.o hda-ipc.o hda-ctrl.o hda-pcm.o \
8-
hda-dai.o hda-bus.o \
9-
apl.o cnl.o tgl.o icl.o
6+
snd-sof-intel-hda-common-objs := hda.o hda-loader.o hda-stream.o hda-dsp.o \
7+
hda-ipc.o hda-ctrl.o hda-pcm.o hda-dai.o \
8+
hda-bus.o apl.o cnl.o tgl.o icl.o
109
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
1112

1213
snd-sof-intel-hda-objs := hda-codec.o
1314

sound/soc/sof/intel/apl.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,19 @@ static const struct snd_sof_debugfs_map apl_dsp_debugfs[] = {
2727

2828
static int apl_register_clients(struct snd_sof_dev *sdev)
2929
{
30-
return hda_probes_register(sdev);
30+
int ret;
31+
32+
ret = hda_probes_register(sdev);
33+
if (ret)
34+
return ret;
35+
36+
return hda_dma_trace_register(sdev);
3137
}
3238

3339
static void apl_unregister_clients(struct snd_sof_dev *sdev)
3440
{
3541
hda_probes_unregister(sdev);
42+
hda_dma_trace_unregister(sdev);
3643
}
3744

3845
/* apollolake ops */

sound/soc/sof/intel/atom.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "atom.h"
2424
#include "../sof-acpi-dev.h"
2525
#include "../sof-audio.h"
26+
#include "../sof-client-dma-trace.h"
2627
#include "../../intel/common/soc-intel-quirks.h"
2728

2829
static void atom_host_done(struct snd_sof_dev *sdev);
@@ -457,4 +458,17 @@ void atom_set_mach_params(const struct snd_soc_acpi_mach *mach,
457458
}
458459
EXPORT_SYMBOL_NS(atom_set_mach_params, SND_SOC_SOF_INTEL_ATOM_HIFI_EP);
459460

461+
int atom_dma_trace_register(struct snd_sof_dev *sdev)
462+
{
463+
return sof_client_dev_register(sdev, "atom-dma-trace", 0, NULL, 0);
464+
}
465+
EXPORT_SYMBOL_NS(atom_dma_trace_register, SND_SOC_SOF_INTEL_ATOM_HIFI_EP);
466+
467+
void atom_dma_trace_unregister(struct snd_sof_dev *sdev)
468+
{
469+
sof_client_dev_unregister(sdev, "atom-dma-trace", 0);
470+
}
471+
EXPORT_SYMBOL_NS(atom_dma_trace_unregister, SND_SOC_SOF_INTEL_ATOM_HIFI_EP);
472+
473+
MODULE_IMPORT_NS(SND_SOC_SOF_CLIENT);
460474
MODULE_LICENSE("Dual BSD/GPL");

sound/soc/sof/intel/atom.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,7 @@ void atom_set_mach_params(const struct snd_soc_acpi_mach *mach,
7171

7272
extern struct snd_soc_dai_driver atom_dai[];
7373

74+
int atom_dma_trace_register(struct snd_sof_dev *sdev);
75+
void atom_dma_trace_unregister(struct snd_sof_dev *sdev);
76+
7477
#endif

sound/soc/sof/intel/bdw.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "shim.h"
2323
#include "../sof-acpi-dev.h"
2424
#include "../sof-audio.h"
25+
#include "../sof-client-dma-trace.h"
2526

2627
/* BARs */
2728
#define BDW_DSP_BAR 0
@@ -580,6 +581,16 @@ static void bdw_set_mach_params(const struct snd_soc_acpi_mach *mach,
580581
mach_params->dai_drivers = desc->ops->drv;
581582
}
582583

584+
static int bdw_dma_trace_register(struct snd_sof_dev *sdev)
585+
{
586+
return sof_client_dev_register(sdev, "bdw-dma-trace", 0, NULL, 0);
587+
}
588+
589+
static void bdw_dma_trace_unregister(struct snd_sof_dev *sdev)
590+
{
591+
sof_client_dev_unregister(sdev, "bdw-dma-trace", 0);
592+
}
593+
583594
/* Broadwell DAIs */
584595
static struct snd_soc_dai_driver bdw_dai[] = {
585596
{
@@ -660,6 +671,10 @@ static const struct snd_sof_dsp_ops sof_bdw_ops = {
660671
/*Firmware loading */
661672
.load_firmware = snd_sof_load_firmware_memcpy,
662673

674+
/* client ops */
675+
.register_ipc_clients = bdw_dma_trace_register,
676+
.unregister_ipc_clients = bdw_dma_trace_unregister,
677+
663678
/* DAI drivers */
664679
.drv = bdw_dai,
665680
.num_drv = ARRAY_SIZE(bdw_dai),
@@ -739,3 +754,4 @@ MODULE_LICENSE("Dual BSD/GPL");
739754
MODULE_IMPORT_NS(SND_SOC_SOF_INTEL_HIFI_EP_IPC);
740755
MODULE_IMPORT_NS(SND_SOC_SOF_XTENSA);
741756
MODULE_IMPORT_NS(SND_SOC_SOF_ACPI_DEV);
757+
MODULE_IMPORT_NS(SND_SOC_SOF_CLIENT);

sound/soc/sof/intel/byt.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,10 @@ static const struct snd_sof_dsp_ops sof_byt_ops = {
278278
.suspend = byt_suspend,
279279
.resume = byt_resume,
280280

281+
/* client ops */
282+
.register_ipc_clients = atom_dma_trace_register,
283+
.unregister_ipc_clients = atom_dma_trace_unregister,
284+
281285
/* DAI drivers */
282286
.drv = atom_dai,
283287
.num_drv = 3, /* we have only 3 SSPs on byt*/
@@ -360,6 +364,10 @@ static const struct snd_sof_dsp_ops sof_cht_ops = {
360364
.suspend = byt_suspend,
361365
.resume = byt_resume,
362366

367+
/* client ops */
368+
.register_ipc_clients = atom_dma_trace_register,
369+
.unregister_ipc_clients = atom_dma_trace_unregister,
370+
363371
/* DAI drivers */
364372
.drv = atom_dai,
365373
/* all 6 SSPs may be available for cherrytrail */

0 commit comments

Comments
 (0)