All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2] tty: serial: fsl_lpuart: use the sg count from dma_map_sg
@ 2019-11-07  2:50 Peng Fan
  2019-11-07  6:36 ` Peng Fan
  2019-11-07  7:02 ` gregkh
  0 siblings, 2 replies; 3+ messages in thread
From: Peng Fan @ 2019-11-07  2:50 UTC (permalink / raw
  To: gregkh@linuxfoundation.org, jslaby@suse.com, shawnguo@kernel.org,
	festevam@gmail.com
  Cc: dl-linux-imx, linux-serial@vger.kernel.org,
	linux-kernel@vger.kernel.org, Andy Duan, Peng Fan,
	stable@vger.kernel.org

From: Peng Fan <peng.fan@nxp.com>

The dmaengine_prep_slave_sg needs to use sg count returned
by dma_map_sg, not use sport->dma_tx_nents, because the return
value of dma_map_sg is not always same with "nents".

When enabling iommu for lpuart + edma, iommu framework may concatenate
two sgs into one.

Fixes: 6250cc30c4c4e ("tty: serial: fsl_lpuart: Use scatter/gather DMA for Tx")
Cc: <stable@vger.kernel.org>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---

V2:
 Assign ret to sport->dma_tx_nents, then we no need to fix dma_unmap_sg
 Hi Greg,
  I saw v1 patch merged to tty-next, please help to replace with V2 if this
  is ok for you, or you need I have a follow up fix for v1.

 drivers/tty/serial/fsl_lpuart.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index 3e17bb8a0b16..ec5ea098669e 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -436,6 +436,7 @@ static void lpuart_dma_tx(struct lpuart_port *sport)
 		return;
 	}
 
+	sport->dma_tx_nents = ret;
 	sport->dma_tx_desc = dmaengine_prep_slave_sg(sport->dma_tx_chan, sgl,
 					sport->dma_tx_nents,
 					DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT);
-- 
2.16.4


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

* RE: [PATCH V2] tty: serial: fsl_lpuart: use the sg count from dma_map_sg
  2019-11-07  2:50 [PATCH V2] tty: serial: fsl_lpuart: use the sg count from dma_map_sg Peng Fan
@ 2019-11-07  6:36 ` Peng Fan
  2019-11-07  7:02 ` gregkh
  1 sibling, 0 replies; 3+ messages in thread
From: Peng Fan @ 2019-11-07  6:36 UTC (permalink / raw
  To: gregkh@linuxfoundation.org, jslaby@suse.com, shawnguo@kernel.org,
	festevam@gmail.com
  Cc: dl-linux-imx, linux-serial@vger.kernel.org,
	linux-kernel@vger.kernel.org, Andy Duan, stable@vger.kernel.org

> Subject: [PATCH V2] tty: serial: fsl_lpuart: use the sg count from dma_map_sg

Ignore this patch. Keep v1.

Thanks,
Peng.

> 
> From: Peng Fan <peng.fan@nxp.com>
> 
> The dmaengine_prep_slave_sg needs to use sg count returned by
> dma_map_sg, not use sport->dma_tx_nents, because the return value of
> dma_map_sg is not always same with "nents".
> 
> When enabling iommu for lpuart + edma, iommu framework may concatenate
> two sgs into one.
> 
> Fixes: 6250cc30c4c4e ("tty: serial: fsl_lpuart: Use scatter/gather DMA for Tx")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> 
> V2:
>  Assign ret to sport->dma_tx_nents, then we no need to fix dma_unmap_sg
> Hi Greg,
>   I saw v1 patch merged to tty-next, please help to replace with V2 if this
>   is ok for you, or you need I have a follow up fix for v1.
> 
>  drivers/tty/serial/fsl_lpuart.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index
> 3e17bb8a0b16..ec5ea098669e 100644
> --- a/drivers/tty/serial/fsl_lpuart.c
> +++ b/drivers/tty/serial/fsl_lpuart.c
> @@ -436,6 +436,7 @@ static void lpuart_dma_tx(struct lpuart_port *sport)
>  		return;
>  	}
> 
> +	sport->dma_tx_nents = ret;
>  	sport->dma_tx_desc = dmaengine_prep_slave_sg(sport->dma_tx_chan,
> sgl,
>  					sport->dma_tx_nents,
>  					DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT);
> --
> 2.16.4


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

* Re: [PATCH V2] tty: serial: fsl_lpuart: use the sg count from dma_map_sg
  2019-11-07  2:50 [PATCH V2] tty: serial: fsl_lpuart: use the sg count from dma_map_sg Peng Fan
  2019-11-07  6:36 ` Peng Fan
@ 2019-11-07  7:02 ` gregkh
  1 sibling, 0 replies; 3+ messages in thread
From: gregkh @ 2019-11-07  7:02 UTC (permalink / raw
  To: Peng Fan
  Cc: jslaby@suse.com, shawnguo@kernel.org, festevam@gmail.com,
	dl-linux-imx, linux-serial@vger.kernel.org,
	linux-kernel@vger.kernel.org, Andy Duan, stable@vger.kernel.org

On Thu, Nov 07, 2019 at 02:50:11AM +0000, Peng Fan wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> The dmaengine_prep_slave_sg needs to use sg count returned
> by dma_map_sg, not use sport->dma_tx_nents, because the return
> value of dma_map_sg is not always same with "nents".
> 
> When enabling iommu for lpuart + edma, iommu framework may concatenate
> two sgs into one.
> 
> Fixes: 6250cc30c4c4e ("tty: serial: fsl_lpuart: Use scatter/gather DMA for Tx")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> 
> V2:
>  Assign ret to sport->dma_tx_nents, then we no need to fix dma_unmap_sg
>  Hi Greg,
>   I saw v1 patch merged to tty-next, please help to replace with V2 if this
>   is ok for you, or you need I have a follow up fix for v1.

I can not "replace" anything, my tree does not rebase, sorry.  Please
send fix-up patches on top of it if there is any changes that need to
happen.

thanks,

greg k-h

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

end of thread, other threads:[~2019-11-07  7:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-07  2:50 [PATCH V2] tty: serial: fsl_lpuart: use the sg count from dma_map_sg Peng Fan
2019-11-07  6:36 ` Peng Fan
2019-11-07  7:02 ` gregkh

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.