2019-11-07 03:03:53

by Peng Fan

[permalink] [raw]
Subject: [PATCH] tty: serial: imx: use the sg count from dma_map_sg

From: Peng Fan <[email protected]>

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".

And update sport->dma_tx_nents with value from dma_map_sg to avoid
modifing dma_unmap_sg

Fixes: b4cdc8f61beb("serial: imx: add DMA support for imx6q")
Signed-off-by: Peng Fan <[email protected]>
---
drivers/tty/serial/imx.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 87c58f9f6390..bda7f59ec60e 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -619,6 +619,9 @@ static void imx_uart_dma_tx(struct imx_port *sport)
dev_err(dev, "DMA mapping error for TX.\n");
return;
}
+
+ sport->dma_tx_nents = ret;
+
desc = dmaengine_prep_slave_sg(chan, sgl, sport->dma_tx_nents,
DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT);
if (!desc) {
--
2.16.4


2019-11-07 06:41:15

by Peng Fan

[permalink] [raw]
Subject: RE: [PATCH] tty: serial: imx: use the sg count from dma_map_sg

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

Ignore this patch. Wrong fix, will have V2.

Thanks,
Peng.

>
> From: Peng Fan <[email protected]>
>
> 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".
>
> And update sport->dma_tx_nents with value from dma_map_sg to avoid
> modifing dma_unmap_sg
>
> Fixes: b4cdc8f61beb("serial: imx: add DMA support for imx6q")
> Signed-off-by: Peng Fan <[email protected]>
> ---
> drivers/tty/serial/imx.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index
> 87c58f9f6390..bda7f59ec60e 100644
> --- a/drivers/tty/serial/imx.c
> +++ b/drivers/tty/serial/imx.c
> @@ -619,6 +619,9 @@ static void imx_uart_dma_tx(struct imx_port *sport)
> dev_err(dev, "DMA mapping error for TX.\n");
> return;
> }
> +
> + sport->dma_tx_nents = ret;
> +
> desc = dmaengine_prep_slave_sg(chan, sgl, sport->dma_tx_nents,
> DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT);
> if (!desc) {
> --
> 2.16.4