From: sashiko-bot@kernel.org
To: phucduc.bui@gmail.com
Cc: Frank.Li@kernel.org, imx@lists.linux.dev
Subject: Re: [PATCH 10/11] ASoC: fsl: mpc5200_dma: Use guard() for spin locks
Date: Fri, 12 Jun 2026 13:44:19 +0000 [thread overview]
Message-ID: <20260612134420.E36631F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260612132639.78086-11-phucduc.bui@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Concurrent ALSA triggers for playback and capture substreams can race when updating the shared `regs->isr_imr.imr` hardware register, potentially dropping interrupt enable bits.
--
commit 41f1f50873252390b25ba84ac77438b563c3e7ea
Author: bui duc phuc <phucduc.bui@gmail.com>
ASoC: fsl: mpc5200_dma: Use guard() for spin locks
This commit cleans up the mpc5200_dma code by using scoped_guard() for spin
locks. This is intended to be purely a code refactoring with no behavior
change.
> diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c
> index 56e2cf2f727ba..bfedb2dea0b32 100644
> --- a/sound/soc/fsl/mpc5200_dma.c
> +++ b/sound/soc/fsl/mpc5200_dma.c
[ ... ]
> @@ -158,13 +158,13 @@ static int psc_dma_trigger(struct snd_soc_component *component,
> substream->pstr->stream, s->period_count);
> s->active = 0;
>
> - spin_lock_irqsave(&psc_dma->lock, flags);
> - bcom_disable(s->bcom_task);
> - if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE)
> - bcom_gen_bd_rx_reset(s->bcom_task);
> - else
> - bcom_gen_bd_tx_reset(s->bcom_task);
> - spin_unlock_irqrestore(&psc_dma->lock, flags);
> + scoped_guard(spinlock_irqsave, &psc_dma->lock) {
> + bcom_disable(s->bcom_task);
> + if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE)
> + bcom_gen_bd_rx_reset(s->bcom_task);
> + else
> + bcom_gen_bd_tx_reset(s->bcom_task);
> + }
>
> break;
>
[Severity: High]
This is a pre-existing issue, but can concurrent ALSA triggers for playback
and capture substreams race when updating the shared regs->isr_imr.imr hardware
register?
Looking down at the end of psc_dma_trigger(), the interrupt mask is updated
entirely outside of the psc_dma->lock:
/* Update interrupt enable settings */
imr = 0;
if (psc_dma->playback.active)
imr |= MPC52xx_PSC_IMR_TXEMP;
if (psc_dma->capture.active)
imr |= MPC52xx_PSC_IMR_ORERR;
out_be16(®s->isr_imr.imr, psc_dma->imr | imr);
If CPU1 triggers playback and CPU2 triggers capture simultaneously, could
they both read stale values for the other stream's active flag?
If so, one of the concurrent writes to regs->isr_imr.imr would overwrite
the other, potentially dropping either the MPC52xx_PSC_IMR_TXEMP or
MPC52xx_PSC_IMR_ORERR bit. This could leave the corresponding stream without
interrupts and stall the audio stream indefinitely.
Since this patch is refactoring the locking in this function, would it make
sense to expand the scope of the new scoped_guard to cover the s->active
updates and this hardware register write?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260612132639.78086-1-phucduc.bui@gmail.com?part=10
next prev parent reply other threads:[~2026-06-12 13:44 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-12 13:26 [PATCH 00/11] ASoC: fsl: Use guard() for mutex & spin locks phucduc.bui
2026-06-12 13:26 ` [PATCH 01/11] ASoC: fsl_asrc: Use guard() for " phucduc.bui
2026-06-12 13:38 ` sashiko-bot
2026-06-12 13:26 ` [PATCH 02/11] ASoC: fsl_audmix: " phucduc.bui
2026-06-12 13:26 ` [PATCH 03/11] ASoC: fsl_easrc: " phucduc.bui
2026-06-12 13:36 ` sashiko-bot
2026-06-12 13:26 ` [PATCH 04/11] ASoC: fsl_esai: " phucduc.bui
2026-06-12 13:26 ` [PATCH 05/11] ASoC: fsl_spdif: " phucduc.bui
2026-06-12 13:38 ` sashiko-bot
2026-06-12 13:26 ` [PATCH 06/11] ASoC: fsl_ssi: Use guard() for mutex locks phucduc.bui
2026-06-12 13:26 ` [PATCH 07/11] ASoC: fsl_xcvr: Use guard() for spin locks phucduc.bui
2026-06-12 13:37 ` sashiko-bot
2026-06-12 13:26 ` [PATCH 08/11] ASoC: imx-audio-rpmsg: " phucduc.bui
2026-06-12 13:46 ` sashiko-bot
2026-06-12 13:26 ` [PATCH 09/11] ASoC: fsl_rpmsg: Use guard() for mutex & " phucduc.bui
2026-06-12 13:42 ` sashiko-bot
2026-06-12 13:26 ` [PATCH 10/11] ASoC: fsl: mpc5200_dma: Use guard() for " phucduc.bui
2026-06-12 13:44 ` sashiko-bot [this message]
2026-06-12 13:26 ` [PATCH 11/11] ASoC: fsl: mpc5200_psc_ac97: Use guard() for mutex locks phucduc.bui
2026-06-12 13:42 ` sashiko-bot
2026-06-12 15:05 ` Mark Brown
2026-06-12 21:42 ` Bui Duc Phuc
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260612134420.E36631F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=imx@lists.linux.dev \
--cc=phucduc.bui@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.