* [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
2026-09-16 19:22 ` Frank Li
0 siblings, 2 replies; 3+ 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 [flat|nested] 3+ 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
1 sibling, 0 replies; 3+ 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] 3+ 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
1 sibling, 0 replies; 3+ 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] 3+ messages in thread
end of thread, other threads:[~2026-09-16 19:22 UTC | newest]
Thread overview: 3+ 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
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®