[PATCH] firmware: cs_dsp: fix missing pwr_lock in cs_dsp_signal_event_controls()

Ziyi Guo posted 1 patch 6 days, 7 hours ago
drivers/firmware/cirrus/cs_dsp.c | 4 ++++
1 file changed, 4 insertions(+)
[PATCH] firmware: cs_dsp: fix missing pwr_lock in cs_dsp_signal_event_controls()
Posted by Ziyi Guo 6 days, 7 hours ago
cs_dsp_signal_event_controls() calls cs_dsp_coeff_write_acked_control()
which has lockdep_assert_held(&dsp->pwr_lock), but the lock is not held.

Add mutex_lock()/mutex_unlock() around the control list iteration in
cs_dsp_signal_event_controls() to fix the missing lock protection.

Signed-off-by: Ziyi Guo <n7l8m4@u.northwestern.edu>
---
 drivers/firmware/cirrus/cs_dsp.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/firmware/cirrus/cs_dsp.c b/drivers/firmware/cirrus/cs_dsp.c
index 525ac0f0a75d..0067cf292c62 100644
--- a/drivers/firmware/cirrus/cs_dsp.c
+++ b/drivers/firmware/cirrus/cs_dsp.c
@@ -972,6 +972,8 @@ static void cs_dsp_signal_event_controls(struct cs_dsp *dsp,
 	struct cs_dsp_coeff_ctl *ctl;
 	int ret;
 
+	mutex_lock(&dsp->pwr_lock);
+
 	list_for_each_entry(ctl, &dsp->ctl_list, list) {
 		if (ctl->type != WMFW_CTL_TYPE_HOSTEVENT)
 			continue;
@@ -985,6 +987,8 @@ static void cs_dsp_signal_event_controls(struct cs_dsp *dsp,
 				    "Failed to send 0x%x event to alg 0x%x (%d)\n",
 				    event, ctl->alg_region.alg, ret);
 	}
+
+	mutex_unlock(&dsp->pwr_lock);
 }
 
 static void cs_dsp_free_ctl_blk(struct cs_dsp_coeff_ctl *ctl)
-- 
2.34.1
Re: [PATCH] firmware: cs_dsp: fix missing pwr_lock in cs_dsp_signal_event_controls()
Posted by Richard Fitzgerald 4 days, 19 hours ago
On 31/01/2026 10:33 pm, Ziyi Guo wrote:
> cs_dsp_signal_event_controls() calls cs_dsp_coeff_write_acked_control()
> which has lockdep_assert_held(&dsp->pwr_lock), but the lock is not held.
> 
> Add mutex_lock()/mutex_unlock() around the control list iteration in
> cs_dsp_signal_event_controls() to fix the missing lock protection.
> 
> Signed-off-by: Ziyi Guo <n7l8m4@u.northwestern.edu>

I don't think this is the correct fix.

The mutex_lock() in cs_dsp_stop() should be at the top of the function.
Compare with cs_dsp_run().
Re: [PATCH] firmware: cs_dsp: fix missing pwr_lock in cs_dsp_signal_event_controls()
Posted by Ziyi Guo 4 days, 15 hours ago
On Mon, Feb 2, 2026 at 4:58 AM Richard Fitzgerald
<rf@opensource.cirrus.com> wrote:
> I don't think this is the correct fix.
>
> The mutex_lock() in cs_dsp_stop() should be at the top of the function.
> Compare with cs_dsp_run().

Thanks for your time and review, I'll send a v2 version patch, let the
mutex_lock() be at the top of the function cs_dsp_stop().