]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
ASoC: SOF: trace: move to opt-in with Kconfig and module parameter
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Fri, 27 Sep 2019 20:05:28 +0000 (15:05 -0500)
committerMark Brown <broonie@kernel.org>
Tue, 1 Oct 2019 17:34:06 +0000 (18:34 +0100)
In a number of debug cases, the DMA-based trace can add problems
(e.g. with HDaudio channel allocation). It also generates additional
traffic on the bus and if the DMA handling is unreliable will prevent
audio use-cases from working normally. Using the trace also requires
tools to be installed on the target.

The trace can be instead handled as dynamic debug. We can use a
Kconfig to force the trace to be enabled in all cases, or use a module
parameter to enable it on a need-basis, e.g. by setting "options
snd_sof sof_debug=0x1" in a /etc/modprobe.d file.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20190927200538.660-4-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/Kconfig
sound/soc/sof/core.c
sound/soc/sof/sof-priv.h
sound/soc/sof/trace.c

index bb8036ae567e6e39226857281e911d648d518672..cc592bcadae710c4a601aad50150463cb5e78578 100644 (file)
@@ -142,6 +142,14 @@ config SND_SOC_SOF_DEBUG_ENABLE_DEBUGFS_CACHE
          Say Y if you want to enable caching the memory windows.
          If unsure, select "N".
 
+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)
+         If unsure, select "N".
+
 config SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST
        bool "SOF enable IPC flood test"
        help
index 81f28f7ff1a0b0dc668ddcbfda9ff61346671af5..15167b8220ed91b71f627bdfc5fbb65e50d77e77 100644 (file)
 #include "sof-priv.h"
 #include "ops.h"
 
+/* see SOF_DBG_ flags */
+int sof_core_debug;
+module_param_named(sof_debug, sof_core_debug, int, 0444);
+MODULE_PARM_DESC(sof_debug, "SOF core debug options (0x0 all off)");
+
 /* SOF defaults if not provided by the platform in ms */
 #define TIMEOUT_DEFAULT_IPC_MS  500
 #define TIMEOUT_DEFAULT_BOOT_MS 2000
@@ -350,12 +355,20 @@ static int sof_probe_continue(struct snd_sof_dev *sdev)
                goto fw_run_err;
        }
 
-       /* 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);
+       if (IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_ENABLE_FIRMWARE_TRACE) ||
+           (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");
        }
 
        /* hereafter all FW boot flows are for PM reasons */
index 730f3259dd027bfc4a691a162011bc69f0ae1893..d5b1a4f895da309b7faaf0c4025f23a452d5b83c 100644 (file)
 #include <uapi/sound/sof/fw.h>
 
 /* debug flags */
-#define SOF_DBG_REGS   BIT(1)
-#define SOF_DBG_MBOX   BIT(2)
-#define SOF_DBG_TEXT   BIT(3)
-#define SOF_DBG_PCI    BIT(4)
+#define SOF_DBG_ENABLE_TRACE   BIT(0)
+#define SOF_DBG_REGS           BIT(1)
+#define SOF_DBG_MBOX           BIT(2)
+#define SOF_DBG_TEXT           BIT(3)
+#define SOF_DBG_PCI            BIT(4)
+
+/* global debug state set by SOF_DBG_ flags */
+extern int sof_core_debug;
 
 /* max BARs mmaped devices can use */
 #define SND_SOF_BARS   8
@@ -434,6 +438,7 @@ struct snd_sof_dev {
        int dma_trace_pages;
        wait_queue_head_t trace_sleep;
        u32 host_offset;
+       u32 dtrace_is_supported; /* set with Kconfig or module parameter */
        u32 dtrace_is_enabled;
        u32 dtrace_error;
        u32 dtrace_draining;
index 4c3cff031fd665aa862a9e2d22de891f41cf4563..b0e4556c8536a3487719e2c242a7e6a37828c76f 100644 (file)
@@ -162,6 +162,9 @@ int snd_sof_init_trace_ipc(struct snd_sof_dev *sdev)
        struct sof_ipc_reply ipc_reply;
        int ret;
 
+       if (!sdev->dtrace_is_supported)
+               return 0;
+
        if (sdev->dtrace_is_enabled || !sdev->dma_trace_pages)
                return -EINVAL;
 
@@ -222,6 +225,9 @@ int snd_sof_init_trace(struct snd_sof_dev *sdev)
 {
        int ret;
 
+       if (!sdev->dtrace_is_supported)
+               return 0;
+
        /* set false before start initialization */
        sdev->dtrace_is_enabled = false;
 
@@ -277,6 +283,9 @@ EXPORT_SYMBOL(snd_sof_init_trace);
 int snd_sof_trace_update_pos(struct snd_sof_dev *sdev,
                             struct sof_ipc_dma_trace_posn *posn)
 {
+       if (!sdev->dtrace_is_supported)
+               return 0;
+
        if (sdev->dtrace_is_enabled && sdev->host_offset != posn->host_offset) {
                sdev->host_offset = posn->host_offset;
                wake_up(&sdev->trace_sleep);
@@ -293,6 +302,9 @@ int snd_sof_trace_update_pos(struct snd_sof_dev *sdev,
 /* an error has occurred within the DSP that prevents further trace */
 void snd_sof_trace_notify_for_error(struct snd_sof_dev *sdev)
 {
+       if (!sdev->dtrace_is_supported)
+               return;
+
        if (sdev->dtrace_is_enabled) {
                dev_err(sdev->dev, "error: waking up any trace sleepers\n");
                sdev->dtrace_error = true;
@@ -305,7 +317,7 @@ void snd_sof_release_trace(struct snd_sof_dev *sdev)
 {
        int ret;
 
-       if (!sdev->dtrace_is_enabled)
+       if (!sdev->dtrace_is_supported || !sdev->dtrace_is_enabled)
                return;
 
        ret = snd_sof_dma_trace_trigger(sdev, SNDRV_PCM_TRIGGER_STOP);
@@ -326,6 +338,9 @@ EXPORT_SYMBOL(snd_sof_release_trace);
 
 void snd_sof_free_trace(struct snd_sof_dev *sdev)
 {
+       if (!sdev->dtrace_is_supported)
+               return;
+
        snd_sof_release_trace(sdev);
 
        snd_dma_free_pages(&sdev->dmatb);