From: Richard Fitzgerald <rf@opensource.cirrus.com>
To: <broonie@kernel.org>
Cc: <alsa-devel@alsa-project.org>, <linux-kernel@vger.kernel.org>,
<patches@opensource.cirrus.com>,
Richard Fitzgerald <rf@opensource.cirrus.com>
Subject: [PATCH 2/2] ASoC: cs35l56: Don't overwrite a patched firmware
Date: Tue, 15 Aug 2023 13:48:26 +0100 [thread overview]
Message-ID: <20230815124826.5447-3-rf@opensource.cirrus.com> (raw)
In-Reply-To: <20230815124826.5447-1-rf@opensource.cirrus.com>
Only attempt to download wmfw/bin files to a non-secured part if
it reports FIRMWARE_MISSING. If FIRMWARE_MISSING is false the
firmware has already been patched and overwriting the patch could
corrupt the running firmware.
For a secured part the wmfw/bin can be downloaded even if
FIRMWARE_MISSING is false, because they will only patch tunings.
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
---
sound/soc/codecs/cs35l56.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/sound/soc/codecs/cs35l56.c b/sound/soc/codecs/cs35l56.c
index 98cfcae554af..3a9ec8724cc1 100644
--- a/sound/soc/codecs/cs35l56.c
+++ b/sound/soc/codecs/cs35l56.c
@@ -665,8 +665,17 @@ static void cs35l56_secure_patch(struct cs35l56_private *cs35l56)
static void cs35l56_patch(struct cs35l56_private *cs35l56)
{
+ unsigned int firmware_missing;
int ret;
+ ret = regmap_read(cs35l56->base.regmap, CS35L56_PROTECTION_STATUS, &firmware_missing);
+ if (ret) {
+ dev_err(cs35l56->base.dev, "Failed to read PROTECTION_STATUS: %d\n", ret);
+ return;
+ }
+
+ firmware_missing &= CS35L56_FIRMWARE_MISSING;
+
/*
* Disable SoundWire interrupts to prevent race with IRQ work.
* Setting sdw_irq_no_unmask prevents the handler re-enabling
@@ -685,8 +694,12 @@ static void cs35l56_patch(struct cs35l56_private *cs35l56)
if (ret)
goto err;
- /* Use wm_adsp to load and apply the firmware patch and coefficient files */
- ret = wm_adsp_power_up(&cs35l56->dsp, true);
+ /*
+ * Use wm_adsp to load and apply the firmware patch and coefficient files,
+ * but only if firmware is missing. If firmware is already patched just
+ * power-up wm_adsp without downloading firmware.
+ */
+ ret = wm_adsp_power_up(&cs35l56->dsp, !!firmware_missing);
if (ret) {
dev_dbg(cs35l56->base.dev, "%s: wm_adsp_power_up ret %d\n", __func__, ret);
goto err;
--
2.30.2
next prev parent reply other threads:[~2023-08-15 12:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-15 12:48 [PATCH 0/2] ASoC: cs35l56: Don't patch firmware that is already patched Richard Fitzgerald
2023-08-15 12:48 ` [PATCH 1/2] ASoC: wm_adsp: Support powering-up DSP without trying to load firmware Richard Fitzgerald
2023-08-15 12:48 ` Richard Fitzgerald [this message]
2023-08-15 19:17 ` [PATCH 0/2] ASoC: cs35l56: Don't patch firmware that is already patched Mark Brown
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=20230815124826.5447-3-rf@opensource.cirrus.com \
--to=rf@opensource.cirrus.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@opensource.cirrus.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