ASoC: Use dmaengine API instead of chan->device->dev
Subsystems (8)
cover ASoC: Use dmaengine API instead of chan->device->dev
Replace open-coded chan->device->dev accesses in ASoC drivers with the proper dmaengine accessor APIs:
- dmaengine_get_dma_device(): returns the device used for DMA mappings; may return a per-channel device if the dmaengine supports per-channel IOMMU mapping.
- dmaengine_get_provider_device(): returns the dmaengine provider device that carries the of_node, used for device-tree based channel filtering.
This avoids direct access to DMA engine internals and prepares for making struct dma_device private.
After previous post patch
1: applied https://lore.kernel.org/imx/179396622411.3073895.524075215689851221.b4-ty@b4/
2: under review https://lore.kernel.org/imx/CAA+D8ANwEqFJYQ39h+1A3zXhcUfpFGzSvVjEzx2htoYxB4sLGg@mail.gmail.com/
sound directory can pass build with allyesconfig after really move struct dma_device to drivers/dmaengine/dmaengine.h
---
Frank Li (4):
ASoC: apple: mca: Use dmaengine_get_dma_device() instead of chan->device->dev
ASoC: fsl: asrc: Use dmaengine API instead of chan->device->dev
ASoC: renesas: rcar: Use dmaengine_get_dma_device() instead of chan->device->dev
ASoC: ti: davinci-mcasp: Use dmaengine_get_provider_device() APIsound/soc/apple/mca.c | 4 ++-- sound/soc/fsl/fsl_asrc_dma.c | 4 ++-- sound/soc/renesas/rcar/dma.c | 2 +- sound/soc/ti/davinci-mcasp.c | 10 ++++------ 4 files changed, 9 insertions(+), 11 deletions(-)
---
base-commit: 13716421a63a932e09c1f56d78f6055c2fa069c1
change-id: 20261106-dma_sound_cleanup-d6b21ff86f31
Best regards,
Signature · 1 line
Frank Li <[email protected]>
PATCH 1/4 ASoC: apple: mca: Use dmaengine_get_dma_device() instead of chan->device->dev
From: Frank Li <[email protected]>
Replace open-coded chan->device->dev with the accessor dmaengine_get_dma_device() to avoid direct access to DMA engine internals.
Prepare to make struct dma_device private.
--- sound/soc/apple/mca.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/apple/mca.c +2 -2
@@ -940,7 +940,7 @@ static int mca_set_runtime_hwparams(struct snd_soc_component *component,struct snd_pcm_substream *substream, struct dma_chan *chan) { - struct device *dma_dev = chan->device->dev; + struct device *dma_dev = dmaengine_get_dma_device(chan);struct snd_dmaengine_dai_dma_data dma_data = {};int ret;
@@ -1123,7 +1123,7 @@ static int mca_pcm_new(struct snd_soc_component *component, cl->dma_chans[i] = chan;snd_pcm_set_managed_buffer (substream,SNDRV_DMA_TYPE_DEV_IRAM , - chan->device->dev,512 *1024 *6 , +dmaengine_get_dma_device (chan),512 *1024 *6 ,SIZE_MAX ); }
Signature · 1 line
2.43.0
PATCH 2/4 ASoC: fsl: asrc: Use dmaengine API instead of chan->device->dev
In reply to [email protected]From: Frank Li <[email protected]>
Replace open-coded chan->device->dev with dmaengine_get_dma_device() and chan->device->dev->of_node with dmaengine_get_provider_device()->of_node to avoid direct access to DMA engine internals.
dmaengine_get_dma_device(): for dma map device, may return pre chan device if dmaengine support per chan iommu mapping. dmaengine_get_provider_device(): for dmaengine device filter, which have of_node.
Prepare to make struct dma_device private.
--- sound/soc/fsl/fsl_asrc_dma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/fsl/fsl_asrc_dma.c +2 -2
@@ -261,7 +261,7 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component, pair->dma_data.priority = tmp_data->priority;dma_release_channel (tmp_chan); - of_dma_node = pair->dma_chan[!dir]->device->dev->of_node; + of_dma_node =dmaengine_get_provider_device (pair->dma_chan[!dir])->of_node; pair->dma_chan[dir] =__dma_request_channel (&mask, filter, &pair->dma_data, of_dma_node);
@@ -526,7 +526,7 @@ static int fsl_asrc_dma_pcm_new(struct snd_soc_component *component, ret =snd_pcm_set_fixed_buffer_all (pcm,SNDRV_DMA_TYPE_DEV , - chan->device->dev, +dmaengine_get_dma_device (chan),FSL_ASRC_DMABUF_SIZE );dma_release_channel (chan);
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH 2/4] ASoC: fsl: asrc: Use dmaengine API instead of chan->device->dev
Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce: - [Critical] ASoC: fsl_asrc_dma: ERR_PTR…
Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce:
- [Critical] ASoC: fsl_asrc_dma: ERR_PTR dereference in fsl_asrc_dma_hw_params() [1]
--
commit 5ed216d0bcbc0b97f113bf28f5e8a475ae506081
Author: Frank Li <[email protected]>
ASoC: fsl: asrc: Use dmaengine API instead of chan->device->dev
This commit replaces direct accesses to chan->device->dev with dmaengine_get_dma_device() and dmaengine_get_provider_device() in the Freescale ASRC DMA driver.
sound/soc/fsl/fsl_asrc_dma.c static int fsl_asrc_dma_hw_params(struct snd_soc_component *component, · line 268
Quoted 13 lines
sound/soc/fsl/fsl_asrc_dma.c +1
-1@@ -262,7 +262,7 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component, pair->dma_data.priority = tmp_data->priority;dma_release_channel (tmp_chan); - of_dma_node = pair->dma_chan[!dir]->device->dev->of_node; + of_dma_node =dmaengine_get_provider_device (pair->dma_chan[!dir])->of_node; pair->dma_chan[dir] =__dma_request_channel (&mask, filter, &pair->dma_data, of_dma_node);
[Severity: Critical]
This problem wasn't introduced by this patch, but can tmp_chan->private dereference an error pointer [1] just above this hunk?
asrc->get_dma_channel() returns an ERR_PTR from dma_request_chan() when front-end DMA channel allocation fails, whereas fsl_asrc_dma_hw_params() only checks for !tmp_chan before accessing tmp_chan->private:
sound/soc/fsl/fsl_asrc_dma.c:fsl_asrc_dma_hw_params() {
...
tmp_chan = asrc->get_dma_channel(pair, dir);
if (!tmp_chan) {
dma_release_channel(pair->dma_chan[!dir]);
pair->dma_chan[!dir] = NULL;
return -EINVAL;
}
tmp_data = tmp_chan->private;
...
}Should this check IS_ERR_OR_NULL(tmp_chan) instead?
[1] https://sashiko.dev/#/bug/linux-564b9a37-0988-4e75-909c-eb977f811fd1
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
PATCH 3/4 ASoC: renesas: rcar: Use dmaengine_get_dma_device() instead of chan->device->dev
In reply to [email protected]From: Frank Li <[email protected]>
Replace open-coded chan->device->dev with the accessor dmaengine_get_dma_device() to avoid direct access to DMA engine internals.
Prepare to make struct dma_device private.
--- sound/soc/renesas/rcar/dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/renesas/rcar/dma.c +1 -1
@@ -246,7 +246,7 @@ static int rsnd_dmaen_attach(struct rsnd_dai_stream *io,* see * rsnd_preallocate_pages() */ - io->dmac_dev = chan->device->dev; + io->dmac_dev =dmaengine_get_dma_device (chan);dma_release_channel (chan);
Signature · 1 line
2.43.0
Re: [PATCH 3/4] ASoC: renesas: rcar: Use dmaengine_get_dma_device() instead of chan->device->dev
Hi
Quoted 8 lines
Replace open-coded
chan->device->devwith the accessordmaengine_get_dma_device()to avoid direct access to DMA engine internals.Prepare to make struct
dma_deviceprivate.Signed-off-by Frank Li <[email protected]>---
Thank you for your help !!
Best regards
---
Kuninori Morimoto
PATCH 4/4 ASoC: ti: davinci-mcasp: Use dmaengine_get_provider_device() API
In reply to [email protected]From: Frank Li <[email protected]>
Replace open-coded chan->device->dev with dmaengine_get_provider_device() to avoid direct access to DMA engine internals. The WARN_ON check for chan->device is no longer needed since already checked return value of dma_request_chan(). It is impossible dma_chan is not NULL and DMA engine device is NULL.
Prepare to make struct dma_device private.
--- sound/soc/ti/davinci-mcasp.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
sound/soc/ti/davinci-mcasp.c +4 -6
@@ -2477,6 +2477,7 @@ static const char *sdma_prefix = "ti,omap";static int davinci_mcasp_get_dma_type (struct davinci_mcasp *mcasp) {struct dma_chan *chan; +struct device *dma_dev;const char *tmp;int ret =PCM_EDMA ;
@@ -2488,13 +2489,10 @@ static int davinci_mcasp_get_dma_type(struct davinci_mcasp *mcasp)if (IS_ERR (chan))return dev_err_probe (mcasp->dev,PTR_ERR (chan),"Can't verify DMA configuration\n" ); -if (WARN_ON (!chan->device || !chan->device->dev)) { -dma_release_channel (chan); -return -EINVAL ; - } -if (chan->device->dev->of_node) - ret =of_property_read_string (chan->device->dev->of_node, + dma_dev =dmaengine_get_provider_device (chan); +if (dma_dev->of_node) + ret =of_property_read_string (dma_dev->of_node,"compatible" , &tmp);else dev_dbg (mcasp->dev,"DMA controller has no of-node\n" );
Signature · 1 line
2.43.0
Mark Brown
maintainerQuoted 5 lines · On Fri, 06 Nov 2026 15:13:44 -0500, [email protected] wrote:
ASoC: Use dmaengine API instead of
chan->device->devReplace open-coded
chan->device->devaccesses in ASoC drivers with the proper dmaengine accessor APIs:
Quoted 8 lines
-
dmaengine_get_dma_device(): returns the device used for DMA mappings; may return a per-channel device if the dmaengine supports per-channel IOMMU mapping.
-dmaengine_get_provider_device(): returns the dmaengine provider device that carries theof_node, used for device-tree based channel filtering.[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.5
Thanks!
[1/4] ASoC: apple: mca: Use dmaengine_get_dma_device() instead of chan->device->dev
https://git.kernel.org/broonie/sound/c/69d9cfe10445 [2/4] ASoC: fsl: asrc: Use dmaengine API instead of chan->device->dev https://git.kernel.org/broonie/sound/c/5aacfc0388c4 [3/4] ASoC: renesas: rcar: Use dmaengine_get_dma_device() instead of chan->device->dev https://git.kernel.org/broonie/sound/c/77c4d4f760d3 [4/4] ASoC: ti: davinci-mcasp: Use dmaengine_get_provider_device() API https://git.kernel.org/broonie/sound/c/2a2c53477627
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