[PATCH 09/10][SRU][M] ALSA: hda: cs35l41: Check CSPL state after loading firmware
Chris Chiu
chris.chiu at canonical.com
Wed Nov 22 06:35:40 UTC 2023
From: Stefan Binding <sbinding at opensource.cirrus.com>
BugLink: https://bugs.launchpad.net/bugs/2042060
CSPL firmware should be in RUNNING or PAUSED state after loading.
If not, the firmware has not been loaded correctly, and we can unload
it and pass the error up.
Signed-off-by: Stefan Binding <sbinding at opensource.cirrus.com>
Link: https://lore.kernel.org/r/20231026150558.2105827-8-sbinding@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai at suse.de>
(cherry picked from commit a51d8ba03a4fc92940d5e349f0325f36e85a89cb)
Signed-off-by: Chris Chiu <chris.chiu at canonical.com>
---
sound/pci/hda/cs35l41_hda.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c
index 3c88f71d97f4..686efaeb7f3c 100644
--- a/sound/pci/hda/cs35l41_hda.c
+++ b/sound/pci/hda/cs35l41_hda.c
@@ -929,6 +929,7 @@ static int cs35l41_runtime_resume(struct device *dev)
static int cs35l41_smart_amp(struct cs35l41_hda *cs35l41)
{
+ unsigned int fw_status;
__be32 halo_sts;
int ret;
@@ -962,6 +963,23 @@ static int cs35l41_smart_amp(struct cs35l41_hda *cs35l41)
goto clean_dsp;
}
+ ret = regmap_read(cs35l41->regmap, CS35L41_DSP_MBOX_2, &fw_status);
+ if (ret < 0) {
+ dev_err(cs35l41->dev,
+ "Failed to read firmware status: %d\n", ret);
+ goto clean_dsp;
+ }
+
+ switch (fw_status) {
+ case CSPL_MBOX_STS_RUNNING:
+ case CSPL_MBOX_STS_PAUSED:
+ break;
+ default:
+ dev_err(cs35l41->dev, "Firmware status is invalid: %u\n",
+ fw_status);
+ goto clean_dsp;
+ }
+
ret = cs35l41_set_cspl_mbox_cmd(cs35l41->dev, cs35l41->regmap, CSPL_MBOX_CMD_PAUSE);
if (ret) {
dev_err(cs35l41->dev, "Error waiting for DSP to pause: %u\n", ret);
--
2.34.1
More information about the kernel-team
mailing list