public inbox for linuxppc-dev@ozlabs.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: fsl_xcvr: fix missing lock in fsl_xcvr_mode_put()
@ 2026-02-02 17:41 Ziyi Guo
  2026-02-04 13:03 ` Mark Brown
  2026-02-10  7:18 ` Alexander Stein
  0 siblings, 2 replies; 5+ messages in thread
From: Ziyi Guo @ 2026-02-02 17:41 UTC (permalink / raw)
  To: Shengjiu Wang, Xiubo Li
  Cc: Fabio Estevam, Nicolin Chen, Mark Brown, Liam Girdwood,
	Jaroslav Kysela, Takashi Iwai, linux-sound, linuxppc-dev,
	linux-kernel, Ziyi Guo

fsl_xcvr_activate_ctl() has 
lockdep_assert_held(&card->snd_card->controls_rwsem),
but fsl_xcvr_mode_put() calls it without acquiring this lock.

Other callers of fsl_xcvr_activate_ctl() in fsl_xcvr_startup() and
fsl_xcvr_shutdown() properly acquire the lock with down_read()/up_read().

Add the missing down_read()/up_read() calls around fsl_xcvr_activate_ctl()
in fsl_xcvr_mode_put() to fix the lockdep assertion and prevent potential
race conditions when multiple userspace threads access the control.

Signed-off-by: Ziyi Guo <n7l8m4@u.northwestern.edu>
---
 sound/soc/fsl/fsl_xcvr.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sound/soc/fsl/fsl_xcvr.c b/sound/soc/fsl/fsl_xcvr.c
index a268fb81a2f8..0b9dd64b9a82 100644
--- a/sound/soc/fsl/fsl_xcvr.c
+++ b/sound/soc/fsl/fsl_xcvr.c
@@ -223,10 +223,13 @@ static int fsl_xcvr_mode_put(struct snd_kcontrol *kcontrol,
 
 	xcvr->mode = snd_soc_enum_item_to_val(e, item[0]);
 
+	down_read(&card->snd_card->controls_rwsem);
 	fsl_xcvr_activate_ctl(dai, fsl_xcvr_arc_mode_kctl.name,
 			      (xcvr->mode == FSL_XCVR_MODE_ARC));
 	fsl_xcvr_activate_ctl(dai, fsl_xcvr_earc_capds_kctl.name,
 			      (xcvr->mode == FSL_XCVR_MODE_EARC));
+	up_read(&card->snd_card->controls_rwsem);
+
 	/* Allow playback for SPDIF only */
 	rtd = snd_soc_get_pcm_runtime(card, card->dai_link);
 	rtd->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream_count =
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] ASoC: fsl_xcvr: fix missing lock in fsl_xcvr_mode_put()
  2026-02-02 17:41 [PATCH] ASoC: fsl_xcvr: fix missing lock in fsl_xcvr_mode_put() Ziyi Guo
@ 2026-02-04 13:03 ` Mark Brown
  2026-02-10  7:18 ` Alexander Stein
  1 sibling, 0 replies; 5+ messages in thread
From: Mark Brown @ 2026-02-04 13:03 UTC (permalink / raw)
  To: Shengjiu Wang, Xiubo Li, Ziyi Guo
  Cc: Fabio Estevam, Nicolin Chen, Liam Girdwood, Jaroslav Kysela,
	Takashi Iwai, linux-sound, linuxppc-dev, linux-kernel

On Mon, 02 Feb 2026 17:41:12 +0000, Ziyi Guo wrote:
> fsl_xcvr_activate_ctl() has
> lockdep_assert_held(&card->snd_card->controls_rwsem),
> but fsl_xcvr_mode_put() calls it without acquiring this lock.
> 
> Other callers of fsl_xcvr_activate_ctl() in fsl_xcvr_startup() and
> fsl_xcvr_shutdown() properly acquire the lock with down_read()/up_read().
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: fsl_xcvr: fix missing lock in fsl_xcvr_mode_put()
      commit: f514248727606b9087bc38a284ff686e0093abf1

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] 5+ messages in thread

* Re: [PATCH] ASoC: fsl_xcvr: fix missing lock in fsl_xcvr_mode_put()
  2026-02-02 17:41 [PATCH] ASoC: fsl_xcvr: fix missing lock in fsl_xcvr_mode_put() Ziyi Guo
  2026-02-04 13:03 ` Mark Brown
@ 2026-02-10  7:18 ` Alexander Stein
  2026-02-10 13:55   ` Ziyi Guo
  1 sibling, 1 reply; 5+ messages in thread
From: Alexander Stein @ 2026-02-10  7:18 UTC (permalink / raw)
  To: Shengjiu Wang, Xiubo Li, Ziyi Guo
  Cc: Fabio Estevam, Nicolin Chen, Mark Brown, Liam Girdwood,
	Jaroslav Kysela, Takashi Iwai, linux-sound, linuxppc-dev,
	linux-kernel, Ziyi Guo

Hi,

Am Montag, 2. Februar 2026, 18:41:12 CET schrieb Ziyi Guo:
> fsl_xcvr_activate_ctl() has 
> lockdep_assert_held(&card->snd_card->controls_rwsem),
> but fsl_xcvr_mode_put() calls it without acquiring this lock.
> 
> Other callers of fsl_xcvr_activate_ctl() in fsl_xcvr_startup() and
> fsl_xcvr_shutdown() properly acquire the lock with down_read()/up_read().
> 
> Add the missing down_read()/up_read() calls around fsl_xcvr_activate_ctl()
> in fsl_xcvr_mode_put() to fix the lockdep assertion and prevent potential
> race conditions when multiple userspace threads access the control.
> 
> Signed-off-by: Ziyi Guo <n7l8m4@u.northwestern.edu>
> ---
>  sound/soc/fsl/fsl_xcvr.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/sound/soc/fsl/fsl_xcvr.c b/sound/soc/fsl/fsl_xcvr.c
> index a268fb81a2f8..0b9dd64b9a82 100644
> --- a/sound/soc/fsl/fsl_xcvr.c
> +++ b/sound/soc/fsl/fsl_xcvr.c
> @@ -223,10 +223,13 @@ static int fsl_xcvr_mode_put(struct snd_kcontrol *kcontrol,
>  
>  	xcvr->mode = snd_soc_enum_item_to_val(e, item[0]);
>  
> +	down_read(&card->snd_card->controls_rwsem);

This lock causes a blocked task on my TQMa8MPxL based board:

INFO: task alsactl:1969 blocked for more than 120 seconds.
      Tainted: G        W           6.19.0-next-20260209+ #3331
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:alsactl         state:D stack:0     pid:1969  tgid:1969  ppid:1      task_flags:0x400100 flags:0x00000a01
Call trace:
 __switch_to+0xdc/0x120 (T)
 __schedule+0x258/0x790
 schedule+0x30/0xb0
 schedule_preempt_disabled+0x20/0x40
 rwsem_down_read_slowpath+0x214/0x68c
 down_read+0xb0/0xb8
 fsl_xcvr_mode_put+0x4c/0xc0 [snd_soc_fsl_xcvr ac1b31380c6a6ea0d613bd5f78489e314a40f91f]
 snd_ctl_elem_write+0xdc/0x180 [snd 852e63996474051c57bcd1a86ebfd81083073853]
 snd_ctl_ioctl+0x7a4/0xaec [snd 852e63996474051c57bcd1a86ebfd81083073853]
 __arm64_sys_ioctl+0x9c/0xe4
 invoke_syscall.constprop.0+0x58/0xcc
 el0_svc_common.constprop.0+0xac/0xd4
 do_el0_svc+0x18/0x20
 el0_svc+0x24/0xa0
 el0t_64_sync_handler+0x98/0xdc
 el0t_64_sync+0x154/0x158
INFO: task alsactl:1969 <reader> blocked on an rw-semaphore likely owned by task alsactl:1969 <writer>

Best regards,
Alexander

>  	fsl_xcvr_activate_ctl(dai, fsl_xcvr_arc_mode_kctl.name,
>  			      (xcvr->mode == FSL_XCVR_MODE_ARC));
>  	fsl_xcvr_activate_ctl(dai, fsl_xcvr_earc_capds_kctl.name,
>  			      (xcvr->mode == FSL_XCVR_MODE_EARC));
> +	up_read(&card->snd_card->controls_rwsem);
> +
>  	/* Allow playback for SPDIF only */
>  	rtd = snd_soc_get_pcm_runtime(card, card->dai_link);
>  	rtd->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream_count =
> 


-- 
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.tq-group.com/




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ASoC: fsl_xcvr: fix missing lock in fsl_xcvr_mode_put()
  2026-02-10  7:18 ` Alexander Stein
@ 2026-02-10 13:55   ` Ziyi Guo
  2026-02-10 13:57     ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Ziyi Guo @ 2026-02-10 13:55 UTC (permalink / raw)
  To: Alexander Stein
  Cc: Shengjiu Wang, Xiubo Li, Fabio Estevam, Nicolin Chen, Mark Brown,
	Liam Girdwood, Jaroslav Kysela, Takashi Iwai, linux-sound,
	linuxppc-dev, linux-kernel

>
> This lock causes a blocked task on my TQMa8MPxL based board:
>
> INFO: task alsactl:1969 blocked for more than 120 seconds.
>       Tainted: G        W           6.19.0-next-20260209+ #3331
> "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
> task:alsactl         state:D stack:0     pid:1969  tgid:1969  ppid:1      task_flags:0x400100 flags:0x00000a01
> Call trace:
>  __switch_to+0xdc/0x120 (T)
>  __schedule+0x258/0x790
>  schedule+0x30/0xb0
>  schedule_preempt_disabled+0x20/0x40
>  rwsem_down_read_slowpath+0x214/0x68c
>  down_read+0xb0/0xb8
>  fsl_xcvr_mode_put+0x4c/0xc0 [snd_soc_fsl_xcvr ac1b31380c6a6ea0d613bd5f78489e314a40f91f]
>  snd_ctl_elem_write+0xdc/0x180 [snd 852e63996474051c57bcd1a86ebfd81083073853]
>  snd_ctl_ioctl+0x7a4/0xaec [snd 852e63996474051c57bcd1a86ebfd81083073853]
>  __arm64_sys_ioctl+0x9c/0xe4
>  invoke_syscall.constprop.0+0x58/0xcc
>  el0_svc_common.constprop.0+0xac/0xd4
>  do_el0_svc+0x18/0x20
>  el0_svc+0x24/0xa0
>  el0t_64_sync_handler+0x98/0xdc
>  el0t_64_sync+0x154/0x158
> INFO: task alsactl:1969 <reader> blocked on an rw-semaphore likely owned by task alsactl:1969 <writer>

Thanks Alexander for reminding this, it seems that in the context of
the whole put operation, the lock is held through upper ALSA core
layer, so we don't need to add lock protection simply for
fsl_xcvr_activate_ctl() in the driver layer.

Thanks for your time and apologies for the inconvenience. I think we
can drop this patch.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ASoC: fsl_xcvr: fix missing lock in fsl_xcvr_mode_put()
  2026-02-10 13:55   ` Ziyi Guo
@ 2026-02-10 13:57     ` Mark Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2026-02-10 13:57 UTC (permalink / raw)
  To: Ziyi Guo
  Cc: Alexander Stein, Shengjiu Wang, Xiubo Li, Fabio Estevam,
	Nicolin Chen, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
	linux-sound, linuxppc-dev, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 197 bytes --]

On Tue, Feb 10, 2026 at 07:55:28AM -0600, Ziyi Guo wrote:

> Thanks for your time and apologies for the inconvenience. I think we
> can drop this patch.

Please send a revert explaining the issue.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-02-10 13:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-02 17:41 [PATCH] ASoC: fsl_xcvr: fix missing lock in fsl_xcvr_mode_put() Ziyi Guo
2026-02-04 13:03 ` Mark Brown
2026-02-10  7:18 ` Alexander Stein
2026-02-10 13:55   ` Ziyi Guo
2026-02-10 13:57     ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox