From f8b852fdd04f7148a31c0bbf1021b9b5ac8b349b Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 24 Sep 2024 12:15:35 +0300 Subject: [PATCH] ASoC: SOF: core: Add debug module parameters to set IPC and boot timeout Add two module parameters to override the IPC and boot timeout values if the SOF stack is compiled with debug enabled to allow experimenting with different timeout values without the need to recompile the kernel. Signed-off-by: Peter Ujfalusi --- sound/soc/sof/core.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c index aa83f9fb400e78..a4a699e9bdb383 100644 --- a/sound/soc/sof/core.c +++ b/sound/soc/sof/core.c @@ -24,6 +24,17 @@ static int sof_core_debug = IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_ENABLE_FIRMWARE module_param_named(sof_debug, sof_core_debug, int, 0444); MODULE_PARM_DESC(sof_debug, "SOF core debug options (0x0 all off)"); +#if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG) +static unsigned int sof_ipc_timeout_ms; +static unsigned int sof_boot_timeout_ms; +module_param_named(ipc_timeout, sof_ipc_timeout_ms, uint, 0444); +MODULE_PARM_DESC(ipc_timeout, + "Set the IPC timeout value in ms (0 to use the platform default)"); +module_param_named(boot_timeout, sof_boot_timeout_ms, uint, 0444); +MODULE_PARM_DESC(boot_timeout, + "Set the DSP boot timeout value in ms (0 to use the platform default)"); +#endif + /* SOF defaults if not provided by the platform in ms */ #define TIMEOUT_DEFAULT_IPC_MS 500 #define TIMEOUT_DEFAULT_BOOT_MS 2000 @@ -636,11 +647,23 @@ int snd_sof_device_probe(struct device *dev, struct snd_sof_pdata *plat_data) mutex_init(&sdev->ipc_client_mutex); mutex_init(&sdev->client_event_handler_mutex); - /* set default timeouts if none provided */ + /* set IPC timeout */ +#if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG) + if (sof_ipc_timeout_ms) + sdev->ipc_timeout = sof_ipc_timeout_ms; + else +#endif if (plat_data->desc->ipc_timeout == 0) sdev->ipc_timeout = TIMEOUT_DEFAULT_IPC_MS; else sdev->ipc_timeout = plat_data->desc->ipc_timeout; + + /* set DSP/firmware boot timeout */ +#if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG) + if (sof_boot_timeout_ms) + sdev->boot_timeout = sof_boot_timeout_ms; + else +#endif if (plat_data->desc->boot_timeout == 0) sdev->boot_timeout = TIMEOUT_DEFAULT_BOOT_MS; else