From: Stefan Binding <sbinding@opensource.cirrus.com>
To: Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.com>
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
patches@opensource.cirrus.com,
Stefan Binding <sbinding@opensource.cirrus.com>
Subject: [PATCH v1 6/7] ALSA: hda/cs35l41: Store filenames of successfully loaded firmware and tunings
Date: Fri, 20 Nov 2026 16:10:52 +0000 [thread overview]
Message-ID: <20261120161136.157593-7-sbinding@opensource.cirrus.com> (raw)
In-Reply-To: <20261120161136.157593-1-sbinding@opensource.cirrus.com>
When the CS35L41 HDA driver loads firmware, it typically loops through
possible filenames, requesting each and stopping when it finds a valid
file.
Since firmware is sometimes reloaded - such as during system resume,
it loops through the possible filenames each time. However, since the
filename will never change, we can store the filename when we
successfully load the firmware for the first time, and reuse it later.
This ensures that the only firmware files requested by the driver in
system resume are the same as the ones cached during suspend, since
only successfully requested firmware files are cached. This prevents
unnecessary file access during resume - if a cached firmware is
requested, the cached file is used, eliminating any potential blocking
calls to the filesystem.
Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
---
sound/hda/codecs/side-codecs/cs35l41_hda.c | 47 +++++++++++++++++-----
sound/hda/codecs/side-codecs/cs35l41_hda.h | 3 ++
2 files changed, 40 insertions(+), 10 deletions(-)
diff --git a/sound/hda/codecs/side-codecs/cs35l41_hda.c b/sound/hda/codecs/side-codecs/cs35l41_hda.c
index a0e2e0c5addf..6f4b2088c5fe 100644
--- a/sound/hda/codecs/side-codecs/cs35l41_hda.c
+++ b/sound/hda/codecs/side-codecs/cs35l41_hda.c
@@ -142,6 +142,7 @@ static int cs35l41_request_tuning_param_file(struct cs35l41_hda *cs35l41, char *
dev_dbg(cs35l41->dev, "Failed to request '%s'\n", *filename);
kfree(*filename);
*filename = NULL;
+ cs35l41->skip_tuning_params = true;
}
return ret;
@@ -308,6 +309,7 @@ static int cs35l41_fallback_firmware_file(struct cs35l41_hda *cs35l41,
if (ret) {
release_firmware(*wmfw_firmware);
kfree(*wmfw_filename);
+ *wmfw_filename = NULL;
goto err;
}
return 0;
@@ -325,6 +327,25 @@ static int cs35l41_request_firmware_files(struct cs35l41_hda *cs35l41,
{
int ret;
+ if (*wmfw_filename) {
+ ret = firmware_request_nowarn(wmfw_firmware, *wmfw_filename, cs35l41->dev);
+ if (ret != 0) {
+ dev_err(cs35l41->dev, "Failed to request known file '%s'\n",
+ *wmfw_filename);
+ return ret;
+ }
+ if (*coeff_filename) {
+ ret = firmware_request_nowarn(coeff_firmware, *coeff_filename,
+ cs35l41->dev);
+ if (ret != 0) {
+ dev_err(cs35l41->dev, "Failed to request known file '%s'\n",
+ *coeff_filename);
+ return ret;
+ }
+ }
+ return 0;
+ }
+
if (cs35l41->speaker_id > -1) {
ret = cs35l41_request_firmware_files_spkid(cs35l41, wmfw_firmware, wmfw_filename,
coeff_firmware, coeff_filename);
@@ -374,6 +395,7 @@ static int cs35l41_request_firmware_files(struct cs35l41_hda *cs35l41,
coeff_err:
release_firmware(*wmfw_firmware);
kfree(*wmfw_filename);
+ *wmfw_filename = NULL;
fallback:
return cs35l41_fallback_firmware_file(cs35l41, wmfw_firmware, wmfw_filename,
coeff_firmware, coeff_filename);
@@ -514,6 +536,9 @@ static int cs35l41_load_tuning_params(struct cs35l41_hda *cs35l41, char *tuning_
char *tuning_param_filename __free(kfree) = NULL;
int ret;
+ if (cs35l41->skip_tuning_params)
+ return 0;
+
ret = cs35l41_request_tuning_param_file(cs35l41, tuning_filename, &tuning_param_file,
&tuning_param_filename, cs35l41->acpi_subsystem_id);
if (ret) {
@@ -538,8 +563,6 @@ static int cs35l41_init_dsp(struct cs35l41_hda *cs35l41)
const struct firmware *coeff_firmware __free(firmware) = NULL;
const struct firmware *wmfw_firmware __free(firmware) = NULL;
struct cs_dsp *dsp = &cs35l41->cs_dsp;
- char *coeff_filename __free(kfree) = NULL;
- char *wmfw_filename __free(kfree) = NULL;
int ret;
if (!cs35l41->halo_initialized) {
@@ -554,23 +577,23 @@ static int cs35l41_init_dsp(struct cs35l41_hda *cs35l41)
cs35l41_set_default_tuning_params(cs35l41);
- ret = cs35l41_request_firmware_files(cs35l41, &wmfw_firmware, &wmfw_filename,
- &coeff_firmware, &coeff_filename);
+ ret = cs35l41_request_firmware_files(cs35l41, &wmfw_firmware, &cs35l41->wmfw_filename,
+ &coeff_firmware, &cs35l41->coeff_filename);
if (ret < 0)
return ret;
- dev_dbg(cs35l41->dev, "Loading WMFW Firmware: %s\n", wmfw_filename);
- if (coeff_filename) {
- dev_dbg(cs35l41->dev, "Loading Coefficient File: %s\n", coeff_filename);
- ret = cs35l41_load_tuning_params(cs35l41, coeff_filename);
+ dev_dbg(cs35l41->dev, "Loading WMFW Firmware: %s\n", cs35l41->wmfw_filename);
+ if (cs35l41->coeff_filename) {
+ dev_dbg(cs35l41->dev, "Loading Coefficient File: %s\n", cs35l41->coeff_filename);
+ ret = cs35l41_load_tuning_params(cs35l41, cs35l41->coeff_filename);
if (ret)
dev_warn(cs35l41->dev, "Unable to load Tuning Parameters: %d\n", ret);
} else {
dev_warn(cs35l41->dev, "No Coefficient File available.\n");
}
- ret = cs_dsp_power_up(dsp, wmfw_firmware, wmfw_filename, coeff_firmware, coeff_filename,
- CS35L41_HDA_FW_ID);
+ ret = cs_dsp_power_up(dsp, wmfw_firmware, cs35l41->wmfw_filename, coeff_firmware,
+ cs35l41->coeff_filename, CS35L41_HDA_FW_ID);
if (ret) {
cs35l41_set_default_tuning_params(cs35l41);
return ret;
@@ -600,6 +623,10 @@ static void cs35l41_remove_dsp(struct cs35l41_hda *cs35l41)
cs35l41_shutdown_dsp(cs35l41);
cs_dsp_remove(dsp);
cs35l41->halo_initialized = false;
+ kfree(cs35l41->wmfw_filename);
+ kfree(cs35l41->coeff_filename);
+ cs35l41->wmfw_filename = NULL;
+ cs35l41->coeff_filename = NULL;
}
/* Protection release cycle to get the speaker out of Safe-Mode */
diff --git a/sound/hda/codecs/side-codecs/cs35l41_hda.h b/sound/hda/codecs/side-codecs/cs35l41_hda.h
index 6fea4b2ad0ac..64ee70c31a43 100644
--- a/sound/hda/codecs/side-codecs/cs35l41_hda.h
+++ b/sound/hda/codecs/side-codecs/cs35l41_hda.h
@@ -93,7 +93,10 @@ struct cs35l41_hda {
unsigned int tuning_gain;
struct cirrus_amp_cal_data cal_data;
bool cal_data_valid;
+ bool skip_tuning_params;
+ char *coeff_filename;
+ char *wmfw_filename;
};
enum halo_state {
--
2.43.0
next prev parent reply other threads:[~2026-11-20 16:12 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 16:10 [PATCH v1 0/7] Fixes and improvements in CS35L41 HDA driver for System Suspend/Resume Stefan Binding
2026-11-20 16:10 ` [PATCH v1 1/7] ALSA: hda: cs35l41: Remove redundant lock_system_sleep() calls Stefan Binding
2026-11-20 16:10 ` [PATCH v1 2/7] ASoC: cs35l41: Prevent software reset when using SPI Stefan Binding
2026-11-20 16:22 ` sashiko-bot
2026-11-20 16:10 ` [PATCH v1 3/7] ALSA: hda: cs35l41: Unset irq if not used or configured Stefan Binding
2026-11-20 16:10 ` [PATCH v1 4/7] ALSA: hda/cs35l41: Split System Suspend/Resume callbacks Stefan Binding
2026-11-20 16:27 ` sashiko-bot
2026-11-20 16:10 ` [PATCH v1 5/7] ALSA: hda/cs35l41: Remove support for alternative firmware types Stefan Binding
2026-11-20 16:10 ` Stefan Binding [this message]
2026-11-20 16:10 ` [PATCH v1 7/7] ALSA: hda/cs35l41: rework how firmware requests are queued and flushed to prevent races Stefan Binding
2026-11-20 16:41 ` sashiko-bot
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=20261120161136.157593-7-sbinding@opensource.cirrus.com \
--to=sbinding@opensource.cirrus.com \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=perex@perex.cz \
--cc=tiwai@suse.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