* [PATCH] firmware: cs_dsp: Take pwr_lock around reading controls debugfs
@ 2025-11-27 11:32 Richard Fitzgerald
2025-11-27 16:36 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Richard Fitzgerald @ 2025-11-27 11:32 UTC (permalink / raw)
To: broonie; +Cc: linux-sound, linux-kernel, patches
In cs_dsp_debugfs_read_controls_show() take the pwr_lock mutex
around the list walk. This protects against debugfs returning
a partial set of new controls if those controls are being added
to the list while it is being walked.
Controls are never deleted from this list, and are only added to
the end of the list. So there was never a danger of following a
stale pointer to garbage.
The worst case was that the printed list is truncated if it saw an
entry that was the list end just before a new entry was appended to
the list.
With the original code, the truncated list from the debugfs could
show only _some_ of the new entries. This could be confusing because
it appears that some new entries are missing.
Adding the mutex means that the debugfs read provides an atomic view.
Either it shows the old content before any of the new controls were
added; or it shows the new content after all the new controls are
added.
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
---
drivers/firmware/cirrus/cs_dsp.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/firmware/cirrus/cs_dsp.c b/drivers/firmware/cirrus/cs_dsp.c
index dfac821bb5fb..60a2061c444c 100644
--- a/drivers/firmware/cirrus/cs_dsp.c
+++ b/drivers/firmware/cirrus/cs_dsp.c
@@ -438,6 +438,8 @@ static int cs_dsp_debugfs_read_controls_show(struct seq_file *s, void *ignored)
struct cs_dsp_coeff_ctl *ctl;
unsigned int reg;
+ guard(mutex)(&dsp->pwr_lock);
+
list_for_each_entry(ctl, &dsp->ctl_list, list) {
cs_dsp_coeff_base_reg(ctl, ®, 0);
seq_printf(s, "%22.*s: %#8x %s:%08x %#8x %s %#8x %#4x %c%c%c%c %s %s\n",
--
2.47.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] firmware: cs_dsp: Take pwr_lock around reading controls debugfs
2025-11-27 11:32 [PATCH] firmware: cs_dsp: Take pwr_lock around reading controls debugfs Richard Fitzgerald
@ 2025-11-27 16:36 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2025-11-27 16:36 UTC (permalink / raw)
To: Richard Fitzgerald; +Cc: linux-sound, linux-kernel, patches
On Thu, 27 Nov 2025 11:32:38 +0000, Richard Fitzgerald wrote:
> In cs_dsp_debugfs_read_controls_show() take the pwr_lock mutex
> around the list walk. This protects against debugfs returning
> a partial set of new controls if those controls are being added
> to the list while it is being walked.
>
> Controls are never deleted from this list, and are only added to
> the end of the list. So there was never a danger of following a
> stale pointer to garbage.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/1] firmware: cs_dsp: Take pwr_lock around reading controls debugfs
commit: ed6e90cb9fe53aba4750be50c1a355d676b7d69c
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-11-27 16:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-27 11:32 [PATCH] firmware: cs_dsp: Take pwr_lock around reading controls debugfs Richard Fitzgerald
2025-11-27 16:36 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®