Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: shengjiu.wang@oss.nxp.com
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org,
	Frank.Li@kernel.org, imx@lists.linux.dev, robh@kernel.org
Subject: Re: [PATCH v4 5/5] ASoC: fsl_easrc: expose individual DAIs per conversion path
Date: Thu, 13 Aug 2026 07:10:05 +0000	[thread overview]
Message-ID: <20260813071005.700121F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260813070020.719810-6-shengjiu.wang@oss.nxp.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] Read-Modify-Write (RMW) on a Write-1-to-Clear (W1C) interrupt status register causes unintentional clearing of concurrent interrupt flags.
- [High] Calling hw_params multiple times for the same stream leaks EASRC hardware contexts and available channels, leading to Use-After-Free (UAF).
--

--- Patch [5]: [PATCH v4 5/5] ASoC: fsl_easrc: expose individual DAIs per conversion path ---
commit 6668df3f25b7ce9103114dd835e72d2e72b096cc
Author: Shengjiu Wang <shengjiu.wang@nxp.com>

ASoC: fsl_easrc: expose individual DAIs per conversion path

The i.MX EASRC hardware supports four independent conversion contexts.
This commit replaces the single fsl_easrc_dai instance with an array of
four DAI drivers to allow up to four independent conversion paths to be
active at the same time.

> diff --git a/sound/soc/fsl/fsl_easrc.c b/sound/soc/fsl/fsl_easrc.c
> index 2b8319b8a609a..c2f0524e949e9 100644
> --- a/sound/soc/fsl/fsl_easrc.c
> +++ b/sound/soc/fsl/fsl_easrc.c
> @@ -1589,27 +1589,99 @@ static const struct snd_soc_dai_ops fsl_easrc_dai_ops = {
>  	.hw_free	= fsl_easrc_hw_free,
>  };
>  
> -static struct snd_soc_dai_driver fsl_easrc_dai = {
[ ... ]
> +static struct snd_soc_dai_driver fsl_easrc_dai[] = {
> +	{
> +		.name = "easrc-0",
[ ... ]
> +	{
> +		.name = "easrc-3",
> +		.playback = {
> +			.stream_name = "ASRC3-Playback",
> +			.channels_min = 1,
> +			.channels_max = 32,
> +			.rate_min = 8000,
> +			.rate_max = 768000,
> +			.rates = SNDRV_PCM_RATE_KNOT,
> +			.formats = FSL_EASRC_FORMATS,
> +		},
> +		.capture = {
> +			.stream_name = "ASRC3-Capture",
> +			.channels_min = 1,
> +			.channels_max = 32,
> +			.rate_min = 8000,
> +			.rate_max = 768000,
> +			.rates = SNDRV_PCM_RATE_KNOT,
> +			.formats = FSL_EASRC_FORMATS |
> +				   SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE,
> +		},
> +		.ops = &fsl_easrc_dai_ops,
>  	},
> -	.ops = &fsl_easrc_dai_ops,
>  };

[Severity: High]
This isn't a bug introduced by this patch, but since multiple DAIs now
allow concurrent streams, could this read-modify-write operation in
fsl_easrc_stop_context() cause issues with interrupt handling?

sound/soc/fsl/fsl_easrc.c:fsl_easrc_stop_context() {
	...
	regmap_write_bits(easrc->regmap,
			  REG_EASRC_IRQF,
			  EASRC_IRQF_RSD(1 << ctx->index),
			  EASRC_IRQF_RSD(1 << ctx->index));
	...
}

Because REG_EASRC_IRQF is a write-1-to-clear register, will this write
1s back to all currently pending interrupt flags?

If two streams stop simultaneously, could one CPU unintentionally clear
the run-stop-done bit of the other context, causing the other CPU's
polling loop to time out?

[Severity: High]
This is a pre-existing issue, but with up to four independent conversion
paths active, is it possible to leak hardware contexts if the ALSA core
calls hw_params multiple times for the same stream?

In sound/soc/fsl/fsl_easrc.c:fsl_easrc_hw_params():

	ret = fsl_easrc_request_context(channels, ctx);

This unconditionally assigns a new context. Then in
fsl_easrc_request_context():

	ctx->index = index;
	ctx->channels = channels;
	easrc->pair[index] = ctx;
	easrc->channel_avail -= channels;

If hw_params is called multiple times without an intermediate hw_free,
won't this leak channels and leave a dangling pointer in the old slot
when ctx is eventually freed?

>  
>  static const struct snd_soc_component_driver fsl_easrc_component = {
[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260813070020.719810-1-shengjiu.wang@oss.nxp.com?part=5

      reply	other threads:[~2026-08-13  7:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-13  7:00 [PATCH v4 0/5] ASoC: fsl_asrc/fsl_easrc: expose per-pair/context DAIs and fix DMA race shengjiu.wang
2026-08-13  7:00 ` [PATCH v4 1/5] ASoC: dt-bindings: fsl,imx-asrc: update port binding to support multiple paths shengjiu.wang
2026-08-13  7:00 ` [PATCH v4 2/5] ASoC: dt-bindings: fsl,easrc: add ports binding for multiple conversion paths shengjiu.wang
2026-08-13  7:00 ` [PATCH v4 3/5] ASoC: fsl_asrc/fsl_easrc: move DMA params into pair/context struct shengjiu.wang
2026-08-13  7:09   ` sashiko-bot
2026-08-13 16:54     ` Frank Li
2026-08-13 16:52   ` Frank Li
2026-08-13  7:00 ` [PATCH v4 4/5] ASoC: fsl_asrc: expose individual DAIs per conversion path shengjiu.wang
2026-08-13  7:14   ` sashiko-bot
2026-08-13  7:00 ` [PATCH v4 5/5] ASoC: fsl_easrc: " shengjiu.wang
2026-08-13  7:10   ` sashiko-bot [this message]

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=20260813071005.700121F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=shengjiu.wang@oss.nxp.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox