[PATCH 4/8] ASoC: aw88399: add firmware reload flag for resume

Marco Giunta <[email protected]>
Newsgroups org.kernel.vger.platform-driver-x86,org.kernel.vger.linux-acpi,org.kernel.vger.linux-kernel,org.kernel.vger.linux-sound
Message-ID <DS7PR19MB77240CB79188C0B7AE243829FCC62@DS7PR19MB7724.namprd19.prod.outlook.com>
Add a fw_needs_reload flag to struct aw88399 that, when set, causes
aw88399_start to perform a full DSP firmware upload instead of
assuming the firmware binary is already present in memory.

After system sleep, the AW88399 loses its memory contents. The
existing start sequence assumes the firmware binary persists from
initialization and only uploads register configuration and DSP
config (AW88399_DSP_FW_UPDATE_OFF). When memory is empty, this causes
the subsequent CRC check to fail, triggering the retry mechanism in
aw88399_start_pa which re-uploads the firmware on the second
attempt.

While the retry mechanism recovers correctly, it produces
misleading error-level log messages on every resume cycle. The
fw_needs_reload flag allows the HDA side codec driver to signal
that a full firmware reload is needed after resume, eliminating
the spurious CRC failures.

The flag defaults to false via kzalloc, preserving the original
behavior for existing ASoC users. No existing code path sets this
flag; it will be set by the HDA side codec driver's system suspend
handler.

Tested-by: Nadim Kobeissi <[email protected]>
Tested-by: Xia Yun'an <[email protected]>
Tested-by: Munzir Taha <[email protected]>
Signed-off-by: Marco Giunta <[email protected]>
---
 include/sound/aw88399.h        | 1 +
 sound/soc/codecs/aw88399-lib.c | 5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/sound/aw88399.h b/include/sound/aw88399.h
index dee91b540b81..3dbc37dc13d1 100644
--- a/include/sound/aw88399.h
+++ b/include/sound/aw88399.h
@@ -599,6 +599,7 @@ struct aw88399 {
 	unsigned int vcalb_init_val;
 	unsigned int dither_st;
 	bool bsts_unreliable;
+	bool fw_needs_reload;
 };
 
 int aw_dev_check_syspll(struct aw_device *aw_dev);
diff --git a/sound/soc/codecs/aw88399-lib.c b/sound/soc/codecs/aw88399-lib.c
index 2045c4171be0..094a37b66fb5 100644
--- a/sound/soc/codecs/aw88399-lib.c
+++ b/sound/soc/codecs/aw88399-lib.c
@@ -1171,12 +1171,15 @@ void aw88399_start(struct aw88399 *aw88399, bool sync_start)
 	if (aw88399->aw_pa->status == AW88399_DEV_PW_ON)
 		return;
 
-	ret = aw88399_dev_fw_update(aw88399, AW88399_DSP_FW_UPDATE_OFF, true);
+	ret = aw88399_dev_fw_update(aw88399, aw88399->fw_needs_reload ?
+		AW88399_DSP_FW_UPDATE_ON : AW88399_DSP_FW_UPDATE_OFF, true);
 	if (ret) {
 		dev_err(aw88399->aw_pa->dev, "fw update failed.");
 		return;
 	}
 
+	aw88399->fw_needs_reload = false;
+
 	if (sync_start == AW88399_SYNC_START)
 		aw88399_start_pa(aw88399);
 	else
-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.