Linux Sound subsystem development
 help / color / mirror / Atom feed
From: <sravisar@amd.com>
To: <broonie@kernel.org>
Cc: <alsa-devel@alsa-project.org>, <lgirdwood@gmail.com>,
	<perex@perex.cz>, <tiwai@suse.com>,
	<yung-chuan.liao@linux.intel.com>, <Basavaraj.Hiregoudar@amd.com>,
	<Sunil-kumar.Dommati@amd.com>, <venkataprasad.potturu@amd.com>,
	<Syed.SabaKareem@amd.com>, <Mario.Limonciello@amd.com>,
	<Richard.Gong@amd.com>, <Vijendar.Mukunda@amd.com>,
	<linux-sound@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<sound-open-firmware@alsa-project.org>,
	"Siva Subramanian Ravi Saravanan" <sravisar@amd.com>
Subject: [PATCH v2 2/2] ASoC: SOF: amd: acp7x: reload firmware from disk on S4 resume
Date: Mon, 30 Nov 2026 14:32:23 +0530	[thread overview]
Message-ID: <20261130090246.3653208-3-sravisar@amd.com> (raw)
In-Reply-To: <20261130090246.3653208-1-sravisar@amd.com>

From: Siva Subramanian Ravi Saravanan <sravisar@amd.com>

On S4 (hibernate) the ASP carveout in DDR loses power, so the raw
firmware image previously deposited there by VALIDATE_IMAGE is gone.
acp7x_load_firmware_carveout() skips VALIDATE_IMAGE whenever
fw_code_carveout_addr is already set and SHA-DMAs directly from the
carveout, which on S4 resume would read an empty carveout and fail to
boot the DSP.

Clear fw_code_carveout_addr at the start of amd_sof_acp7x_resume() when
the system suspend target is deeper than S3, so the loader takes the full
request_firmware() + VALIDATE_IMAGE path and re-deposits the image into
the carveout. Doing this before the SoundWire clock-stop and
acp_init()/acp_memory_init() early returns ensures it is never skipped.
Resume is used rather than suspend because the platform suspend callback
is not invoked when the DSP is already runtime suspended.

snd_sof_prepare() leaves the target at S3 without querying ACPI when the
firmware has crashed or failed to boot, so S4 cannot be detected in that
case. Also clear fw_code_carveout_addr in amd_sof_acp7x_suspend() for
those firmware states.

S0ix/s2idle resume is unaffected and keeps the fast SHA-DMA path, as the
carveout contents are preserved.

Fixes: cec3598305a6 ("ASoC: SOF: amd: add ASP carveout firmware loading for ACP7.B/7.F")
Signed-off-by: Siva Subramanian Ravi Saravanan <sravisar@amd.com>
---
Changes in v2:
- Clear fw_code_carveout_addr at the start of resume, before the
  early returns, and for S4/S5.
- Also clear it on suspend if the firmware has crashed or failed to boot.
- Link to v1: https://lore.kernel.org/all/20261125053843.1611378-1-sravisar@amd.com/

 sound/soc/sof/amd/acp.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/sound/soc/sof/amd/acp.c b/sound/soc/sof/amd/acp.c
index 0d208df621e29..b93330dcf22e8 100644
--- a/sound/soc/sof/amd/acp.c
+++ b/sound/soc/sof/amd/acp.c
@@ -1585,6 +1585,12 @@ int amd_sof_acp7x_suspend(struct snd_sof_dev *sdev, u32 target_state)
 
 	acp_data = sdev->pdata->hw_pdata;
 
+	/* snd_sof_prepare() can't detect S4 if FW crashed; reload from disk */
+	if (acp_data->asp_carveout_base &&
+	    (sdev->fw_state == SOF_FW_CRASHED ||
+	     sdev->fw_state == SOF_FW_BOOT_FAILED))
+		acp_data->fw_code_carveout_addr = 0;
+
 	if (acp_data->is_sdw_dev && check_acp_sdw_enable_status(sdev)) {
 		snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP7X_ZSC_DSP_CTRL, 1);
 		return acp_dsp_reset(sdev);
@@ -1655,6 +1661,11 @@ int amd_sof_acp7x_resume(struct snd_sof_dev *sdev)
 
 	acp_data = sdev->pdata->hw_pdata;
 
+	/* Carveout is unpowered in S4/S5; force a full firmware reload */
+	if (acp_data->asp_carveout_base &&
+	    sdev->system_suspend_target > SOF_SUSPEND_S3)
+		acp_data->fw_code_carveout_addr = 0;
+
 	if (acp_data->sdw_en_stat) {
 		snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP7X_ZSC_DSP_CTRL, 0);
 		snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP7X_PME_EN, 1);
-- 
2.43.0


      parent reply	other threads:[~2026-11-30  9:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30  9:02 [PATCH v2 0/2] ASoC: SOF: amd: acp7x: fix S4 resume with ASP carveout firmware loading sravisar
2026-11-30  9:02 ` [PATCH v2 1/2] ASoC: SOF: amd: acp7x: enable ACPI target power states sravisar
2026-11-30  9:02 ` sravisar [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261130090246.3653208-3-sravisar@amd.com \
    --to=sravisar@amd.com \
    --cc=Basavaraj.Hiregoudar@amd.com \
    --cc=Mario.Limonciello@amd.com \
    --cc=Richard.Gong@amd.com \
    --cc=Sunil-kumar.Dommati@amd.com \
    --cc=Syed.SabaKareem@amd.com \
    --cc=Vijendar.Mukunda@amd.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=sound-open-firmware@alsa-project.org \
    --cc=tiwai@suse.com \
    --cc=venkataprasad.potturu@amd.com \
    --cc=yung-chuan.liao@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox