All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@oss.nxp.com>
To: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jirislaby@kernel.org>, Frank Li <Frank.Li@nxp.com>,
	Sherry Sun <sherry.sun@nxp.com>,
	imx@lists.linux.dev, linux-kernel@vger.kernel.org,
	linux-serial@vger.kernel.org, Peng Fan <peng.fan@nxp.com>
Subject: Re: [PATCH] tty: serial: fsl_lpuart: use dmaengine_get_dma_device() for DMA mapping
Date: Wed, 16 Sep 2026 14:22:48 -0500	[thread overview]
Message-ID: <aqrsiHDH0ebYo55w@SMW015318> (raw)
In-Reply-To: <20260916-lpuart-dma-v1-1-021be5b03e53@nxp.com>

On Wed, Sep 16, 2026 at 11:27:30PM +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/sync 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/tty/serial/fsl_lpuart.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
> index b7919c05f0fb8..c8575c9652035 100644
> --- a/drivers/tty/serial/fsl_lpuart.c
> +++ b/drivers/tty/serial/fsl_lpuart.c
> @@ -491,7 +491,7 @@ static void lpuart_dma_tx(struct lpuart_port *sport)
>  	sport->dma_tx_nents = kfifo_dma_out_prepare(&tport->xmit_fifo, sgl,
>  			ARRAY_SIZE(sport->tx_sgl), sport->dma_tx_bytes);
>
> -	ret = dma_map_sg(chan->device->dev, sgl, sport->dma_tx_nents,
> +	ret = dma_map_sg(dmaengine_get_dma_device(chan), sgl, sport->dma_tx_nents,
>  			 DMA_TO_DEVICE);
>  	if (!ret) {
>  		dev_err(dev, "DMA mapping error for TX.\n");
> @@ -502,7 +502,7 @@ static void lpuart_dma_tx(struct lpuart_port *sport)
>  					ret, DMA_MEM_TO_DEV,
>  					DMA_PREP_INTERRUPT);
>  	if (!sport->dma_tx_desc) {
> -		dma_unmap_sg(chan->device->dev, sgl, sport->dma_tx_nents,
> +		dma_unmap_sg(dmaengine_get_dma_device(chan), sgl, sport->dma_tx_nents,
>  			      DMA_TO_DEVICE);
>  		dev_err(dev, "Cannot prepare TX slave DMA!\n");
>  		return;
> @@ -535,7 +535,7 @@ static void lpuart_dma_tx_complete(void *arg)
>  		return;
>  	}
>
> -	dma_unmap_sg(chan->device->dev, sgl, sport->dma_tx_nents,
> +	dma_unmap_sg(dmaengine_get_dma_device(chan), sgl, sport->dma_tx_nents,
>  		     DMA_TO_DEVICE);
>
>  	uart_xmit_advance(&sport->port, sport->dma_tx_bytes);
> @@ -606,7 +606,7 @@ static void lpuart_flush_buffer(struct uart_port *port)
>
>  	if (sport->lpuart_dma_tx_use) {
>  		if (sport->dma_tx_in_progress) {
> -			dma_unmap_sg(chan->device->dev, &sport->tx_sgl[0],
> +			dma_unmap_sg(dmaengine_get_dma_device(chan), &sport->tx_sgl[0],
>  				sport->dma_tx_nents, DMA_TO_DEVICE);
>  			sport->dma_tx_in_progress = false;
>  		}
> @@ -1176,7 +1176,7 @@ static void lpuart_copy_rx_to_tty(struct lpuart_port *sport)
>  	}
>
>  	/* CPU claims ownership of RX DMA buffer */
> -	dma_sync_sg_for_cpu(chan->device->dev, &sport->rx_sgl, 1,
> +	dma_sync_sg_for_cpu(dmaengine_get_dma_device(chan), &sport->rx_sgl, 1,
>  			    DMA_FROM_DEVICE);
>
>  	/*
> @@ -1237,7 +1237,7 @@ static void lpuart_copy_rx_to_tty(struct lpuart_port *sport)
>  	sport->last_residue = state.residue;
>
>  exit:
> -	dma_sync_sg_for_device(chan->device->dev, &sport->rx_sgl, 1,
> +	dma_sync_sg_for_device(dmaengine_get_dma_device(chan), &sport->rx_sgl, 1,
>  			       DMA_FROM_DEVICE);
>
>  	uart_port_unlock_irqrestore(&sport->port, flags);
> @@ -1374,7 +1374,7 @@ static inline int lpuart_start_rx_dma(struct lpuart_port *sport)
>  		return -ENOMEM;
>
>  	sg_init_one(&sport->rx_sgl, ring->buf, sport->rx_dma_rng_buf_len);
> -	nent = dma_map_sg(chan->device->dev, &sport->rx_sgl, 1,
> +	nent = dma_map_sg(dmaengine_get_dma_device(chan), &sport->rx_sgl, 1,
>  			  DMA_FROM_DEVICE);
>
>  	if (!nent) {
> @@ -1430,7 +1430,7 @@ static inline int lpuart_start_rx_dma(struct lpuart_port *sport)
>  	return 0;
>
>  err_unmap_sg:
> -	dma_unmap_sg(chan->device->dev, &sport->rx_sgl, 1, DMA_FROM_DEVICE);
> +	dma_unmap_sg(dmaengine_get_dma_device(chan), &sport->rx_sgl, 1, DMA_FROM_DEVICE);
>  err_free_buf:
>  	kfree(ring->buf);
>  	ring->buf = NULL;
> @@ -1447,7 +1447,7 @@ static void lpuart_dma_rx_free(struct uart_port *port)
>  	if (!sport->dma_idle_int)
>  		timer_delete_sync(&sport->lpuart_timer);
>
> -	dma_unmap_sg(chan->device->dev, &sport->rx_sgl, 1, DMA_FROM_DEVICE);
> +	dma_unmap_sg(dmaengine_get_dma_device(chan), &sport->rx_sgl, 1, DMA_FROM_DEVICE);
>  	kfree(sport->rx_ring.buf);
>  	sport->rx_ring.tail = 0;
>  	sport->rx_ring.head = 0;
>
> ---
> base-commit: e6e35979777d646fe3c7c94dca7dd32fb25d45f4
> change-id: 20260916-lpuart-dma-9923b7b2e1da
>
> Best regards,
> --
> Peng Fan <peng.fan@nxp.com>
>
>

      parent reply	other threads:[~2026-09-16 19:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-16 15:27 [PATCH] tty: serial: fsl_lpuart: use dmaengine_get_dma_device() for DMA mapping Peng Fan (OSS)
2026-09-16 15:30 ` sashiko-bot
2026-09-16 19:22 ` 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=aqrsiHDH0ebYo55w@SMW015318 \
    --to=frank.li@oss.nxp.com \
    --cc=Frank.Li@nxp.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=imx@lists.linux.dev \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=peng.fan@nxp.com \
    --cc=peng.fan@oss.nxp.com \
    --cc=sherry.sun@nxp.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.