Devicetree
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@oss.nxp.com>
To: shengjiu.wang@oss.nxp.com
Cc: lgirdwood@gmail.com, broonie@kernel.org, robh@kernel.org,
	krzk+dt@kernel.org, conor+dt@kernel.org, Frank.Li@nxp.com,
	s.hauer@pengutronix.de, kernel@pengutronix.de,
	festevam@gmail.com, shawnguo@kernel.org,
	linux-sound@vger.kernel.org, devicetree@vger.kernel.org,
	imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, shengjiu.wang@gmail.com,
	Xiubo.Lee@gmail.com, nicoleotsuka@gmail.com, perex@perex.cz,
	tiwai@suse.com, linuxppc-dev@lists.ozlabs.org,
	Shengjiu Wang <shengjiu.wang@nxp.com>
Subject: Re: [PATCH v4 3/5] ASoC: fsl_asrc/fsl_easrc: move DMA params into pair/context struct
Date: Thu, 13 Aug 2026 11:52:17 -0500	[thread overview]
Message-ID: <an32QUTIbtVn1G-I@SMW015318> (raw)
In-Reply-To: <20260813070020.719810-4-shengjiu.wang@oss.nxp.com>

On Thu, Aug 13, 2026 at 03:00:18PM +0800, shengjiu.wang@oss.nxp.com wrote:
> From: Shengjiu Wang <shengjiu.wang@nxp.com>
>
> The shared dma_params_tx/rx fields in struct fsl_asrc were a single
> instance written by every concurrent fsl_asrc_dma_hw_params() call.
> With multiple DAIs registered (one per pair/context), parallel stream
> open+hw_params races would corrupt addr and maxburst for all active
> streams.
>
> Fix by moving dma_params into struct fsl_asrc_pair so each pair owns
> its own copy. Initialise them in fsl_asrc_dma_startup() where
> the pair is allocated, which makes the per-DAI probe callbacks in
> fsl_asrc.c and fsl_easrc.c redundant; remove those as well.
>
> Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
> ---

Reviewed-by: Frank Li <Frank.Li@nxp.com>

>  sound/soc/fsl/fsl_asrc.c        | 11 -----------
>  sound/soc/fsl/fsl_asrc_common.h |  7 +++----
>  sound/soc/fsl/fsl_asrc_dma.c    | 14 ++++++++++++++
>  sound/soc/fsl/fsl_easrc.c       | 11 -----------
>  4 files changed, 17 insertions(+), 26 deletions(-)
>
> diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c
> index df4817ae91b1..2755ee57c6a1 100644
> --- a/sound/soc/fsl/fsl_asrc.c
> +++ b/sound/soc/fsl/fsl_asrc.c
> @@ -781,18 +781,7 @@ static int fsl_asrc_dai_trigger(struct snd_pcm_substream *substream, int cmd,
>  	return 0;
>  }
>
> -static int fsl_asrc_dai_probe(struct snd_soc_dai *dai)
> -{
> -	struct fsl_asrc *asrc = snd_soc_dai_get_drvdata(dai);
> -
> -	snd_soc_dai_init_dma_data(dai, &asrc->dma_params_tx,
> -				  &asrc->dma_params_rx);
> -
> -	return 0;
> -}
> -
>  static const struct snd_soc_dai_ops fsl_asrc_dai_ops = {
> -	.probe		= fsl_asrc_dai_probe,
>  	.startup	= fsl_asrc_dai_startup,
>  	.hw_params	= fsl_asrc_dai_hw_params,
>  	.hw_free	= fsl_asrc_dai_hw_free,
> diff --git a/sound/soc/fsl/fsl_asrc_common.h b/sound/soc/fsl/fsl_asrc_common.h
> index c8a1a2b5915d..4e6b00cb5d63 100644
> --- a/sound/soc/fsl/fsl_asrc_common.h
> +++ b/sound/soc/fsl/fsl_asrc_common.h
> @@ -53,6 +53,7 @@ struct fsl_asrc_m2m_cap {
>   * @dma_data: private dma data
>   * @pos: hardware pointer position
>   * @req_dma_chan: flag to release dev_to_dev chan
> + * @dma_params: DMA parameters for transmit/receive channel
>   * @private: pair private area
>   * @complete: dma task complete
>   * @sample_format: format of m2m
> @@ -76,6 +77,8 @@ struct fsl_asrc_pair {
>  	unsigned int pos;
>  	bool req_dma_chan;
>
> +	struct snd_dmaengine_dai_dma_data dma_params;
> +
>  	void *private;
>
>  	/* used for m2m */
> @@ -92,8 +95,6 @@ struct fsl_asrc_pair {
>  /**
>   * fsl_asrc: ASRC common data
>   *
> - * @dma_params_rx: DMA parameters for receive channel
> - * @dma_params_tx: DMA parameters for transmit channel
>   * @pdev: platform device pointer
>   * @regmap: regmap handler
>   * @paddr: physical address to the base address of registers
> @@ -128,8 +129,6 @@ struct fsl_asrc_pair {
>   * @private: private data structure
>   */
>  struct fsl_asrc {
> -	struct snd_dmaengine_dai_dma_data dma_params_rx;
> -	struct snd_dmaengine_dai_dma_data dma_params_tx;
>  	struct platform_device *pdev;
>  	struct regmap *regmap;
>  	unsigned long paddr;
> diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c
> index 2f662bdf14d0..15f2dccc3584 100644
> --- a/sound/soc/fsl/fsl_asrc_dma.c
> +++ b/sound/soc/fsl/fsl_asrc_dma.c
> @@ -392,6 +392,20 @@ static int fsl_asrc_dma_startup(struct snd_soc_component *component,
>
>  	runtime->private_data = pair;
>
> +	/*
> +	 * Point the cpu DAI dma_data at the per-pair params so that
> +	 * concurrent hw_params calls on different pairs each write to
> +	 * their own struct and do not race on addr/maxburst.  Use the
> +	 * per-direction setters so that a concurrent open of the other
> +	 * direction on the same DAI does not NULL out its pointer.
> +	 */
> +	if (tx)
> +		snd_soc_dai_dma_data_set_playback(snd_soc_rtd_to_cpu(rtd, 0),
> +						  &pair->dma_params);
> +	else
> +		snd_soc_dai_dma_data_set_capture(snd_soc_rtd_to_cpu(rtd, 0),
> +						 &pair->dma_params);
> +
>  	/* Request a dummy pair, which will be released later.
>  	 * Request pair function needs channel num as input, for this
>  	 * dummy pair, we just request "1" channel temporarily.
> diff --git a/sound/soc/fsl/fsl_easrc.c b/sound/soc/fsl/fsl_easrc.c
> index 77c5009cc01f..d23ee482924b 100644
> --- a/sound/soc/fsl/fsl_easrc.c
> +++ b/sound/soc/fsl/fsl_easrc.c
> @@ -1582,18 +1582,7 @@ static int fsl_easrc_hw_free(struct snd_pcm_substream *substream,
>  	return 0;
>  }
>
> -static int fsl_easrc_dai_probe(struct snd_soc_dai *cpu_dai)
> -{
> -	struct fsl_asrc *easrc = dev_get_drvdata(cpu_dai->dev);
> -
> -	snd_soc_dai_init_dma_data(cpu_dai,
> -				  &easrc->dma_params_tx,
> -				  &easrc->dma_params_rx);
> -	return 0;
> -}
> -
>  static const struct snd_soc_dai_ops fsl_easrc_dai_ops = {
> -	.probe		= fsl_easrc_dai_probe,
>  	.startup	= fsl_easrc_startup,
>  	.trigger	= fsl_easrc_trigger,
>  	.hw_params	= fsl_easrc_hw_params,
> --
> 2.34.1
>
>

  parent reply	other threads:[~2026-08-13 16:52 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 [this message]
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

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=an32QUTIbtVn1G-I@SMW015318 \
    --to=frank.li@oss.nxp.com \
    --cc=Frank.Li@nxp.com \
    --cc=Xiubo.Lee@gmail.com \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=festevam@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=kernel@pengutronix.de \
    --cc=krzk+dt@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=nicoleotsuka@gmail.com \
    --cc=perex@perex.cz \
    --cc=robh@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    --cc=shengjiu.wang@gmail.com \
    --cc=shengjiu.wang@nxp.com \
    --cc=shengjiu.wang@oss.nxp.com \
    --cc=tiwai@suse.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