* [PATCH v1 0/3] Support wm_adsp hibernation for runtime suspend
@ 2026-02-23 16:05 Stefan Binding
2026-02-23 16:05 ` [PATCH v1 1/3] firmware: cs_dsp: Add API to hibernate the DSP Stefan Binding
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Stefan Binding @ 2026-02-23 16:05 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-sound, linux-kernel, patches, Stefan Binding
When the CS35L41 driver suspends, it is put into hibernation, and
the regmap goes into cache_only, but the firmware is still running, and
wm_adsp is not stopped. If userspace attempts to read a firmware
control, it will perform a regmap_raw_read() and this will produce an
error in the kernel log.
To prevent these spurious errors, add an apis into cs_dsp and wm_adsp
to allow wm_adsp to hibernate. In this hibernation mode, reads or
writes to the dsp controls would be rejected with -EPERM rather than
-EBUSY, and no error will be printed to the kernel log.
Stefan Binding (3):
firmware: cs_dsp: Add API to hibernate the DSP
ASoC: codecs: wm_adsp: Allow wm_adsp to hibernate without stopping DSP
ASoC: cs35l41: Hibernate wm_adsp on runtime suspend
drivers/firmware/cirrus/cs_dsp.c | 49 +++++++++++++++++++++++---
include/linux/firmware/cirrus/cs_dsp.h | 3 ++
sound/soc/codecs/cs35l41.c | 5 +++
sound/soc/codecs/wm_adsp.c | 6 ++++
sound/soc/codecs/wm_adsp.h | 1 +
5 files changed, 60 insertions(+), 4 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v1 1/3] firmware: cs_dsp: Add API to hibernate the DSP
2026-02-23 16:05 [PATCH v1 0/3] Support wm_adsp hibernation for runtime suspend Stefan Binding
@ 2026-02-23 16:05 ` Stefan Binding
2026-02-23 16:43 ` Richard Fitzgerald
2026-02-23 18:05 ` kernel test robot
2026-02-23 16:05 ` [PATCH v1 2/3] ASoC: codecs: wm_adsp: Allow wm_adsp to hibernate without stopping DSP Stefan Binding
2026-02-23 16:05 ` [PATCH v1 3/3] ASoC: cs35l41: Hibernate wm_adsp on runtime suspend Stefan Binding
2 siblings, 2 replies; 7+ messages in thread
From: Stefan Binding @ 2026-02-23 16:05 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-sound, linux-kernel, patches, Stefan Binding
For some parts, the DSP is kept running when in low power mode
(hibernation), leaving the firmware ALSA controls enabled, but the
registers are inaccessible. Attempts to access volatile firmware
controls whilst in this state would produce errors in the kernel log
due to a regmap_raw_read() into DSP registers whilst the regmap is in
cache_only.
To remove this error log, add a hibernating flag to indicate that the
controls are inaccessible, so we no longer try to read or write to the
registers whilst the regmap is in cache_only.
This would still produce an error when trying to read or write to these
controls, but this would be a different error (-EPERM instead of
-EBUSY), and would not produce a spurious error log in the kernel.
Upon wake from hibernation, the control caches are re-synced to the
hardware, if the DSP is running.
Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
---
drivers/firmware/cirrus/cs_dsp.c | 49 +++++++++++++++++++++++---
include/linux/firmware/cirrus/cs_dsp.h | 3 ++
2 files changed, 48 insertions(+), 4 deletions(-)
diff --git a/drivers/firmware/cirrus/cs_dsp.c b/drivers/firmware/cirrus/cs_dsp.c
index b4f1c01e3b5b..aed1b4214621 100644
--- a/drivers/firmware/cirrus/cs_dsp.c
+++ b/drivers/firmware/cirrus/cs_dsp.c
@@ -515,6 +515,7 @@ void cs_dsp_init_debugfs(struct cs_dsp *dsp, struct dentry *debugfs_root)
debugfs_create_bool("booted", 0444, root, &dsp->booted);
debugfs_create_bool("running", 0444, root, &dsp->running);
+ debugfs_create_bool("hibernating", 0444, root, &dsp->hibernating);
debugfs_create_x32("fw_id", 0444, root, &dsp->fw_id);
debugfs_create_x32("fw_version", 0444, root, &dsp->fw_id_version);
@@ -703,7 +704,7 @@ int cs_dsp_coeff_write_acked_control(struct cs_dsp_coeff_ctl *ctl, unsigned int
lockdep_assert_held(&dsp->pwr_lock);
- if (!dsp->running)
+ if (!dsp->running || dsp->hibernating)
return -EPERM;
ret = cs_dsp_coeff_base_reg(ctl, ®, 0);
@@ -827,7 +828,7 @@ int cs_dsp_coeff_write_ctrl(struct cs_dsp_coeff_ctl *ctl,
}
ctl->set = 1;
- if (ctl->enabled && ctl->dsp->running)
+ if (ctl->enabled && ctl->dsp->running && !ctl->dsp->hibernating)
ret = cs_dsp_coeff_write_ctrl_raw(ctl, off, buf, len);
if (ret < 0)
@@ -920,12 +921,12 @@ int cs_dsp_coeff_read_ctrl(struct cs_dsp_coeff_ctl *ctl,
return -EINVAL;
if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) {
- if (ctl->enabled && ctl->dsp->running)
+ if (ctl->enabled && ctl->dsp->running && !ctl->dsp->hibernating)
return cs_dsp_coeff_read_ctrl_raw(ctl, off, buf, len);
else
return -EPERM;
} else {
- if (!ctl->flags && ctl->enabled && ctl->dsp->running)
+ if (!ctl->flags && ctl->enabled && ctl->dsp->running && !ctl->dsp->hibernating)
ret = cs_dsp_coeff_read_ctrl_raw(ctl, 0, ctl->cache, ctl->len);
if (buf != ctl->cache)
@@ -1108,6 +1109,44 @@ static int cs_dsp_create_control(struct cs_dsp *dsp,
return ret;
}
+
+/**
+ * cs_dsp_hibernate() - Disable or enable all controls for a DSP
+ * @dsp: pointer to DSP structure
+ * @hibernating: whether to set controls to cache only mode
+ *
+ * When @hibernate is true, the DSP is entering hibernation mode where the
+ * regmap is inaccessible, and all controls become cache only.
+ * When @hibernate is false, the DSP has exited hibernation mode. If the DSP
+ * is running, all controls are re-synced to the DSP.
+ *
+ */
+void cs_dsp_hibernate(struct cs_dsp *dsp, bool hibernate)
+{
+ mutex_lock(&dsp->pwr_lock);
+
+ if (!dsp->running) {
+ cs_dsp_dbg(dsp, "Cannot hibernate, DSP not running\n");
+ goto out;
+ }
+
+ if (dsp->hibernating == hibernate)
+ goto out;
+
+ cs_dsp_dbg(dsp, "Set hibernating to %d\n", hibernate);
+ dsp->hibernating = hibernate;
+
+ if (!dsp->hibernating && dsp->running) {
+ int ret = cs_dsp_coeff_sync_controls(dsp);
+
+ if (ret)
+ cs_dsp_err(dsp, "Error syncing controls: %d\n", ret);
+ }
+out:
+ mutex_unlock(&dsp->pwr_lock);
+}
+EXPORT_SYMBOL_NS_GPL(cs_dsp_hibernate, "FW_CS_DSP");
+
struct cs_dsp_coeff_parsed_alg {
int id;
const u8 *name;
@@ -2498,6 +2537,7 @@ int cs_dsp_adsp1_power_up(struct cs_dsp *dsp,
goto err_ena;
dsp->booted = true;
+ dsp->hibernating = false;
/* Start the core running */
regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30,
@@ -2776,6 +2816,7 @@ int cs_dsp_power_up(struct cs_dsp *dsp,
dsp->ops->disable_core(dsp);
dsp->booted = true;
+ dsp->hibernating = false;
mutex_unlock(&dsp->pwr_lock);
diff --git a/include/linux/firmware/cirrus/cs_dsp.h b/include/linux/firmware/cirrus/cs_dsp.h
index 0ec1cdc5585d..4e3baa557068 100644
--- a/include/linux/firmware/cirrus/cs_dsp.h
+++ b/include/linux/firmware/cirrus/cs_dsp.h
@@ -179,6 +179,7 @@ struct cs_dsp {
bool booted;
bool running;
+ bool hibernating;
struct list_head ctl_list;
@@ -354,4 +355,6 @@ int cs_dsp_chunk_write(struct cs_dsp_chunk *ch, int nbits, u32 val);
int cs_dsp_chunk_flush(struct cs_dsp_chunk *ch);
int cs_dsp_chunk_read(struct cs_dsp_chunk *ch, int nbits);
+void cs_dsp_hibernate(struct cs_dsp *dsp, bool hibernating);
+
#endif
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v1 2/3] ASoC: codecs: wm_adsp: Allow wm_adsp to hibernate without stopping DSP
2026-02-23 16:05 [PATCH v1 0/3] Support wm_adsp hibernation for runtime suspend Stefan Binding
2026-02-23 16:05 ` [PATCH v1 1/3] firmware: cs_dsp: Add API to hibernate the DSP Stefan Binding
@ 2026-02-23 16:05 ` Stefan Binding
2026-02-23 16:43 ` Richard Fitzgerald
2026-02-23 16:05 ` [PATCH v1 3/3] ASoC: cs35l41: Hibernate wm_adsp on runtime suspend Stefan Binding
2 siblings, 1 reply; 7+ messages in thread
From: Stefan Binding @ 2026-02-23 16:05 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-sound, linux-kernel, patches, Stefan Binding
Some parts do not stop the DSP core before runtime suspend, however,
this leaves the DSP controls enabled and accessible whilst the part is
suspended and the regmap is cache_only.
Add new APIs to allow for the DSP to hibernate when the part is
suspended, and the DSP is not shut down.
Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
---
sound/soc/codecs/wm_adsp.c | 6 ++++++
sound/soc/codecs/wm_adsp.h | 1 +
2 files changed, 7 insertions(+)
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index 2e23848e1dce..d95b54275b5e 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -1100,6 +1100,12 @@ void wm_adsp_stop(struct wm_adsp *dsp)
}
EXPORT_SYMBOL_GPL(wm_adsp_stop);
+void wm_adsp_hibernate(struct wm_adsp *dsp, bool hibernate)
+{
+ cs_dsp_hibernate(&dsp->cs_dsp, hibernate);
+}
+EXPORT_SYMBOL_GPL(wm_adsp_hibernate);
+
int wm_adsp_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
diff --git a/sound/soc/codecs/wm_adsp.h b/sound/soc/codecs/wm_adsp.h
index 8035fda71f8d..a9118be793d7 100644
--- a/sound/soc/codecs/wm_adsp.h
+++ b/sound/soc/codecs/wm_adsp.h
@@ -103,6 +103,7 @@ irqreturn_t wm_halo_wdt_expire(int irq, void *data);
int wm_adsp_run(struct wm_adsp *dsp);
void wm_adsp_stop(struct wm_adsp *dsp);
+void wm_adsp_hibernate(struct wm_adsp *dsp, bool hibernate);
int wm_adsp_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event);
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v1 3/3] ASoC: cs35l41: Hibernate wm_adsp on runtime suspend
2026-02-23 16:05 [PATCH v1 0/3] Support wm_adsp hibernation for runtime suspend Stefan Binding
2026-02-23 16:05 ` [PATCH v1 1/3] firmware: cs_dsp: Add API to hibernate the DSP Stefan Binding
2026-02-23 16:05 ` [PATCH v1 2/3] ASoC: codecs: wm_adsp: Allow wm_adsp to hibernate without stopping DSP Stefan Binding
@ 2026-02-23 16:05 ` Stefan Binding
2 siblings, 0 replies; 7+ messages in thread
From: Stefan Binding @ 2026-02-23 16:05 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-sound, linux-kernel, patches, Stefan Binding
When the CS35L41 driver suspends, it is put into hibernation, and
the regmap goes into cache_only, but the firmware is still running, and
wm_adsp is not stopped. If userspace attempts to read a firmware
control, it will perform a regmap_raw_read() and this will produce an
error in the kernel log. To prevent spurious errors, put the DSP into
hibernation which prevents access to the hardware for the ALSA
controls.
Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
---
sound/soc/codecs/cs35l41.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/sound/soc/codecs/cs35l41.c b/sound/soc/codecs/cs35l41.c
index ee56dfceedeb..b2a076706c79 100644
--- a/sound/soc/codecs/cs35l41.c
+++ b/sound/soc/codecs/cs35l41.c
@@ -1404,6 +1404,7 @@ static int cs35l41_runtime_suspend(struct device *dev)
if (!cs35l41->dsp.preloaded || !cs35l41->dsp.cs_dsp.running)
return 0;
+ wm_adsp_hibernate(&cs35l41->dsp, true);
cs35l41_enter_hibernate(dev, cs35l41->regmap, cs35l41->hw_cfg.bst_type);
regcache_cache_only(cs35l41->regmap, true);
@@ -1432,10 +1433,14 @@ static int cs35l41_runtime_resume(struct device *dev)
cs35l41_test_key_unlock(cs35l41->dev, cs35l41->regmap);
ret = regcache_sync(cs35l41->regmap);
cs35l41_test_key_lock(cs35l41->dev, cs35l41->regmap);
+
+ wm_adsp_hibernate(&cs35l41->dsp, false);
+
if (ret) {
dev_err(cs35l41->dev, "Failed to restore register cache: %d\n", ret);
return ret;
}
+
cs35l41_init_boost(cs35l41->dev, cs35l41->regmap, &cs35l41->hw_cfg);
return 0;
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v1 1/3] firmware: cs_dsp: Add API to hibernate the DSP
2026-02-23 16:05 ` [PATCH v1 1/3] firmware: cs_dsp: Add API to hibernate the DSP Stefan Binding
@ 2026-02-23 16:43 ` Richard Fitzgerald
2026-02-23 18:05 ` kernel test robot
1 sibling, 0 replies; 7+ messages in thread
From: Richard Fitzgerald @ 2026-02-23 16:43 UTC (permalink / raw)
To: Stefan Binding, Mark Brown; +Cc: linux-sound, linux-kernel, patches
On 23/02/2026 4:05 pm, Stefan Binding wrote:
> For some parts, the DSP is kept running when in low power mode
> (hibernation), leaving the firmware ALSA controls enabled, but the
> registers are inaccessible. Attempts to access volatile firmware
> controls whilst in this state would produce errors in the kernel log
> due to a regmap_raw_read() into DSP registers whilst the regmap is in
> cache_only.
>
> To remove this error log, add a hibernating flag to indicate that the
> controls are inaccessible, so we no longer try to read or write to the
> registers whilst the regmap is in cache_only.
>
> This would still produce an error when trying to read or write to these
> controls, but this would be a different error (-EPERM instead of
> -EBUSY), and would not produce a spurious error log in the kernel.
>
> Upon wake from hibernation, the control caches are re-synced to the
> hardware, if the DSP is running.
>
> Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
> ---
Reviewed-by: Richard Fitzgerald <rf@opensource.cirrus.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1 2/3] ASoC: codecs: wm_adsp: Allow wm_adsp to hibernate without stopping DSP
2026-02-23 16:05 ` [PATCH v1 2/3] ASoC: codecs: wm_adsp: Allow wm_adsp to hibernate without stopping DSP Stefan Binding
@ 2026-02-23 16:43 ` Richard Fitzgerald
0 siblings, 0 replies; 7+ messages in thread
From: Richard Fitzgerald @ 2026-02-23 16:43 UTC (permalink / raw)
To: Stefan Binding, Mark Brown; +Cc: linux-sound, linux-kernel, patches
On 23/02/2026 4:05 pm, Stefan Binding wrote:
> Some parts do not stop the DSP core before runtime suspend, however,
> this leaves the DSP controls enabled and accessible whilst the part is
> suspended and the regmap is cache_only.
>
> Add new APIs to allow for the DSP to hibernate when the part is
> suspended, and the DSP is not shut down.
>
> Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
> ---
Reviewed-by: Richard Fitzgerald <rf@opensource.cirrus.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1 1/3] firmware: cs_dsp: Add API to hibernate the DSP
2026-02-23 16:05 ` [PATCH v1 1/3] firmware: cs_dsp: Add API to hibernate the DSP Stefan Binding
2026-02-23 16:43 ` Richard Fitzgerald
@ 2026-02-23 18:05 ` kernel test robot
1 sibling, 0 replies; 7+ messages in thread
From: kernel test robot @ 2026-02-23 18:05 UTC (permalink / raw)
To: Stefan Binding, Mark Brown
Cc: oe-kbuild-all, linux-sound, linux-kernel, patches, Stefan Binding
Hi Stefan,
kernel test robot noticed the following build warnings:
[auto build test WARNING on broonie-sound/for-next]
[also build test WARNING on linus/master v7.0-rc1 next-20260220]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Stefan-Binding/firmware-cs_dsp-Add-API-to-hibernate-the-DSP/20260224-002158
base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
patch link: https://lore.kernel.org/r/20260223160614.754934-2-sbinding%40opensource.cirrus.com
patch subject: [PATCH v1 1/3] firmware: cs_dsp: Add API to hibernate the DSP
config: loongarch-randconfig-r071-20260224 (https://download.01.org/0day-ci/archive/20260224/202602240126.0DhinYkl-lkp@intel.com/config)
compiler: loongarch64-linux-gcc (GCC) 15.2.0
smatch version: v0.5.0-8994-gd50c5a4c
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260224/202602240126.0DhinYkl-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202602240126.0DhinYkl-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> Warning: drivers/firmware/cirrus/cs_dsp.c:1124 function parameter 'hibernate' not described in 'cs_dsp_hibernate'
>> Warning: drivers/firmware/cirrus/cs_dsp.c:1124 function parameter 'hibernate' not described in 'cs_dsp_hibernate'
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-02-23 18:09 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-23 16:05 [PATCH v1 0/3] Support wm_adsp hibernation for runtime suspend Stefan Binding
2026-02-23 16:05 ` [PATCH v1 1/3] firmware: cs_dsp: Add API to hibernate the DSP Stefan Binding
2026-02-23 16:43 ` Richard Fitzgerald
2026-02-23 18:05 ` kernel test robot
2026-02-23 16:05 ` [PATCH v1 2/3] ASoC: codecs: wm_adsp: Allow wm_adsp to hibernate without stopping DSP Stefan Binding
2026-02-23 16:43 ` Richard Fitzgerald
2026-02-23 16:05 ` [PATCH v1 3/3] ASoC: cs35l41: Hibernate wm_adsp on runtime suspend Stefan Binding
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox