Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH 0/2] ASoC: SOF: amd: acp7x: fix S4 resume with ASP carveout firmware loading
@ 2026-11-25  5:38 sravisar
  2026-11-25  5:38 ` [PATCH 1/2] ASoC: SOF: amd: acp7x: enable ACPI target power states sravisar
  2026-11-25  5:38 ` [PATCH 2/2] ASoC: SOF: amd: acp7x: reload firmware from disk on S4 resume sravisar
  0 siblings, 2 replies; 4+ messages in thread
From: sravisar @ 2026-11-25  5:38 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, lgirdwood, perex, tiwai, yung-chuan.liao,
	Basavaraj.Hiregoudar, Sunil-kumar.Dommati, venkataprasad.potturu,
	Syed.SabaKareem, Mario.Limonciello, Richard.Gong,
	Vijendar.Mukunda, linux-sound, linux-kernel, sound-open-firmware,
	Siva Subramanian Ravi Saravanan

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

On ACP7.B/7.F with signed firmware, the DSP firmware is loaded through
the ASP carveout in DDR. The carveout loses its contents across S4
(hibernate), but on resume the loader still SHA-DMAs the image from it,
so the DSP fails to boot.

Patch 1 enables ACPI target power states for ACP7.B/7.F so the driver
can tell S4 apart from S3. It does not change behaviour on its own.

Patch 2 clears the cached carveout firmware address on S4 resume,
forcing a full request_firmware() + VALIDATE_IMAGE reload. S3 resume
is unchanged, as the carveout is preserved across S3.

Siva Subramanian Ravi Saravanan (2):
  ASoC: SOF: amd: acp7x: enable ACPI target power states
  ASoC: SOF: amd: acp7x: reload firmware from disk on S4 resume

 sound/soc/sof/amd/acp.c       | 9 +++++++++
 sound/soc/sof/amd/pci-acp7x.c | 2 ++
 2 files changed, 11 insertions(+)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] ASoC: SOF: amd: acp7x: enable ACPI target power states
  2026-11-25  5:38 [PATCH 0/2] ASoC: SOF: amd: acp7x: fix S4 resume with ASP carveout firmware loading sravisar
@ 2026-11-25  5:38 ` sravisar
  2026-11-25  5:38 ` [PATCH 2/2] ASoC: SOF: amd: acp7x: reload firmware from disk on S4 resume sravisar
  1 sibling, 0 replies; 4+ messages in thread
From: sravisar @ 2026-11-25  5:38 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, lgirdwood, perex, tiwai, yung-chuan.liao,
	Basavaraj.Hiregoudar, Sunil-kumar.Dommati, venkataprasad.potturu,
	Syed.SabaKareem, Mario.Limonciello, Richard.Gong,
	Vijendar.Mukunda, linux-sound, linux-kernel, sound-open-firmware,
	Siva Subramanian Ravi Saravanan

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

The ACP7.x suspend and resume handlers need to tell S4 (hibernate)
apart from S3, because the ASP firmware carveout in DDR loses its
contents across S4 but not across S3. They rely on
sdev->system_suspend_target for this, but snd_sof_prepare() only
derives it from acpi_target_system_state() when the device descriptor
sets use_acpi_target_states. Otherwise system_suspend_target stays at
its SOF_SUSPEND_S3 default and the S4 path is never taken.

Set use_acpi_target_states in the ACP7.B and ACP7.F descriptors so that
system_suspend_target reflects the actual target state (S0ix, S3, S4 or
S5).

Signed-off-by: Siva Subramanian Ravi Saravanan <sravisar@amd.com>
---
 sound/soc/sof/amd/pci-acp7x.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sound/soc/sof/amd/pci-acp7x.c b/sound/soc/sof/amd/pci-acp7x.c
index 5a21ab8ebb4b9..b27798f2007bc 100644
--- a/sound/soc/sof/amd/pci-acp7x.c
+++ b/sound/soc/sof/amd/pci-acp7x.c
@@ -66,6 +66,7 @@ static const struct sof_dev_desc acp7b_desc = {
 	.nocodec_tplg_filename	= "sof-acp.tplg",
 	.ops			= &sof_acp7x_ops,
 	.ops_init		= sof_acp7x_ops_init,
+	.use_acpi_target_states = true,
 };
 
 static const struct sof_amd_acp_desc acp7f_chip_info = {
@@ -108,6 +109,7 @@ static const struct sof_dev_desc acp7f_desc = {
 	.nocodec_tplg_filename	= "sof-acp.tplg",
 	.ops			= &sof_acp7x_ops,
 	.ops_init		= sof_acp7x_ops_init,
+	.use_acpi_target_states = true,
 };
 
 static const struct pci_device_id acp7b_pci_id = {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] ASoC: SOF: amd: acp7x: reload firmware from disk on S4 resume
  2026-11-25  5:38 [PATCH 0/2] ASoC: SOF: amd: acp7x: fix S4 resume with ASP carveout firmware loading sravisar
  2026-11-25  5:38 ` [PATCH 1/2] ASoC: SOF: amd: acp7x: enable ACPI target power states sravisar
@ 2026-11-25  5:38 ` sravisar
  2026-11-25  6:02   ` sashiko-bot
  1 sibling, 1 reply; 4+ messages in thread
From: sravisar @ 2026-11-25  5:38 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, lgirdwood, perex, tiwai, yung-chuan.liao,
	Basavaraj.Hiregoudar, Sunil-kumar.Dommati, venkataprasad.potturu,
	Syed.SabaKareem, Mario.Limonciello, Richard.Gong,
	Vijendar.Mukunda, linux-sound, linux-kernel, sound-open-firmware,
	Siva Subramanian Ravi Saravanan

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 on S4 resume so the loader takes the full
request_firmware() + VALIDATE_IMAGE path and re-deposits the image into
the carveout. S3 resume is unaffected, as the carveout contents are
preserved across S3.

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>
---
 sound/soc/sof/amd/acp.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/sound/soc/sof/amd/acp.c b/sound/soc/sof/amd/acp.c
index 8039b2450cf3e..b6befa9712567 100644
--- a/sound/soc/sof/amd/acp.c
+++ b/sound/soc/sof/amd/acp.c
@@ -1673,6 +1673,15 @@ int amd_sof_acp7x_resume(struct snd_sof_dev *sdev)
 		return ret;
 	}
 
+	/*
+	 * S4 powers down the carveout, invalidating its cached firmware. Clear
+	 * fw_code_carveout_addr to force a full reload via VALIDATE_IMAGE on
+	 * resume instead of a SHA-DMA from the stale carveout.
+	 */
+	if (acp_data->asp_carveout_base &&
+	    sdev->system_suspend_target == SOF_SUSPEND_S4)
+		acp_data->fw_code_carveout_addr = 0;
+
 	return 0;
 }
 EXPORT_SYMBOL_NS(amd_sof_acp7x_resume, "SND_SOC_SOF_AMD_COMMON");
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] ASoC: SOF: amd: acp7x: reload firmware from disk on S4 resume
  2026-11-25  5:38 ` [PATCH 2/2] ASoC: SOF: amd: acp7x: reload firmware from disk on S4 resume sravisar
@ 2026-11-25  6:02   ` sashiko-bot
  0 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-11-25  6:02 UTC (permalink / raw)
  To: sravisar; +Cc: linux-sound

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] ASoC: SOF: amd: S4 carveout reset bypassed in
  amd_sof_acp7x_resume()
- [Medium] ASoC: SOF: amd: missed carveout clear in
  amd_sof_acp7x_resume() after FW crash
--

commit b8704d96ab1f4418fdf040e05ffe9e060f0a776b
Author: Siva Subramanian Ravi Saravanan <sravisar@amd.com>

ASoC: SOF: amd: acp7x: reload firmware from disk on S4 resume

This commit clears fw_code_carveout_addr on S4 resume in
amd_sof_acp7x_resume() so acp7x_load_firmware_carveout() reloads and
re-validates the firmware into the ASP carveout after hibernation.

> diff --git a/sound/soc/sof/amd/acp.c b/sound/soc/sof/amd/acp.c
> index 0d208df621e29..4ad54e5b4f660 100644
> --- a/sound/soc/sof/amd/acp.c
> +++ b/sound/soc/sof/amd/acp.c
> @@ -1672,6 +1672,15 @@ int amd_sof_acp7x_resume(struct snd_sof_dev *sdev)
>  		return ret;
>  	}
>  
> +	/*
> +	 * S4 powers down the carveout, invalidating its cached firmware. Clear
> +	 * fw_code_carveout_addr to force a full reload via VALIDATE_IMAGE on
> +	 * resume instead of a SHA-DMA from the stale carveout.
> +	 */
> +	if (acp_data->asp_carveout_base &&
> +	    sdev->system_suspend_target == SOF_SUSPEND_S4)
> +		acp_data->fw_code_carveout_addr = 0;

[Severity: High]
Does placing this check at the end of amd_sof_acp7x_resume() leave
acp_data->fw_code_carveout_addr set when acp_data->sdw_en_stat is true?

When SoundWire managers suspend in clock-stop mode,
amd_sof_acp7x_suspend() sets acp_data->sdw_en_stat via
check_acp_sdw_enable_status(), causing amd_sof_acp7x_resume() to return
early:

sound/soc/sof/amd/acp.c:amd_sof_acp7x_resume() {
	...
	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);
		return acp_dsp_reset(sdev);
	}
	...
}

sof_resume() still calls snd_sof_boot_dsp_firmware() afterwards, so on S4
resume acp7x_load_firmware_carveout() will skip VALIDATE_IMAGE and
SHA-DMA from the unpopulated carveout.  Similarly, if acp_init() or
acp_memory_init() fails before reaching this check, snd_sof_complete()
resets sdev->system_suspend_target to SOF_SUSPEND_NONE without clearing
fw_code_carveout_addr.

[Severity: Medium]
Can acp_data->fw_code_carveout_addr also remain set on S4 resume if the
system hibernates while sdev->fw_state is SOF_FW_CRASHED or
SOF_FW_BOOT_FAILED?

In snd_sof_prepare(), sdev->system_suspend_target is initialized to
SOF_SUSPEND_S3 and the function returns early before querying
acpi_target_system_state() when sdev->fw_state is SOF_FW_CRASHED or
SOF_FW_BOOT_FAILED:

sound/soc/sof/pm.c:snd_sof_prepare() {
	...
	/* default to S3 in case the followingaske fails */
	sdev->system_suspend_target = SOF_SUSPEND_S3;

	if (sdev->fw_state == SOF_FW_CRASHED ||
	    sdev->fw_state == SOF_FW_BOOT_FAILED)
		return 0;
	...
}

sof_suspend() then resets sdev->fw_state to SOF_FW_BOOT_NOT_STARTED
after snd_sof_dsp_suspend() returns, so on S4 resume
sdev->system_suspend_target is still SOF_SUSPEND_S3 and
acp7x_load_firmware_carveout() will SHA-DMA from the powered-down
carveout.  Clearing fw_code_carveout_addr in amd_sof_acp7x_suspend()
when sdev->system_suspend_target > SOF_SUSPEND_S3 or sdev->fw_state is
SOF_FW_CRASHED or SOF_FW_BOOT_FAILED would avoid both issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261125053843.1611378-1-sravisar@amd.com?part=2

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-25  6:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25  5:38 [PATCH 0/2] ASoC: SOF: amd: acp7x: fix S4 resume with ASP carveout firmware loading sravisar
2026-11-25  5:38 ` [PATCH 1/2] ASoC: SOF: amd: acp7x: enable ACPI target power states sravisar
2026-11-25  5:38 ` [PATCH 2/2] ASoC: SOF: amd: acp7x: reload firmware from disk on S4 resume sravisar
2026-11-25  6:02   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox