Skip to content

Commit ed6e90c

Browse files
rfvirgilbroonie
authored andcommitted
firmware: cs_dsp: Take pwr_lock around reading controls debugfs
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> Link: https://patch.msgid.link/20251127113238.1251352-1-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 5d0cad4 commit ed6e90c

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

drivers/firmware/cirrus/cs_dsp.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,8 @@ static int cs_dsp_debugfs_read_controls_show(struct seq_file *s, void *ignored)
438438
struct cs_dsp_coeff_ctl *ctl;
439439
unsigned int reg;
440440

441+
guard(mutex)(&dsp->pwr_lock);
442+
441443
list_for_each_entry(ctl, &dsp->ctl_list, list) {
442444
cs_dsp_coeff_base_reg(ctl, &reg, 0);
443445
seq_printf(s, "%22.*s: %#8x %s:%08x %#8x %s %#8x %#4x %c%c%c%c %s %s\n",

0 commit comments

Comments
 (0)