All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: shengjiu.wang@oss.nxp.com
Cc: robh@kernel.org, Frank.Li@kernel.org, devicetree@vger.kernel.org,
	imx@lists.linux.dev, conor+dt@kernel.org
Subject: Re: [PATCH v3 4/5] ASoC: fsl_asrc: expose individual DAIs per conversion path
Date: Tue, 04 Aug 2026 10:20:55 +0000	[thread overview]
Message-ID: <20260804102058.1AAA21F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260804100218.49587-5-shengjiu.wang@oss.nxp.com>

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

Pre-existing issues:
- [High] Latent use-after-free / state corruption bug triggered by resource exhaustion: an hw_params error unconditionally releases a hardware pair actively used by another stream.
- [High] Changing Pair A's channel count via a DAI re-configuration instantly corrupts Pair B's active conversion.
--

--- Patch [4]: [PATCH v3 4/5] ASoC: fsl_asrc: expose individual DAIs per conversion path ---
commit 958c34d5b39a813baf5b15d76b95e94f278f4bf9
Author: Shengjiu Wang <shengjiu.wang@nxp.com>

ASoC: fsl_asrc: expose individual DAIs per conversion path

The patch replaces the single fsl_asrc_dai instance with an array of three
DAI drivers. This allows up to three independent conversion paths to be
active at the same time.

> diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c
> index 2755ee57c6a17..a5d6c4c1e9292 100644
> --- a/sound/soc/fsl/fsl_asrc.c
> +++ b/sound/soc/fsl/fsl_asrc.c
> @@ -792,27 +792,76 @@ static const struct snd_soc_dai_ops fsl_asrc_dai_ops = {
[ ... ]
> -static struct snd_soc_dai_driver fsl_asrc_dai = {
> -	.playback = {
[ ... ]
> +static struct snd_soc_dai_driver fsl_asrc_dai[] = {
> +	{
> +		.name = "asrc-0",
[ ... ]
> +	},
> +	{
> +		.name = "asrc-1",
[ ... ]
> +	},
> +	{
> +		.name = "asrc-2",

[Severity: High]
This isn't a bug introduced by this patch, but exposing 3 independent DAIs
allows multiple streams to run concurrently, making channel exhaustion and
-EBUSY in hw_params trivially reachable.

If a stream fails inside fsl_asrc_dai_hw_params() due to exhaustion, does
the cleanup path inadvertently disable another active stream?

Looking at fsl_asrc_dma_startup(), it requests a dummy pair and sets
pair->index (usually to 0), but does not clear it when released:

sound/soc/fsl/fsl_asrc_dma.c:fsl_asrc_dma_startup() {
    ...
    ret = asrc->request_pair(1, pair);
    ...
    if (pair)
        fsl_asrc_release_pair(pair);
}

If hw_params subsequently fails, the ALSA core calls fsl_asrc_dai_hw_free():

sound/soc/fsl/fsl_asrc.c:fsl_asrc_dai_hw_free() {
    ...
    if (pair)
        fsl_asrc_release_pair(pair);
}

Since pair->index is still 0 from the dummy request, wouldn't this blindly
disable Pair A, setting asrc->pair[0] = NULL and corrupting the global
channel_avail counter, even if Pair A is actively used by another DAI?


[Severity: High]
This is also a pre-existing issue, but allowing up to three independent
conversion paths to be active at the same time appears to violate a hardware
constraint regarding Pair B.

The driver documentation notes that Pair B depends on Pair A:

sound/soc/fsl/fsl_asrc.c:fsl_asrc_request_pair()
 * It assigns pair by the order of A->C->B because allocation of pair B,
 * within range [ANCA, ANCA+ANCB-1], depends on the channels of pair A

If Pair A is stopped and restarted with a different channel count while
Pair B is actively running, what prevents Pair B from being corrupted?

When fsl_asrc_config_pair() updates REG_ASRCNCR to change the ANCA value for
Pair A, won't Pair B's internal hardware channel offsets immediately shift
and disrupt its active conversion?

> +		.ops = &fsl_asrc_dai_ops,
>  	},
>  };

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

  reply	other threads:[~2026-08-04 10:20 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-04 10:02 [PATCH v3 0/5] ASoC: fsl_asrc/fsl_easrc: expose per-pair/context DAIs and fix DMA race shengjiu.wang
2026-08-04 10:02 ` [PATCH v3 1/5] ASoC: dt-bindings: fsl,imx-asrc: update port binding to support multiple paths shengjiu.wang
2026-08-04 14:39   ` Frank Li
2026-08-05  6:57     ` Shengjiu Wang
2026-08-05 17:06       ` Frank Li
2026-08-06  5:27         ` Shengjiu Wang
2026-08-06 16:40           ` Frank Li
2026-08-10  7:12     ` Krzysztof Kozlowski
2026-08-10 19:07       ` Frank Li
2026-08-11  5:44         ` Krzysztof Kozlowski
2026-08-10  7:14   ` Krzysztof Kozlowski
2026-08-11  2:28     ` Shengjiu Wang
2026-08-11  5:44       ` Krzysztof Kozlowski
2026-08-11  7:33         ` Shengjiu Wang
2026-08-11  7:36           ` Krzysztof Kozlowski
2026-08-11  8:17             ` Shengjiu Wang
2026-08-04 10:02 ` [PATCH v3 2/5] ASoC: dt-bindings: fsl,easrc: add ports binding for multiple conversion paths shengjiu.wang
2026-08-04 14:40   ` Frank Li
2026-08-04 10:02 ` [PATCH v3 3/5] ASoC: fsl_asrc/fsl_easrc: move DMA params into pair/context struct shengjiu.wang
2026-08-04 10:15   ` sashiko-bot
2026-08-04 10:02 ` [PATCH v3 4/5] ASoC: fsl_asrc: expose individual DAIs per conversion path shengjiu.wang
2026-08-04 10:20   ` sashiko-bot [this message]
2026-08-04 10:02 ` [PATCH v3 5/5] ASoC: fsl_easrc: " shengjiu.wang
2026-08-04 10:12   ` sashiko-bot

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=20260804102058.1AAA21F000E9@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 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.