Unverified Commit dab6b6f5 authored by Mark Brown's avatar Mark Brown
Browse files

ASoC: SOF: Support for on-demand DSP boot

Merge series from Peter Ujfalusi <peter.ujfalusi@linux.intel.com>:

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.

Similarly, on jack insert/removal we needlesly boot up the firmware to check
the jack status, which needs no DSP/firmware communication.

The on-demand DSP boot will make sure that we boot the DSP firmware up only
when it is needed - for audio activity, in other cases the firmware will be
not booted up, which saves time.

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.

The on-demand boot has been tested in our CI for more than half a year
and so far no issues have been seen on supported platforms since it's
introduction to our development tree (sof-dev).
parents 524ee559 f25c7d70
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;
+11 −2
Original line number Diff line number Diff line
@@ -187,14 +187,23 @@ int snd_sof_bytes_ext_volatile_get(struct snd_kcontrol *kcontrol, unsigned int _
	const struct sof_ipc_tplg_ops *tplg_ops = sof_ipc_get_ops(sdev, tplg);
	int ret, err;

	/* ignore the ext_volatile_get call if the callbacks are not provided */
	if (!tplg_ops || !tplg_ops->control ||
	    !tplg_ops->control->bytes_ext_volatile_get)
		return 0;

	ret = pm_runtime_resume_and_get(scomp->dev);
	if (ret < 0 && ret != -EACCES) {
		dev_err_ratelimited(scomp->dev, "%s: failed to resume %d\n", __func__, ret);
		return ret;
	}

	if (tplg_ops && tplg_ops->control && tplg_ops->control->bytes_ext_volatile_get)
		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