Skip to content

Commit

Permalink
ASoC: SOF: Intel: hda: Move DSP power step to the set_power_state op
Browse files Browse the repository at this point in the history
This will allow for the set_power_state op to be used for switching the
DSP to the D3 state. The logic for powering up the DSP when setting the
state to D0 also needs to be moved and will be done in a follow up. But
for now, this will allow stress testing firmware boot.

Signed-off-by: Ranjani Sridharan <[email protected]>
  • Loading branch information
ranj063 committed Jun 10, 2024
1 parent 7c7a4da commit ecb73cb
Showing 1 changed file with 24 additions and 23 deletions.
47 changes: 24 additions & 23 deletions sound/soc/sof/intel/hda-dsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -684,8 +684,22 @@ static int hda_dsp_set_power_state(struct snd_sof_dev *sdev,
case SOF_DSP_PM_D3:
/* The only allowed transition is: D0I0 -> D3 */
if (sdev->dsp_power_state.state == SOF_DSP_PM_D0 &&
sdev->dsp_power_state.substate == SOF_HDA_DSP_PM_D0I0)
sdev->dsp_power_state.substate == SOF_HDA_DSP_PM_D0I0) {
struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
const struct sof_intel_dsp_desc *chip = hda->desc;
int ret, j;

ret = chip->power_down_dsp(sdev);
if (ret < 0) {
dev_err(sdev->dev, "failed to power down DSP during suspend\n");
return ret;
}

/* reset ref counts for all cores */
for (j = 0; j < chip->cores_num; j++)
sdev->dsp_core_ref_count[j] = 0;
break;
}

dev_err(sdev->dev,
"error: transition from %d to %d not allowed\n",
Expand Down Expand Up @@ -781,8 +795,11 @@ static int hda_suspend(struct snd_sof_dev *sdev, bool runtime_suspend)
struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
const struct sof_intel_dsp_desc *chip = hda->desc;
struct hdac_bus *bus = sof_to_bus(sdev);
struct sof_dsp_power_state target_state = {
.state = SOF_DSP_PM_D3,
};
bool imr_lost = false;
int ret, j;
int ret;

/*
* The memory used for IMR boot loses its content in deeper than S3
Expand Down Expand Up @@ -820,15 +837,9 @@ static int hda_suspend(struct snd_sof_dev *sdev, bool runtime_suspend)
if (sdev->dspless_mode_selected)
goto skip_dsp;

ret = chip->power_down_dsp(sdev);
if (ret < 0) {
dev_err(sdev->dev, "failed to power down DSP during suspend\n");
ret = snd_sof_dsp_set_power_state(sdev, &target_state);
if (ret < 0)
return ret;
}

/* reset ref counts for all cores */
for (j = 0; j < chip->cores_num; j++)
sdev->dsp_core_ref_count[j] = 0;

/* disable ppcap interrupt */
hda_dsp_ctrl_ppcap_enable(sdev, false);
Expand Down Expand Up @@ -988,22 +999,14 @@ EXPORT_SYMBOL_NS(hda_dsp_runtime_idle, SND_SOC_SOF_INTEL_HDA_COMMON);
int hda_dsp_runtime_suspend(struct snd_sof_dev *sdev)
{
struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
const struct sof_dsp_power_state target_state = {
.state = SOF_DSP_PM_D3,
};
int ret;

if (!sdev->dspless_mode_selected) {
/* cancel any attempt for DSP D0I3 */
cancel_delayed_work_sync(&hda->d0i3_work);
}

/* stop hda controller and power dsp off */
ret = hda_suspend(sdev, true);
if (ret < 0)
return ret;

return snd_sof_dsp_set_power_state(sdev, &target_state);
return hda_suspend(sdev, true);
}
EXPORT_SYMBOL_NS(hda_dsp_runtime_suspend, SND_SOC_SOF_INTEL_HDA_COMMON);

Expand Down Expand Up @@ -1059,12 +1062,10 @@ int hda_dsp_suspend(struct snd_sof_dev *sdev, u32 target_state)

/* stop hda controller and power dsp off */
ret = hda_suspend(sdev, false);
if (ret < 0) {
if (ret < 0)
dev_err(bus->dev, "error: suspending dsp\n");
return ret;
}

return snd_sof_dsp_set_power_state(sdev, &target_dsp_state);
return ret;
}
EXPORT_SYMBOL_NS(hda_dsp_suspend, SND_SOC_SOF_INTEL_HDA_COMMON);

Expand Down

0 comments on commit ecb73cb

Please sign in to comment.