diff options
author | Ranjani Sridharan | 2020-01-29 16:07:22 -0600 |
---|---|---|
committer | Mark Brown | 2020-02-11 11:48:05 +0000 |
commit | 61e285caf40fef18e8bd7cea5237ee6723609a1c (patch) | |
tree | ce943de3d6321f55e73e42b91184d2c971becd4f /sound/soc/sof/pm.c | |
parent | 700d167739a099cdf12ed15c25fec7f4cb563d42 (diff) |
ASoC: SOF: Move DSP power state transitions to platform-specific ops
The DSP device substates such as D0I0/D0I3
are platform-specific. Therefore, the d0_substate
field of struct snd_sof_dev is replaced
with the dsp_power_state field which represents the current
state of the DSP. This field holds both the device state
and the platform-specific substate values.
With the DSP device substates being platform-specific,
the DSP power state transitions need to be performed in
the platform-specific suspend/resume ops as well.
In order to achieve this, the ops signature has to be
modified to pass the target device state as an
argument. The target substate will be determined by
the platform-specific ops before performing the transition.
For example, in the case of the system suspending to S0IX,
the top-level SOF device suspend callback needs to
only determine if the DSP will be entering
D3 or remain in D0. The target substate in case the device
needs to remain in D0 (D0I0 or D0I3) will be determined
by the platform-specific suspend op.
With the addition of the extended set of power states for the DSP,
the set_power_state op for HDA platforms has to be extended
to handle only the appropriate state transitions. So, the
implementation for the Intel HDA platforms is also modified.
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20200129220726.31792-6-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/sof/pm.c')
-rw-r--r-- | sound/soc/sof/pm.c | 92 |
1 files changed, 10 insertions, 82 deletions
diff --git a/sound/soc/sof/pm.c b/sound/soc/sof/pm.c index bec25cb6beec..c410822d9920 100644 --- a/sound/soc/sof/pm.c +++ b/sound/soc/sof/pm.c @@ -86,7 +86,7 @@ static void sof_cache_debugfs(struct snd_sof_dev *sdev) static int sof_resume(struct device *dev, bool runtime_resume) { struct snd_sof_dev *sdev = dev_get_drvdata(dev); - enum sof_d0_substate old_d0_substate = sdev->d0_substate; + u32 old_state = sdev->dsp_power_state.state; int ret; /* do nothing if dsp resume callbacks are not set */ @@ -97,17 +97,6 @@ static int sof_resume(struct device *dev, bool runtime_resume) if (sdev->first_boot) return 0; - /* resume from D0I3 */ - if (!runtime_resume && old_d0_substate == SOF_DSP_D0I3) { - ret = snd_sof_set_d0_substate(sdev, SOF_DSP_D0I0); - if (ret < 0 && ret != -ENOTSUPP) { - dev_err(sdev->dev, - "error: failed to resume from D0I3 %d\n", - ret); - return ret; - } - } - /* * if the runtime_resume flag is set, call the runtime_resume routine * or else call the system resume routine @@ -122,8 +111,8 @@ static int sof_resume(struct device *dev, bool runtime_resume) return ret; } - /* Nothing further to do if resuming from D0I3 */ - if (!runtime_resume && old_d0_substate == SOF_DSP_D0I3) + /* Nothing further to do if resuming from a low-power D0 substate */ + if (!runtime_resume && old_state == SOF_DSP_PM_D0) return 0; sdev->fw_state = SOF_FW_BOOT_PREPARE; @@ -176,15 +165,13 @@ static int sof_resume(struct device *dev, bool runtime_resume) "error: ctx_restore ipc error during resume %d\n", ret); - /* initialize default D0 sub-state */ - sdev->d0_substate = SOF_DSP_D0I0; - return ret; } static int sof_suspend(struct device *dev, bool runtime_suspend) { struct snd_sof_dev *sdev = dev_get_drvdata(dev); + u32 target_state = 0; int ret; /* do nothing if dsp suspend callback is not set */ @@ -205,18 +192,11 @@ static int sof_suspend(struct device *dev, bool runtime_suspend) } } - if (snd_sof_dsp_power_target(sdev) == SOF_DSP_PM_D0) { - /* suspend to D0i3 */ - ret = snd_sof_set_d0_substate(sdev, SOF_DSP_D0I3); - if (ret < 0) { - dev_err(sdev->dev, "error: failed to enter D0I3, %d\n", - ret); - return ret; - } + target_state = snd_sof_dsp_power_target(sdev); - /* Skip to platform-specific suspend if DSP is entering D0I3 */ + /* Skip to platform-specific suspend if DSP is entering D0 */ + if (target_state == SOF_DSP_PM_D0) goto suspend; - } /* release trace */ snd_sof_release_trace(sdev); @@ -254,14 +234,14 @@ suspend: if (runtime_suspend) ret = snd_sof_dsp_runtime_suspend(sdev); else - ret = snd_sof_dsp_suspend(sdev); + ret = snd_sof_dsp_suspend(sdev, target_state); if (ret < 0) dev_err(sdev->dev, "error: failed to power down DSP during suspend %d\n", ret); - /* Do not reset FW state if DSP is in D0I3 */ - if (sdev->d0_substate == SOF_DSP_D0I3) + /* Do not reset FW state if DSP is in D0 */ + if (target_state == SOF_DSP_PM_D0) return ret; /* reset FW state */ @@ -290,58 +270,6 @@ int snd_sof_runtime_resume(struct device *dev) } EXPORT_SYMBOL(snd_sof_runtime_resume); -int snd_sof_set_d0_substate(struct snd_sof_dev *sdev, - enum sof_d0_substate d0_substate) -{ - int ret; - - if (sdev->d0_substate == d0_substate) - return 0; - - /* do platform specific set_state */ - ret = snd_sof_dsp_set_power_state(sdev, d0_substate); - if (ret < 0) - return ret; - - /* update dsp D0 sub-state */ - sdev->d0_substate = d0_substate; - - return 0; -} -EXPORT_SYMBOL(snd_sof_set_d0_substate); - -/* - * Audio DSP states may transform as below:- - * - * D0I3 compatible stream - * Runtime +---------------------+ opened only, timeout - * suspend | +--------------------+ - * +------------+ D0(active) | | - * | | <---------------+ | - * | +--------> | | | - * | |Runtime +--^--+---------^--+--+ The last | | - * | |resume | | | | opened D0I3 | | - * | | | | | | compatible | | - * | | resume| | | | stream closed | | - * | | from | | D3 | | | | - * | | D3 | |suspend | | d0i3 | | - * | | | | | |suspend | | - * | | | | | | | | - * | | | | | | | | - * +-v---+-----------+--v-------+ | | +------+----v----+ - * | | | +-----------> | - * | D3 (suspended) | | | D0I3 +-----+ - * | | +--------------+ | | - * | | resume from | | | - * +-------------------^--------+ d0i3 suspend +----------------+ | - * | | - * | D3 suspend | - * +------------------------------------------------+ - * - * d0i3_suspend = s0_suspend && D0I3 stream opened, - * D3 suspend = !d0i3_suspend, - */ - int snd_sof_resume(struct device *dev) { return sof_resume(dev, false); |