sound/soc/sof/pm.c

Source file repositories/reference/linux-study-clean/sound/soc/sof/pm.c

File Facts

System
Linux kernel
Corpus path
sound/soc/sof/pm.c
Extension
.c
Size
11077 bytes
Lines
427
Domain
Driver Families
Bucket
sound/soc
Inferred role
Driver Families: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (ret < 0) {
			dev_err(sdev->dev, "%s: failed to restore pipeline: %d\n",
				__func__, ret);
			goto setup_fail;
		}
	}

	/* Notify clients not managed by pm framework about core resume */
	sof_resume_clients(sdev);

	/* notify DSP of system resume */
	if (pm_ops && pm_ops->ctx_restore) {
		ret = pm_ops->ctx_restore(sdev);
		if (ret < 0)
			dev_err(sdev->dev, "%s: ctx_restore IPC failed: %d\n",
				__func__, ret);
	}

setup_fail:
#if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_ENABLE_DEBUGFS_CACHE)
	if (ret < 0) {
		/*
		 * Debugfs cannot be read in runtime suspend, so cache
		 * the contents upon failure. This allows to capture
		 * possible DSP coredump information.
		 */
		sof_cache_debugfs(sdev);
	}
#endif

	return ret;
}
EXPORT_SYMBOL(snd_sof_boot_dsp_firmware);

static int sof_resume(struct device *dev, bool runtime_resume)
{
	struct snd_sof_dev *sdev = dev_get_drvdata(dev);
	u32 old_state = sdev->dsp_power_state.state;
	bool on_demand_boot;
	int ret;

	/* do nothing if dsp resume callbacks are not set */
	if (!runtime_resume && !sof_ops(sdev)->resume)
		return 0;

	if (runtime_resume && !sof_ops(sdev)->runtime_resume)
		return 0;

	/* DSP was never successfully started, nothing to resume */
	if (sdev->first_boot)
		return 0;

	/*
	 * if the runtime_resume flag is set, call the runtime_resume routine
	 * or else call the system resume routine
	 */
	if (runtime_resume)
		ret = snd_sof_dsp_runtime_resume(sdev);
	else
		ret = snd_sof_dsp_resume(sdev);
	if (ret < 0) {
		dev_err(sdev->dev,
			"error: failed to power up DSP after resume\n");
		return ret;
	}

	if (sdev->dspless_mode_selected) {
		sof_set_fw_state(sdev, SOF_DSPLESS_MODE);
		return 0;
	}

	/*
	 * Nothing further to be done for platforms that support the low power
	 * D0 substate. Resume trace and return when resuming from
	 * low-power D0 substate
	 */
	if (!runtime_resume && sof_ops(sdev)->set_power_state &&
	    old_state == SOF_DSP_PM_D0) {
		ret = sof_fw_trace_resume(sdev);
		if (ret < 0)
			/* non fatal */
			dev_warn(sdev->dev,
				 "failed to enable trace after resume %d\n", ret);
		return 0;
	}

	if (override_on_demand_boot > -1)
		on_demand_boot = override_on_demand_boot ? true : false;
	else
		on_demand_boot = sdev->pdata->desc->on_demand_dsp_boot;

Annotation

Implementation Notes