Skip to contentSkip to conversation

ASoC: SOF: Intel: hda/mtl: Handle powered on DSP on boot

PATCH In review Peter Ujfalusi 2 participants 4 messages Jul 30 – Jul 31

Subsystems (3)
lore
Share & tools
lore

Peter Ujfalusi

author maintainer
#0 lore raw

cover ASoC: SOF: Intel: hda/mtl: Handle powered on DSP on boot

Hi,

It is expected that the DSP is in power down state when the firmware boot is attempted.
If the DSP for any reason was left powered up then the DSP boot will fail since the ROM boot sequence might not be able to run.

Make sure that the DSP is off before proceeding to boot it up.

We have seen reports that for some undetermined reasons the DSP was on during system boot and this caused firmware boot failure as the DSP cannot be booted up - it was already in booted up state.

Regards,
Peter
--
Peter Ujfalusi (2):
ASoC: SOF: Intel: hda: Power down DSP if it is left enabled in

    pre_fw_run()
  ASoC: SOF: Intel: mtl: Power down DSP if it is left enabled in
    pre_fw_run()
 sound/soc/sof/intel/hda.c | 14 ++++++++++++++
 sound/soc/sof/intel/mtl.c | 23 +++++++++++++++++++++++
 2 files changed, 37 insertions(+)
Signature · 1 line
2.55.0
author maintainer
#1 lore raw

PATCH 1/2 ASoC: SOF: Intel: hda: Power down DSP if it is left enabled in pre_fw_run()

It is expected that the DSP is in power down state when the firmware boot is attempted.
If the DSP for any reason was left powered up then the DSP boot will fail since the ROM boot sequence might not be able to run.

Make sure that the DSP is off before proceeding to boot it up.

---
 sound/soc/sof/intel/hda.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
sound/soc/sof/intel/hda.c +14 -0
index dc85903b8d46..007a8e4a2f3d 100644
@@ -421,6 +421,20 @@ static inline void hda_dsp_sdw_process_mic_privacy(struct snd_sof_dev *sdev) { }
 /* pre fw run operations */
 int hda_dsp_pre_fw_run(struct snd_sof_dev *sdev)
 {
+	struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
+	const struct sof_intel_dsp_desc *chip = hda->desc;
+	int ret;
+
+	/* Power down DSP if left enabled to ensure a clean boot state. */
+	if (hda_dsp_core_is_enabled(sdev, chip->host_managed_cores_mask)) {
+		dev_dbg(sdev->dev, "DSP core enabled, power down DSP first\n");
+
+		ret = chip->power_down_dsp(sdev);
+		if (ret < 0)
+			dev_warn(sdev->dev,
+				 "%s: failed to power down already-enabled DSP\n", __func__);
+	}
+
 	/* disable clock gating and power gating */
 	return hda_dsp_ctrl_clock_power_gating(sdev, false);
 }
Signature · 1 line
2.55.0
author maintainer
#2 lore raw

PATCH 2/2 ASoC: SOF: Intel: mtl: Power down DSP if it is left enabled in pre_fw_run()

In reply to Peter Ujfalusi

It is expected that the DSP is in power down state when the firmware boot is attempted.
If the DSP for any reason was left powered up then the DSP boot will fail since the ROM boot sequence might not be able to run.

Make sure that the DSP is off before proceeding to boot it up.

---
 sound/soc/sof/intel/mtl.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
sound/soc/sof/intel/mtl.c +23 -0
index 9503d00e6002..3d67d6777f1b 100644
@@ -236,6 +236,17 @@ int mtl_enable_interrupts(struct snd_sof_dev *sdev, bool enable)
 }
 EXPORT_SYMBOL_NS(mtl_enable_interrupts, "SND_SOC_SOF_INTEL_MTL");
 
+static bool mtl_dsp_is_enabled(struct snd_sof_dev *sdev)
+{
+	int val;
+
+	val = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_HFDSSCS);
+	if (val & MTL_HFDSSCS_CPA_MASK)
+		return true;
+
+	return false;
+}
+
 /* pre fw run operations */
 static int mtl_dsp_pre_fw_run(struct snd_sof_dev *sdev)
 {
@@ -249,6 +260,18 @@ static int mtl_dsp_pre_fw_run(struct snd_sof_dev *sdev)
 	u32 dsppwrsts;
 	const struct sof_intel_dsp_desc *chip;
 
+	/* Power down the DSP if it is left enabled to ensure clean boot state */
+	if (mtl_dsp_is_enabled(sdev)) {
+		dev_dbg(sdev->dev, "powering down DSP first\n");
+
+		ret = mtl_power_down_dsp(sdev);
+		if (ret < 0) {
+			dev_warn(sdev->dev,
+				 "%s: failed to power down already-enabled DSP\n", __func__);
+			/* Continue anyway to attempt recovery */
+		}
+	}
+
 	chip = get_chip_info(sdev->pdata);
 	if (chip->hw_ip_version > SOF_INTEL_ACE_2_0) {
 		dsppwrctl = PTL_HFPWRCTL2;
Signature · 1 line
2.55.0
maintainer
#3 lore raw
In reply to Peter Ujfalusi
Quoted 10 lines · Peter Ujfalusi

ASoC: SOF: Intel: hda/mtl: Handle powered on DSP on boot

Hi,

It is expected that the DSP is in power down state when the firmware boot is attempted.
If the DSP for any reason was left powered up then the DSP boot will fail since the ROM boot sequence might not be able to run.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.3

Thanks!

[1/2] ASoC: SOF: Intel: hda: Power down DSP if it is left enabled in pre_fw_run()

      https://git.kernel.org/broonie/sound/c/7b51d4c4256c
[2/2] ASoC: SOF: Intel: mtl: Power down DSP if it is left enabled in pre_fw_run()
      https://git.kernel.org/broonie/sound/c/31fd7a0bbfa4

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark