Skip to contentSkip to conversation

tty: serial: fsl_lpuart: use the sg count from dma_map_sg

PATCH In review Peng Fan 2 participants 3 messages Nov 7, 2019

Subsystems (2)
lore
Share & tools
lore

Peng Fan

author
#0 lore raw

PATCH v2 1/1 tty: serial: fsl_lpuart: 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".

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

---

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(+)
drivers/tty/serial/fsl_lpuart.c +1 -0
index 3e17bb8a0b16..ec5ea098669e 100644
@@ -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);
Signature · 1 line
2.16.4
author
#1 lore raw
Quoted 1 line

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

Ignore this patch. Keep v1.

Thanks,
Peng.

Quoted 39 lines

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

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

---

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(+)
drivers/tty/serial/fsl_lpuart.c index renamed from drivers/tty/serial/fsl_lpuart.c +0 -0

3e17bb8a0b16..ec5ea098669e 100644

drivers/tty/serial/fsl_lpuart.c +1 -0
@@ -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

#2 lore raw
In reply to Peng Fan
Quoted 12 lines · Peng Fan

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

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")
Quoted 7 lines

---

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