Skip to content

Commit 050e5a7

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 38bb980 commit 050e5a7

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
4+
control.o iomem-utils.o sof-audio.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
@@ -199,25 +199,8 @@ static int sof_probe_continue(struct snd_sof_dev *sdev)
199199
goto fw_run_err;
200200
}
201201

202-
#if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_DMA_TRACE)
203-
/* trace support via SOF client */
204-
sdev->dtrace_is_supported = false;
205-
#else
206-
if (sof_core_debug & SOF_DBG_ENABLE_TRACE) {
207-
sdev->dtrace_is_supported = true;
208-
209-
/* init DMA trace */
210-
ret = snd_sof_init_trace(sdev);
211-
if (ret < 0) {
212-
/* non fatal */
213-
dev_warn(sdev->dev,
214-
"warning: failed to initialize trace %d\n",
215-
ret);
216-
}
217-
} else {
218-
dev_dbg(sdev->dev, "SOF firmware trace disabled\n");
219-
}
220-
#endif
202+
if (sof_core_debug & SOF_DBG_ENABLE_TRACE)
203+
dev_dbg(sdev->dev, "SOF_DBG_ENABLE_TRACE is no longer used\n");
221204

222205
/* hereafter all FW boot flows are for PM reasons */
223206
sdev->first_boot = false;
@@ -229,14 +212,14 @@ static int sof_probe_continue(struct snd_sof_dev *sdev)
229212
if (ret < 0) {
230213
dev_err(sdev->dev,
231214
"error: failed to register DSP DAI driver %d\n", ret);
232-
goto fw_trace_err;
215+
goto fw_run_err;
233216
}
234217

235218
ret = snd_sof_machine_register(sdev, plat_data);
236219
if (ret < 0) {
237220
dev_err(sdev->dev,
238221
"error: failed to register machine driver %d\n", ret);
239-
goto fw_trace_err;
222+
goto fw_run_err;
240223
}
241224

242225
ret = sof_register_clients(sdev);
@@ -262,8 +245,6 @@ static int sof_probe_continue(struct snd_sof_dev *sdev)
262245

263246
sof_machine_err:
264247
snd_sof_machine_unregister(sdev, plat_data);
265-
fw_trace_err:
266-
snd_sof_free_trace(sdev);
267248
fw_run_err:
268249
snd_sof_fw_unload(sdev);
269250
fw_load_err:
@@ -395,7 +376,6 @@ int snd_sof_device_remove(struct device *dev)
395376

396377
snd_sof_ipc_free(sdev);
397378
snd_sof_free_debug(sdev);
398-
snd_sof_free_trace(sdev);
399379
}
400380

401381
/*

sound/soc/sof/debug.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,6 @@ void snd_sof_handle_fw_exception(struct snd_sof_dev *sdev)
406406
/* dump vital information to the logs */
407407
snd_sof_ipc_dump(sdev);
408408
snd_sof_dsp_dbg_dump(sdev, SOF_DBG_DUMP_REGS | SOF_DBG_DUMP_MBOX);
409-
snd_sof_trace_notify_for_error(sdev);
410409
sof_client_dsp_panic_dispatcher(sdev);
411410
}
412411
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
@@ -9,8 +9,7 @@ snd-sof-intel-hda-common-objs := hda.o hda-loader.o hda-stream.o hda-dsp.o \
99
hda-ipc.o hda-ctrl.o hda-pcm.o hda-dai.o \
1010
hda-bus.o apl.o cnl.o tgl.o icl.o
1111
snd-sof-intel-hda-common-$(CONFIG_SND_SOC_SOF_HDA_PROBES) += hda-probes.o
12-
# snd-sof-intel-hda-common-$(CONFIG_SND_SOC_SOF_HDA_DMA_TRACE) += hda-trace.o
13-
snd-sof-intel-hda-common-objs += hda-trace.o
12+
snd-sof-intel-hda-common-$(CONFIG_SND_SOC_SOF_HDA_DMA_TRACE) += hda-trace.o
1413

1514
snd-sof-intel-hda-objs := hda-codec.o
1615

sound/soc/sof/intel/apl.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,6 @@ const struct snd_sof_dsp_ops sof_apl_ops = {
110110
.core_get = hda_dsp_core_get,
111111
.core_put = hda_dsp_core_put,
112112

113-
/* trace callback */
114-
.trace_init = hda_dsp_trace_init,
115-
.trace_release = hda_dsp_trace_release,
116-
.trace_trigger = hda_dsp_trace_trigger,
117-
118113
/* client ops */
119114
.register_ipc_clients = apl_register_clients,
120115
.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
@@ -315,11 +315,6 @@ const struct snd_sof_dsp_ops sof_cnl_ops = {
315315
/* firmware run */
316316
.run = hda_dsp_cl_boot_firmware,
317317

318-
/* trace callback */
319-
.trace_init = hda_dsp_trace_init,
320-
.trace_release = hda_dsp_trace_release,
321-
.trace_trigger = hda_dsp_trace_trigger,
322-
323318
/* client ops */
324319
.register_ipc_clients = cnl_register_clients,
325320
.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
@@ -640,13 +640,6 @@ static inline int hda_codec_i915_exit(struct snd_sof_dev *sdev) { return 0; }
640640

641641
#endif
642642

643-
/*
644-
* Trace Control.
645-
*/
646-
int hda_dsp_trace_init(struct snd_sof_dev *sdev, u32 *stream_tag);
647-
int hda_dsp_trace_release(struct snd_sof_dev *sdev);
648-
int hda_dsp_trace_trigger(struct snd_sof_dev *sdev, int cmd);
649-
650643
/*
651644
* SoundWire support
652645
*/

0 commit comments

Comments
 (0)