From: Frank Li <Frank.li@oss.nxp.com>
To: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
Cc: Dong Aisheng <aisheng.dong@nxp.com>,
Andi Shyti <andi.shyti@kernel.org>, Frank Li <Frank.Li@nxp.com>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
linux-i2c@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Peng Fan <peng.fan@nxp.com>
Subject: Re: [PATCH] i2c: imx-lpi2c: use dmaengine_get_dma_device() for DMA mapping
Date: Wed, 16 Sep 2026 11:43:18 -0500 [thread overview]
Message-ID: <aqrHJsO5xYBO4WvB@SMW015318> (raw)
In-Reply-To: <20260916-i2c-dma-v1-1-6dd4f1916910@nxp.com>
On Wed, Sep 16, 2026 at 11:25:26PM +0800, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
>
> Replace all chan->device->dev references with
> dmaengine_get_dma_device(chan) so that DMA mapping goes through the
> correct device when the DMA controller has per-channel IOMMU domains
> (chan_dma_dev=true). Without this, DMA map/unmap bypasses the IOMMU
> context configured by the eDMA driver.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> drivers/i2c/busses/i2c-imx-lpi2c.c | 18 +++++++++---------
> 1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c
> index 49aabef7f115c..60547006f8b44 100644
> --- a/drivers/i2c/busses/i2c-imx-lpi2c.c
> +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c
> @@ -780,7 +780,7 @@ static void lpi2c_dma_unmap(struct lpi2c_imx_dma *dma)
> struct dma_chan *chan = dma->dma_data_dir == DMA_FROM_DEVICE
> ? dma->chan_rx : dma->chan_tx;
>
> - dma_unmap_single(chan->device->dev, dma->dma_addr,
> + dma_unmap_single(dmaengine_get_dma_device(chan), dma->dma_addr,
> dma->dma_len, dma->dma_data_dir);
>
> dma->dma_data_dir = DMA_NONE;
> @@ -789,7 +789,7 @@ static void lpi2c_dma_unmap(struct lpi2c_imx_dma *dma)
> static void lpi2c_cleanup_rx_cmd_dma(struct lpi2c_imx_dma *dma)
> {
> dmaengine_terminate_sync(dma->chan_tx);
> - dma_unmap_single(dma->chan_tx->device->dev, dma->dma_tx_addr,
> + dma_unmap_single(dmaengine_get_dma_device(dma->chan_tx), dma->dma_tx_addr,
> dma->rx_cmd_buf_len, DMA_TO_DEVICE);
> }
>
> @@ -817,10 +817,10 @@ static int lpi2c_dma_rx_cmd_submit(struct lpi2c_imx_struct *lpi2c_imx)
> struct dma_chan *txchan = dma->chan_tx;
> dma_cookie_t cookie;
>
> - dma->dma_tx_addr = dma_map_single(txchan->device->dev,
> + dma->dma_tx_addr = dma_map_single(dmaengine_get_dma_device(txchan),
> dma->rx_cmd_buf, dma->rx_cmd_buf_len,
> DMA_TO_DEVICE);
> - if (dma_mapping_error(txchan->device->dev, dma->dma_tx_addr)) {
> + if (dma_mapping_error(dmaengine_get_dma_device(txchan), dma->dma_tx_addr)) {
> dev_err(&lpi2c_imx->adapter.dev, "DMA map failed, use pio\n");
> return -EINVAL;
> }
> @@ -844,12 +844,12 @@ static int lpi2c_dma_rx_cmd_submit(struct lpi2c_imx_struct *lpi2c_imx)
> return 0;
>
> desc_prepare_err_exit:
> - dma_unmap_single(txchan->device->dev, dma->dma_tx_addr,
> + dma_unmap_single(dmaengine_get_dma_device(txchan), dma->dma_tx_addr,
> dma->rx_cmd_buf_len, DMA_TO_DEVICE);
> return -EINVAL;
>
> submit_err_exit:
> - dma_unmap_single(txchan->device->dev, dma->dma_tx_addr,
> + dma_unmap_single(dmaengine_get_dma_device(txchan), dma->dma_tx_addr,
> dma->rx_cmd_buf_len, DMA_TO_DEVICE);
> dmaengine_desc_free(rx_cmd_desc);
> return -EINVAL;
> @@ -872,9 +872,9 @@ static int lpi2c_dma_submit(struct lpi2c_imx_struct *lpi2c_imx)
> dma->dma_transfer_dir = DMA_MEM_TO_DEV;
> }
>
> - dma->dma_addr = dma_map_single(chan->device->dev,
> + dma->dma_addr = dma_map_single(dmaengine_get_dma_device(chan),
> dma->dma_buf, dma->dma_len, dma->dma_data_dir);
> - if (dma_mapping_error(chan->device->dev, dma->dma_addr)) {
> + if (dma_mapping_error(dmaengine_get_dma_device(chan), dma->dma_addr)) {
> dev_err(&lpi2c_imx->adapter.dev, "DMA map failed, use pio\n");
> return -EINVAL;
> }
> @@ -1085,7 +1085,7 @@ static int lpi2c_imx_dma_xfer(struct lpi2c_imx_struct *lpi2c_imx,
> }
>
> if (dma->dma_msg_flag & I2C_M_RD)
> - dma_unmap_single(dma->chan_tx->device->dev, dma->dma_tx_addr,
> + dma_unmap_single(dmaengine_get_dma_device(dma->chan_tx), dma->dma_tx_addr,
> dma->rx_cmd_buf_len, DMA_TO_DEVICE);
> lpi2c_dma_unmap(dma);
>
>
> ---
> base-commit: e6e35979777d646fe3c7c94dca7dd32fb25d45f4
> change-id: 20260916-i2c-dma-e9cd42e4e7ff
>
> Best regards,
> --
> Peng Fan <peng.fan@nxp.com>
>
>
prev parent reply other threads:[~2026-09-16 16:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 15:25 Peng Fan (OSS)
2026-09-16 16:43 ` Frank Li [this message]
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=aqrHJsO5xYBO4WvB@SMW015318 \
--to=frank.li@oss.nxp.com \
--cc=Frank.Li@nxp.com \
--cc=aisheng.dong@nxp.com \
--cc=andi.shyti@kernel.org \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peng.fan@nxp.com \
--cc=peng.fan@oss.nxp.com \
--cc=s.hauer@pengutronix.de \
/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
all inboxes | Powered by JetHome®