mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/4] ASoC: Use dmaengine API instead of chan->device->dev
@ 2026-11-06 20:13 Frank.Li
  2026-11-06 20:13 ` [PATCH 1/4] ASoC: apple: mca: Use dmaengine_get_dma_device() " Frank.Li
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Frank.Li @ 2026-11-06 20:13 UTC (permalink / raw)
  To: Martin Povišer, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Shengjiu Wang, Xiubo Li, Fabio Estevam,
	Nicolin Chen, Kuninori Morimoto, Geert Uytterhoeven, Magnus Damm,
	Sen Wang
  Cc: asahi, linux-sound, linux-kernel, linuxppc-dev,
	linux-renesas-soc, imx, vkoul, Frank Li

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

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
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() API

 sound/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,
--  
Frank Li <Frank.Li@nxp.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/4] ASoC: apple: mca: Use dmaengine_get_dma_device() instead of chan->device->dev
  2026-11-06 20:13 [PATCH 0/4] ASoC: Use dmaengine API instead of chan->device->dev Frank.Li
@ 2026-11-06 20:13 ` Frank.Li
  2026-11-06 20:13 ` [PATCH 2/4] ASoC: fsl: asrc: Use dmaengine API " Frank.Li
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Frank.Li @ 2026-11-06 20:13 UTC (permalink / raw)
  To: Martin Povišer, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Shengjiu Wang, Xiubo Li, Fabio Estevam,
	Nicolin Chen, Kuninori Morimoto, Geert Uytterhoeven, Magnus Damm,
	Sen Wang
  Cc: asahi, linux-sound, linux-kernel, linuxppc-dev,
	linux-renesas-soc, imx, vkoul, Frank Li

From: Frank Li <Frank.Li@nxp.com>

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.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
 sound/soc/apple/mca.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/apple/mca.c b/sound/soc/apple/mca.c
index 26022a42a95ec..b4ca8ec78488f 100644
--- a/sound/soc/apple/mca.c
+++ b/sound/soc/apple/mca.c
@@ -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);
 	}
 

-- 
2.43.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/4] ASoC: fsl: asrc: Use dmaengine API instead of chan->device->dev
  2026-11-06 20:13 [PATCH 0/4] ASoC: Use dmaengine API instead of chan->device->dev Frank.Li
  2026-11-06 20:13 ` [PATCH 1/4] ASoC: apple: mca: Use dmaengine_get_dma_device() " Frank.Li
@ 2026-11-06 20:13 ` Frank.Li
  2026-11-06 20:13 ` [PATCH 3/4] ASoC: renesas: rcar: Use dmaengine_get_dma_device() " Frank.Li
  2026-11-06 20:13 ` [PATCH 4/4] ASoC: ti: davinci-mcasp: Use dmaengine_get_provider_device() API Frank.Li
  3 siblings, 0 replies; 5+ messages in thread
From: Frank.Li @ 2026-11-06 20:13 UTC (permalink / raw)
  To: Martin Povišer, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Shengjiu Wang, Xiubo Li, Fabio Estevam,
	Nicolin Chen, Kuninori Morimoto, Geert Uytterhoeven, Magnus Damm,
	Sen Wang
  Cc: asahi, linux-sound, linux-kernel, linuxppc-dev,
	linux-renesas-soc, imx, vkoul, Frank Li

From: Frank Li <Frank.Li@nxp.com>

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.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
 sound/soc/fsl/fsl_asrc_dma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c
index cd3bf6340b650..71f84359df3af 100644
--- a/sound/soc/fsl/fsl_asrc_dma.c
+++ b/sound/soc/fsl/fsl_asrc_dma.c
@@ -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);

-- 
2.43.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 3/4] ASoC: renesas: rcar: Use dmaengine_get_dma_device() instead of chan->device->dev
  2026-11-06 20:13 [PATCH 0/4] ASoC: Use dmaengine API instead of chan->device->dev Frank.Li
  2026-11-06 20:13 ` [PATCH 1/4] ASoC: apple: mca: Use dmaengine_get_dma_device() " Frank.Li
  2026-11-06 20:13 ` [PATCH 2/4] ASoC: fsl: asrc: Use dmaengine API " Frank.Li
@ 2026-11-06 20:13 ` Frank.Li
  2026-11-06 20:13 ` [PATCH 4/4] ASoC: ti: davinci-mcasp: Use dmaengine_get_provider_device() API Frank.Li
  3 siblings, 0 replies; 5+ messages in thread
From: Frank.Li @ 2026-11-06 20:13 UTC (permalink / raw)
  To: Martin Povišer, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Shengjiu Wang, Xiubo Li, Fabio Estevam,
	Nicolin Chen, Kuninori Morimoto, Geert Uytterhoeven, Magnus Damm,
	Sen Wang
  Cc: asahi, linux-sound, linux-kernel, linuxppc-dev,
	linux-renesas-soc, imx, vkoul, Frank Li

From: Frank Li <Frank.Li@nxp.com>

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.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
 sound/soc/renesas/rcar/dma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/renesas/rcar/dma.c b/sound/soc/renesas/rcar/dma.c
index 793dd4adbe5c6..d70cc71676df6 100644
--- a/sound/soc/renesas/rcar/dma.c
+++ b/sound/soc/renesas/rcar/dma.c
@@ -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);
 

-- 
2.43.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 4/4] ASoC: ti: davinci-mcasp: Use dmaengine_get_provider_device() API
  2026-11-06 20:13 [PATCH 0/4] ASoC: Use dmaengine API instead of chan->device->dev Frank.Li
                   ` (2 preceding siblings ...)
  2026-11-06 20:13 ` [PATCH 3/4] ASoC: renesas: rcar: Use dmaengine_get_dma_device() " Frank.Li
@ 2026-11-06 20:13 ` Frank.Li
  3 siblings, 0 replies; 5+ messages in thread
From: Frank.Li @ 2026-11-06 20:13 UTC (permalink / raw)
  To: Martin Povišer, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Shengjiu Wang, Xiubo Li, Fabio Estevam,
	Nicolin Chen, Kuninori Morimoto, Geert Uytterhoeven, Magnus Damm,
	Sen Wang
  Cc: asahi, linux-sound, linux-kernel, linuxppc-dev,
	linux-renesas-soc, imx, vkoul, Frank Li

From: Frank Li <Frank.Li@nxp.com>

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.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
 sound/soc/ti/davinci-mcasp.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/sound/soc/ti/davinci-mcasp.c b/sound/soc/ti/davinci-mcasp.c
index 481d1042ddb6d..e871925517dca 100644
--- a/sound/soc/ti/davinci-mcasp.c
+++ b/sound/soc/ti/davinci-mcasp.c
@@ -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");

-- 
2.43.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-06 20:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-06 20:13 [PATCH 0/4] ASoC: Use dmaengine API instead of chan->device->dev Frank.Li
2026-11-06 20:13 ` [PATCH 1/4] ASoC: apple: mca: Use dmaengine_get_dma_device() " Frank.Li
2026-11-06 20:13 ` [PATCH 2/4] ASoC: fsl: asrc: Use dmaengine API " Frank.Li
2026-11-06 20:13 ` [PATCH 3/4] ASoC: renesas: rcar: Use dmaengine_get_dma_device() " Frank.Li
2026-11-06 20:13 ` [PATCH 4/4] ASoC: ti: davinci-mcasp: Use dmaengine_get_provider_device() API Frank.Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®