* [PATCH] spi: use dmaengine_get_dma_device() for DMA mapping
@ 2026-09-16 15:30 Peng Fan (OSS)
2026-09-16 19:10 ` Frank Li
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Peng Fan (OSS) @ 2026-09-16 15:30 UTC (permalink / raw)
To: Mark Brown, Frank Li; +Cc: imx, linux-spi, linux-kernel, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
Replace chan->device->dev with dmaengine_get_dma_device(chan) in the
SPI core (spi.c) and SPI mem (spi-mem.c) DMA mapping helpers so that
DMA mapping goes through the correct device when the DMA controller
has per-channel IOMMU domains (chan_dma_dev=true).
Assisted-by: Claude:claude-opus-4-6
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/spi/spi-mem.c | 8 ++++----
drivers/spi/spi.c | 4 ++--
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
index 94d122be1c930..b94680b60af95 100644
--- a/drivers/spi/spi-mem.c
+++ b/drivers/spi/spi-mem.c
@@ -46,9 +46,9 @@ int spi_controller_dma_map_mem_op_data(struct spi_controller *ctlr,
return -EINVAL;
if (op->data.dir == SPI_MEM_DATA_OUT && ctlr->dma_tx)
- dmadev = ctlr->dma_tx->device->dev;
+ dmadev = dmaengine_get_dma_device(ctlr->dma_tx);
else if (op->data.dir == SPI_MEM_DATA_IN && ctlr->dma_rx)
- dmadev = ctlr->dma_rx->device->dev;
+ dmadev = dmaengine_get_dma_device(ctlr->dma_rx);
else
dmadev = ctlr->dev.parent;
@@ -92,9 +92,9 @@ void spi_controller_dma_unmap_mem_op_data(struct spi_controller *ctlr,
return;
if (op->data.dir == SPI_MEM_DATA_OUT && ctlr->dma_tx)
- dmadev = ctlr->dma_tx->device->dev;
+ dmadev = dmaengine_get_dma_device(ctlr->dma_tx);
else if (op->data.dir == SPI_MEM_DATA_IN && ctlr->dma_rx)
- dmadev = ctlr->dma_rx->device->dev;
+ dmadev = dmaengine_get_dma_device(ctlr->dma_rx);
else
dmadev = ctlr->dev.parent;
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 172141650b648..4f9f34b798b66 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -1456,14 +1456,14 @@ int __spi_map_msg(struct spi_controller *ctlr, struct spi_message *msg)
return 0;
if (ctlr->dma_tx)
- tx_dev = ctlr->dma_tx->device->dev;
+ tx_dev = dmaengine_get_dma_device(ctlr->dma_tx);
else if (ctlr->dma_map_dev)
tx_dev = ctlr->dma_map_dev;
else
tx_dev = ctlr->dev.parent;
if (ctlr->dma_rx)
- rx_dev = ctlr->dma_rx->device->dev;
+ rx_dev = dmaengine_get_dma_device(ctlr->dma_rx);
else if (ctlr->dma_map_dev)
rx_dev = ctlr->dma_map_dev;
else
---
base-commit: e6e35979777d646fe3c7c94dca7dd32fb25d45f4
change-id: 20260916-spi-dma-466d0a92bd28
Best regards,
--
Peng Fan <peng.fan@nxp.com>
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] spi: use dmaengine_get_dma_device() for DMA mapping
2026-09-16 15:30 [PATCH] spi: use dmaengine_get_dma_device() for DMA mapping Peng Fan (OSS)
@ 2026-09-16 19:10 ` Frank Li
2026-09-16 19:22 ` Frank Li
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Frank Li @ 2026-09-16 19:10 UTC (permalink / raw)
To: Peng Fan (OSS)
Cc: Mark Brown, Frank Li, imx, linux-spi, linux-kernel, Peng Fan
On Wed, Sep 16, 2026 at 11:30:55PM +0800, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
>
> Replace chan->device->dev with dmaengine_get_dma_device(chan) in the
> SPI core (spi.c) and SPI mem (spi-mem.c) DMA mapping helpers so that
> DMA mapping goes through the correct device when the DMA controller
> has per-channel IOMMU domains (chan_dma_dev=true).
>
> Assisted-by: Claude:claude-opus-4-6
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
Thank you for these, it is on my todo list.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> drivers/spi/spi-mem.c | 8 ++++----
> drivers/spi/spi.c | 4 ++--
> 2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
> index 94d122be1c930..b94680b60af95 100644
> --- a/drivers/spi/spi-mem.c
> +++ b/drivers/spi/spi-mem.c
> @@ -46,9 +46,9 @@ int spi_controller_dma_map_mem_op_data(struct spi_controller *ctlr,
> return -EINVAL;
>
> if (op->data.dir == SPI_MEM_DATA_OUT && ctlr->dma_tx)
> - dmadev = ctlr->dma_tx->device->dev;
> + dmadev = dmaengine_get_dma_device(ctlr->dma_tx);
> else if (op->data.dir == SPI_MEM_DATA_IN && ctlr->dma_rx)
> - dmadev = ctlr->dma_rx->device->dev;
> + dmadev = dmaengine_get_dma_device(ctlr->dma_rx);
> else
> dmadev = ctlr->dev.parent;
>
> @@ -92,9 +92,9 @@ void spi_controller_dma_unmap_mem_op_data(struct spi_controller *ctlr,
> return;
>
> if (op->data.dir == SPI_MEM_DATA_OUT && ctlr->dma_tx)
> - dmadev = ctlr->dma_tx->device->dev;
> + dmadev = dmaengine_get_dma_device(ctlr->dma_tx);
> else if (op->data.dir == SPI_MEM_DATA_IN && ctlr->dma_rx)
> - dmadev = ctlr->dma_rx->device->dev;
> + dmadev = dmaengine_get_dma_device(ctlr->dma_rx);
> else
> dmadev = ctlr->dev.parent;
>
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index 172141650b648..4f9f34b798b66 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -1456,14 +1456,14 @@ int __spi_map_msg(struct spi_controller *ctlr, struct spi_message *msg)
> return 0;
>
> if (ctlr->dma_tx)
> - tx_dev = ctlr->dma_tx->device->dev;
> + tx_dev = dmaengine_get_dma_device(ctlr->dma_tx);
> else if (ctlr->dma_map_dev)
> tx_dev = ctlr->dma_map_dev;
> else
> tx_dev = ctlr->dev.parent;
>
> if (ctlr->dma_rx)
> - rx_dev = ctlr->dma_rx->device->dev;
> + rx_dev = dmaengine_get_dma_device(ctlr->dma_rx);
> else if (ctlr->dma_map_dev)
> rx_dev = ctlr->dma_map_dev;
> else
>
> ---
> base-commit: e6e35979777d646fe3c7c94dca7dd32fb25d45f4
> change-id: 20260916-spi-dma-466d0a92bd28
>
> Best regards,
> --
> Peng Fan <peng.fan@nxp.com>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] spi: use dmaengine_get_dma_device() for DMA mapping
2026-09-16 15:30 [PATCH] spi: use dmaengine_get_dma_device() for DMA mapping Peng Fan (OSS)
2026-09-16 19:10 ` Frank Li
@ 2026-09-16 19:22 ` Frank Li
2026-09-24 16:12 ` Mark Brown
2026-09-24 16:44 ` Mark Brown
3 siblings, 0 replies; 5+ messages in thread
From: Frank Li @ 2026-09-16 19:22 UTC (permalink / raw)
To: Peng Fan (OSS)
Cc: Mark Brown, Frank Li, imx, linux-spi, linux-kernel, Peng Fan
On Wed, Sep 16, 2026 at 11:30:55PM +0800, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
>
> Replace chan->device->dev with dmaengine_get_dma_device(chan) in the
> SPI core (spi.c) and SPI mem (spi-mem.c) DMA mapping helpers so that
> DMA mapping goes through the correct device when the DMA controller
> has per-channel IOMMU domains (chan_dma_dev=true).
>
> Assisted-by: Claude:claude-opus-4-6
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> drivers/spi/spi-mem.c | 8 ++++----
> drivers/spi/spi.c | 4 ++--
> 2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
> index 94d122be1c930..b94680b60af95 100644
> --- a/drivers/spi/spi-mem.c
> +++ b/drivers/spi/spi-mem.c
> @@ -46,9 +46,9 @@ int spi_controller_dma_map_mem_op_data(struct spi_controller *ctlr,
> return -EINVAL;
>
> if (op->data.dir == SPI_MEM_DATA_OUT && ctlr->dma_tx)
> - dmadev = ctlr->dma_tx->device->dev;
> + dmadev = dmaengine_get_dma_device(ctlr->dma_tx);
> else if (op->data.dir == SPI_MEM_DATA_IN && ctlr->dma_rx)
> - dmadev = ctlr->dma_rx->device->dev;
> + dmadev = dmaengine_get_dma_device(ctlr->dma_rx);
> else
> dmadev = ctlr->dev.parent;
>
> @@ -92,9 +92,9 @@ void spi_controller_dma_unmap_mem_op_data(struct spi_controller *ctlr,
> return;
>
> if (op->data.dir == SPI_MEM_DATA_OUT && ctlr->dma_tx)
> - dmadev = ctlr->dma_tx->device->dev;
> + dmadev = dmaengine_get_dma_device(ctlr->dma_tx);
> else if (op->data.dir == SPI_MEM_DATA_IN && ctlr->dma_rx)
> - dmadev = ctlr->dma_rx->device->dev;
> + dmadev = dmaengine_get_dma_device(ctlr->dma_rx);
> else
> dmadev = ctlr->dev.parent;
>
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index 172141650b648..4f9f34b798b66 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -1456,14 +1456,14 @@ int __spi_map_msg(struct spi_controller *ctlr, struct spi_message *msg)
> return 0;
>
> if (ctlr->dma_tx)
> - tx_dev = ctlr->dma_tx->device->dev;
> + tx_dev = dmaengine_get_dma_device(ctlr->dma_tx);
> else if (ctlr->dma_map_dev)
> tx_dev = ctlr->dma_map_dev;
> else
> tx_dev = ctlr->dev.parent;
>
> if (ctlr->dma_rx)
> - rx_dev = ctlr->dma_rx->device->dev;
> + rx_dev = dmaengine_get_dma_device(ctlr->dma_rx);
> else if (ctlr->dma_map_dev)
> rx_dev = ctlr->dma_map_dev;
> else
>
> ---
> base-commit: e6e35979777d646fe3c7c94dca7dd32fb25d45f4
> change-id: 20260916-spi-dma-466d0a92bd28
>
> Best regards,
> --
> Peng Fan <peng.fan@nxp.com>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] spi: use dmaengine_get_dma_device() for DMA mapping
2026-09-16 15:30 [PATCH] spi: use dmaengine_get_dma_device() for DMA mapping Peng Fan (OSS)
2026-09-16 19:10 ` Frank Li
2026-09-16 19:22 ` Frank Li
@ 2026-09-24 16:12 ` Mark Brown
2026-09-24 16:44 ` Mark Brown
3 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2026-09-24 16:12 UTC (permalink / raw)
To: Peng Fan (OSS); +Cc: Frank Li, imx, linux-spi, linux-kernel, Peng Fan
[-- Attachment #1: Type: text/plain, Size: 982 bytes --]
On Wed, Sep 16, 2026 at 11:30:55PM +0800, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
>
> Replace chan->device->dev with dmaengine_get_dma_device(chan) in the
> SPI core (spi.c) and SPI mem (spi-mem.c) DMA mapping helpers so that
> DMA mapping goes through the correct device when the DMA controller
> has per-channel IOMMU domains (chan_dma_dev=true).
> @@ -46,9 +46,9 @@ int spi_controller_dma_map_mem_op_data(struct spi_controller *ctlr,
> return -EINVAL;
>
> if (op->data.dir == SPI_MEM_DATA_OUT && ctlr->dma_tx)
> - dmadev = ctlr->dma_tx->device->dev;
> + dmadev = dmaengine_get_dma_device(ctlr->dma_tx);
> else if (op->data.dir == SPI_MEM_DATA_IN && ctlr->dma_rx)
> - dmadev = ctlr->dma_rx->device->dev;
> + dmadev = dmaengine_get_dma_device(ctlr->dma_rx);
> else
> dmadev = ctlr->dev.parent;
>
At least OMAP McSPI has different DMA channels per chip select for some
reason, that's broken either way though I think.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] spi: use dmaengine_get_dma_device() for DMA mapping
2026-09-16 15:30 [PATCH] spi: use dmaengine_get_dma_device() for DMA mapping Peng Fan (OSS)
` (2 preceding siblings ...)
2026-09-24 16:12 ` Mark Brown
@ 2026-09-24 16:44 ` Mark Brown
3 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2026-09-24 16:44 UTC (permalink / raw)
To: Frank Li, Peng Fan (OSS); +Cc: imx, linux-spi, linux-kernel, Peng Fan
On Wed, 16 Sep 2026 23:30:55 +0800, Peng Fan (OSS) wrote:
> spi: use dmaengine_get_dma_device() for DMA mapping
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-7.4
Thanks!
[1/1] spi: use dmaengine_get_dma_device() for DMA mapping
https://git.kernel.org/broonie/spi/c/cb5a15943d7d
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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-09-24 16:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-16 15:30 [PATCH] spi: use dmaengine_get_dma_device() for DMA mapping Peng Fan (OSS)
2026-09-16 19:10 ` Frank Li
2026-09-16 19:22 ` Frank Li
2026-09-24 16:12 ` Mark Brown
2026-09-24 16:44 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox