Unverified Commit c3e15498 authored by Peter Ujfalusi's avatar Peter Ujfalusi Committed by Mark Brown
Browse files

ASoC: SOF: Add support for on-demand DSP boot



On system suspend / resume we always power up the DSP and boot the
firmware, which is not strictly needed as right after the firmware booted
up we power the DSP down again on suspend and we also power it down after
resume after some inactivity.

Out of caution, add a new platform descriptor flag to enable on-demand
DSP boot since this might not work without changes to platform code on
certain platforms.

With the on-demand dsp boot enabled we will not boot the DSP and firmware
up on system or rpm resume, just enable audio subsystem since audio IPs,
like HDA and SoundWire might be needed (codecs suspend/resume operation).
Only boot up the DSP during the first hw_params() call when the DSP is
really going to be needed.

In this way we can handle the audio related use cases:
normal audio use (rpm suspend/resume)
system suspend/resume without active audio
system suspend/resume with active audio
system suspend/resume without active audio, and audio start before the rpm
suspend timeout

Add module option to force the on-demand DSP boot to allow it to be
disabled or enabled without kernel change for testing.

Signed-off-by: default avatarPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: default avatarKai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: default avatarLiam Girdwood <liam.r.girdwood@intel.com>
Link: https://patch.msgid.link/20251215132946.2155-4-peter.ujfalusi@linux.intel.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 2c77ff20
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -159,6 +159,9 @@ struct sof_dev_desc {
	/* The platform supports DSPless mode */
	bool dspless_mode_supported;

	/* On demand DSP booting is possible on the platform */
	bool on_demand_dsp_boot;

	/* defaults paths for firmware, library and topology files */
	const char *default_fw_path[SOF_IPC_TYPE_COUNT];
	const char *default_lib_path[SOF_IPC_TYPE_COUNT];
+8 −0
Original line number Diff line number Diff line
@@ -195,6 +195,14 @@ static int sof_compr_set_params(struct snd_soc_component *component,
	if (sizeof(*pcm) + ext_data_size > sdev->ipc->max_payload_size)
		return -EINVAL;

	/*
	 * Make sure that the DSP is booted up, which might not be the
	 * case if the on-demand DSP boot is used
	 */
	ret = snd_sof_boot_dsp_firmware(sdev);
	if (ret)
		return ret;

	pcm = kzalloc(sizeof(*pcm) + ext_data_size, GFP_KERNEL);
	if (!pcm)
		return -ENOMEM;
+6 −1
Original line number Diff line number Diff line
@@ -198,7 +198,12 @@ int snd_sof_bytes_ext_volatile_get(struct snd_kcontrol *kcontrol, unsigned int _
		return ret;
	}

	ret = tplg_ops->control->bytes_ext_volatile_get(scontrol, binary_data, size);
	/* Make sure the DSP/firmware is booted up */
	ret = snd_sof_boot_dsp_firmware(sdev);
	if (!ret)
		ret = tplg_ops->control->bytes_ext_volatile_get(scontrol,
								binary_data,
								size);

	err = pm_runtime_put_autosuspend(scomp->dev);
	if (err < 0)
+1 −0
Original line number Diff line number Diff line
@@ -680,6 +680,7 @@ int snd_sof_device_probe(struct device *dev, struct snd_sof_pdata *plat_data)
	mutex_init(&sdev->power_state_access);
	mutex_init(&sdev->ipc_client_mutex);
	mutex_init(&sdev->client_event_handler_mutex);
	mutex_init(&sdev->dsp_fw_boot_mutex);

	/* set default timeouts if none provided */
	if (plat_data->desc->ipc_timeout == 0)
+6 −1
Original line number Diff line number Diff line
@@ -216,7 +216,12 @@ static int memory_info_update(struct snd_sof_dev *sdev, char *buf, size_t buff_s
		goto error;
	}

	ret = sof_ipc_tx_message(sdev->ipc, &msg, msg.size, reply, SOF_IPC_MSG_MAX_SIZE);
	/* Make sure the DSP/firmware is booted up */
	ret = snd_sof_boot_dsp_firmware(sdev);
	if (!ret)
		ret = sof_ipc_tx_message(sdev->ipc, &msg, msg.size, reply,
					 SOF_IPC_MSG_MAX_SIZE);

	pm_runtime_put_autosuspend(sdev->dev);
	if (ret < 0 || reply->rhdr.error < 0) {
		ret = min(ret, reply->rhdr.error);
Loading