Skip to content

Commit

Permalink
ASoC: SOF: Convert the dma-trace support to SOF client
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ujfalusi committed Sep 6, 2021
1 parent 33d1a12 commit 7e07fea
Show file tree
Hide file tree
Showing 30 changed files with 913 additions and 740 deletions.
14 changes: 12 additions & 2 deletions sound/soc/sof/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ config SND_SOC_SOF_DEBUG_PROBES
This option is not user-selectable but automagically handled by
'select' statements at a higher level.

config SND_SOC_SOF_DEBUG_DMA_TRACE
tristate
select SND_SOC_SOF_CLIENT
help
This option enables the dma-trace feature that can be used to
gather trace information in close to real time from firmware, backed
by DMA.
This option is not user-selectable but automagically handled by
'select' statements at a higher level.

config SND_SOC_SOF_CLIENT
tristate
select AUXILIARY_BUS
Expand Down Expand Up @@ -188,8 +198,8 @@ config SND_SOC_SOF_DEBUG_ENABLE_FIRMWARE_TRACE
bool "SOF enable firmware trace"
help
The firmware trace can be enabled either at build-time with
this option, or dynamically by setting flags in the SOF core
module parameter (similar to dynamic debug).
this option, or dynamically by setting the 'enable' module parameter
for the snd_sof_dma_trace module.
If unsure, select "N".

config SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST
Expand Down
4 changes: 3 additions & 1 deletion sound/soc/sof/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)

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

snd-sof-$(CONFIG_SND_SOC_SOF_COMPRESS) += compress.o
Expand All @@ -12,6 +12,7 @@ snd-sof-of-objs := sof-of-dev.o

snd-sof-ipc-test-objs := sof-client-ipc-test.o
snd-sof-probes-objs := sof-client-probes.o
snd-sof-dma-trace-objs := sof-client-dma-trace.o

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

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

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

obj-$(CONFIG_SND_SOC_SOF_INTEL_TOPLEVEL) += intel/
obj-$(CONFIG_SND_SOC_SOF_IMX_TOPLEVEL) += imx/
Expand Down
23 changes: 4 additions & 19 deletions sound/soc/sof/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,20 +220,8 @@ static int sof_probe_continue(struct snd_sof_dev *sdev)
goto fw_run_err;
}

if (sof_core_debug & SOF_DBG_ENABLE_TRACE) {
sdev->dtrace_is_supported = true;

/* init DMA trace */
ret = snd_sof_init_trace(sdev);
if (ret < 0) {
/* non fatal */
dev_warn(sdev->dev,
"warning: failed to initialize trace %d\n",
ret);
}
} else {
dev_dbg(sdev->dev, "SOF firmware trace disabled\n");
}
if (sof_core_debug & SOF_DBG_ENABLE_TRACE)
dev_dbg(sdev->dev, "SOF_DBG_ENABLE_TRACE is no longer used\n");

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

ret = snd_sof_machine_register(sdev, plat_data);
if (ret < 0) {
dev_err(sdev->dev,
"error: failed to register machine driver %d\n", ret);
goto fw_trace_err;
goto fw_run_err;
}

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

sof_machine_err:
snd_sof_machine_unregister(sdev, plat_data);
fw_trace_err:
snd_sof_free_trace(sdev);
fw_run_err:
snd_sof_fw_unload(sdev);
fw_load_err:
Expand Down Expand Up @@ -412,7 +398,6 @@ int snd_sof_device_remove(struct device *dev)

snd_sof_ipc_free(sdev);
snd_sof_free_debug(sdev);
snd_sof_free_trace(sdev);
}

/*
Expand Down
1 change: 0 additions & 1 deletion sound/soc/sof/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,5 @@ void snd_sof_handle_fw_exception(struct snd_sof_dev *sdev)
snd_sof_ipc_dump(sdev);
snd_sof_dsp_dbg_dump(sdev, SOF_DBG_DUMP_REGS | SOF_DBG_DUMP_MBOX);
sof_set_fw_state(sdev, SOF_FW_CRASHED);
snd_sof_trace_notify_for_error(sdev);
}
EXPORT_SYMBOL(snd_sof_handle_fw_exception);
1 change: 1 addition & 0 deletions sound/soc/sof/imx/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ config SND_SOC_SOF_IMX_TOPLEVEL
bool "SOF support for NXP i.MX audio DSPs"
depends on ARM64|| COMPILE_TEST
depends on SND_SOC_SOF_OF
select SND_SOC_SOF_DEBUG_DMA_TRACE
help
This adds support for Sound Open Firmware for NXP i.MX platforms.
Say Y if you have such a device.
Expand Down
14 changes: 14 additions & 0 deletions sound/soc/sof/imx/imx-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <linux/module.h>
#include <sound/sof/xtensa.h>
#include "../ops.h"
#include "../sof-client-dma-trace.h"

#include "imx-common.h"

Expand Down Expand Up @@ -74,4 +75,17 @@ void imx8_dump(struct snd_sof_dev *sdev, u32 flags)
}
EXPORT_SYMBOL(imx8_dump);

int imx8_dma_trace_register(struct snd_sof_dev *sdev)
{
return sof_client_dev_register(sdev, "imx8-dma-trace", 0, NULL, 0);
}
EXPORT_SYMBOL(imx8_dma_trace_register);

void imx8_dma_trace_unregister(struct snd_sof_dev *sdev)
{
sof_client_dev_unregister(sdev, "imx8-dma-trace", 0);
}
EXPORT_SYMBOL(imx8_dma_trace_unregister);

MODULE_IMPORT_NS(SND_SOC_SOF_CLIENT);
MODULE_LICENSE("Dual BSD/GPL");
3 changes: 3 additions & 0 deletions sound/soc/sof/imx/imx-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ void imx8_get_registers(struct snd_sof_dev *sdev,

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

int imx8_dma_trace_register(struct snd_sof_dev *sdev);
void imx8_dma_trace_unregister(struct snd_sof_dev *sdev);

#endif
8 changes: 8 additions & 0 deletions sound/soc/sof/imx/imx8.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,10 @@ struct snd_sof_dsp_ops sof_imx8_ops = {
/* firmware loading */
.load_firmware = snd_sof_load_firmware_memcpy,

/* client ops */
.register_ipc_clients = imx8_dma_trace_register,
.unregister_ipc_clients = imx8_dma_trace_unregister,

/* Debug information */
.dbg_dump = imx8_dump,
.debugfs_add_region_item = snd_sof_debugfs_add_region_item_iomem,
Expand Down Expand Up @@ -488,6 +492,10 @@ struct snd_sof_dsp_ops sof_imx8x_ops = {
/* firmware loading */
.load_firmware = snd_sof_load_firmware_memcpy,

/* client ops */
.register_ipc_clients = imx8_dma_trace_register,
.unregister_ipc_clients = imx8_dma_trace_unregister,

/* Debug information */
.dbg_dump = imx8_dump,
.debugfs_add_region_item = snd_sof_debugfs_add_region_item_iomem,
Expand Down
4 changes: 4 additions & 0 deletions sound/soc/sof/imx/imx8m.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ struct snd_sof_dsp_ops sof_imx8m_ops = {
/* firmware loading */
.load_firmware = snd_sof_load_firmware_memcpy,

/* client ops */
.register_ipc_clients = imx8_dma_trace_register,
.unregister_ipc_clients = imx8_dma_trace_unregister,

/* Debug information */
.dbg_dump = imx8_dump,
.debugfs_add_region_item = snd_sof_debugfs_add_region_item_iomem,
Expand Down
9 changes: 9 additions & 0 deletions sound/soc/sof/intel/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ config SND_SOC_SOF_INTEL_HIFI_EP_IPC
This option is not user-selectable but automagically handled by
'select' statements at a higher level.

config SND_SOC_SOF_HDA_DMA_TRACE
bool
select SND_SOC_SOF_DEBUG_DMA_TRACE
help
This option is not user-selectable but following the higher level
SND_SOC_SOF_DEBUG_ENABLE_FIRMWARE_TRACE option.

config SND_SOC_SOF_INTEL_ATOM_HIFI_EP
tristate
select SND_SOC_SOF_INTEL_COMMON
Expand All @@ -31,6 +38,7 @@ config SND_SOC_SOF_INTEL_COMMON
select SND_SOC_INTEL_MACH
select SND_SOC_ACPI if ACPI
select SND_INTEL_DSP_CONFIG
select SND_SOC_SOF_DEBUG_DMA_TRACE
help
This option is not user-selectable but automagically handled by
'select' statements at a higher level.
Expand Down Expand Up @@ -216,6 +224,7 @@ config SND_SOC_SOF_HDA_COMMON
select SND_INTEL_DSP_CONFIG
select SND_SOC_SOF_HDA_LINK_BASELINE
select SND_SOC_SOF_HDA_PROBES
select SND_SOC_SOF_HDA_DMA_TRACE
help
This option is not user-selectable but automagically handled by
'select' statements at a higher level.
Expand Down
8 changes: 4 additions & 4 deletions sound/soc/sof/intel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
snd-sof-acpi-intel-byt-objs := byt.o
snd-sof-acpi-intel-bdw-objs := bdw.o

snd-sof-intel-hda-common-objs := hda.o hda-loader.o hda-stream.o hda-trace.o \
hda-dsp.o hda-ipc.o hda-ctrl.o hda-pcm.o \
hda-dai.o hda-bus.o \
apl.o cnl.o tgl.o icl.o
snd-sof-intel-hda-common-objs := hda.o hda-loader.o hda-stream.o hda-dsp.o \
hda-ipc.o hda-ctrl.o hda-pcm.o hda-dai.o \
hda-bus.o apl.o cnl.o tgl.o icl.o
snd-sof-intel-hda-common-$(CONFIG_SND_SOC_SOF_HDA_PROBES) += hda-probes.o
snd-sof-intel-hda-common-$(CONFIG_SND_SOC_SOF_HDA_DMA_TRACE) += hda-trace.o

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

Expand Down
14 changes: 8 additions & 6 deletions sound/soc/sof/intel/apl.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,19 @@ static const struct snd_sof_debugfs_map apl_dsp_debugfs[] = {

static int apl_register_clients(struct snd_sof_dev *sdev)
{
return hda_probes_register(sdev);
int ret;

ret = hda_probes_register(sdev);
if (ret)
return ret;

return hda_dma_trace_register(sdev);
}

static void apl_unregister_clients(struct snd_sof_dev *sdev)
{
hda_probes_unregister(sdev);
hda_dma_trace_unregister(sdev);
}

/* apollolake ops */
Expand Down Expand Up @@ -107,11 +114,6 @@ const struct snd_sof_dsp_ops sof_apl_ops = {
.core_get = hda_dsp_core_get,
.core_put = hda_dsp_core_put,

/* trace callback */
.trace_init = hda_dsp_trace_init,
.trace_release = hda_dsp_trace_release,
.trace_trigger = hda_dsp_trace_trigger,

/* client ops */
.register_ipc_clients = apl_register_clients,
.unregister_ipc_clients = apl_unregister_clients,
Expand Down
14 changes: 14 additions & 0 deletions sound/soc/sof/intel/atom.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "atom.h"
#include "../sof-acpi-dev.h"
#include "../sof-audio.h"
#include "../sof-client-dma-trace.h"
#include "../../intel/common/soc-intel-quirks.h"

static void atom_host_done(struct snd_sof_dev *sdev);
Expand Down Expand Up @@ -457,4 +458,17 @@ void atom_set_mach_params(const struct snd_soc_acpi_mach *mach,
}
EXPORT_SYMBOL_NS(atom_set_mach_params, SND_SOC_SOF_INTEL_ATOM_HIFI_EP);

int atom_dma_trace_register(struct snd_sof_dev *sdev)
{
return sof_client_dev_register(sdev, "atom-dma-trace", 0, NULL, 0);
}
EXPORT_SYMBOL_NS(atom_dma_trace_register, SND_SOC_SOF_INTEL_ATOM_HIFI_EP);

void atom_dma_trace_unregister(struct snd_sof_dev *sdev)
{
sof_client_dev_unregister(sdev, "atom-dma-trace", 0);
}
EXPORT_SYMBOL_NS(atom_dma_trace_unregister, SND_SOC_SOF_INTEL_ATOM_HIFI_EP);

MODULE_IMPORT_NS(SND_SOC_SOF_CLIENT);
MODULE_LICENSE("Dual BSD/GPL");
3 changes: 3 additions & 0 deletions sound/soc/sof/intel/atom.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,7 @@ void atom_set_mach_params(const struct snd_soc_acpi_mach *mach,

extern struct snd_soc_dai_driver atom_dai[];

int atom_dma_trace_register(struct snd_sof_dev *sdev);
void atom_dma_trace_unregister(struct snd_sof_dev *sdev);

#endif
16 changes: 16 additions & 0 deletions sound/soc/sof/intel/bdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "shim.h"
#include "../sof-acpi-dev.h"
#include "../sof-audio.h"
#include "../sof-client-dma-trace.h"

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

static int bdw_dma_trace_register(struct snd_sof_dev *sdev)
{
return sof_client_dev_register(sdev, "bdw-dma-trace", 0, NULL, 0);
}

static void bdw_dma_trace_unregister(struct snd_sof_dev *sdev)
{
sof_client_dev_unregister(sdev, "bdw-dma-trace", 0);
}

/* Broadwell DAIs */
static struct snd_soc_dai_driver bdw_dai[] = {
{
Expand Down Expand Up @@ -660,6 +671,10 @@ static const struct snd_sof_dsp_ops sof_bdw_ops = {
/*Firmware loading */
.load_firmware = snd_sof_load_firmware_memcpy,

/* client ops */
.register_ipc_clients = bdw_dma_trace_register,
.unregister_ipc_clients = bdw_dma_trace_unregister,

/* DAI drivers */
.drv = bdw_dai,
.num_drv = ARRAY_SIZE(bdw_dai),
Expand Down Expand Up @@ -739,3 +754,4 @@ MODULE_LICENSE("Dual BSD/GPL");
MODULE_IMPORT_NS(SND_SOC_SOF_INTEL_HIFI_EP_IPC);
MODULE_IMPORT_NS(SND_SOC_SOF_XTENSA);
MODULE_IMPORT_NS(SND_SOC_SOF_ACPI_DEV);
MODULE_IMPORT_NS(SND_SOC_SOF_CLIENT);
8 changes: 8 additions & 0 deletions sound/soc/sof/intel/byt.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@ static const struct snd_sof_dsp_ops sof_byt_ops = {
.suspend = byt_suspend,
.resume = byt_resume,

/* client ops */
.register_ipc_clients = atom_dma_trace_register,
.unregister_ipc_clients = atom_dma_trace_unregister,

/* DAI drivers */
.drv = atom_dai,
.num_drv = 3, /* we have only 3 SSPs on byt*/
Expand Down Expand Up @@ -360,6 +364,10 @@ static const struct snd_sof_dsp_ops sof_cht_ops = {
.suspend = byt_suspend,
.resume = byt_resume,

/* client ops */
.register_ipc_clients = atom_dma_trace_register,
.unregister_ipc_clients = atom_dma_trace_unregister,

/* DAI drivers */
.drv = atom_dai,
/* all 6 SSPs may be available for cherrytrail */
Expand Down
Loading

0 comments on commit 7e07fea

Please sign in to comment.