All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net,stable 1/1] net: fec: unmap the xmit buffer that are not transferred by DMA
@ 2017-12-22  9:12 Fugang Duan
  2017-12-27  1:21 ` Andy Duan
  2017-12-27 15:57 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Fugang Duan @ 2017-12-22  9:12 UTC (permalink / raw)
  To: davem; +Cc: netdev, fugang.duan

The enet IP only support 32 bit, it will use swiotlb buffer to do dma
mapping when xmit buffer DMA memory address is bigger than 4G in i.MX
platform. After stress suspend/resume test, it will print out:

log:
[12826.352864] fec 5b040000.ethernet: swiotlb buffer is full (sz: 191 bytes)
[12826.359676] DMA: Out of SW-IOMMU space for 191 bytes at device 5b040000.ethernet
[12826.367110] fec 5b040000.ethernet eth0: Tx DMA memory map failed

The issue is that the ready xmit buffers that are dma mapped but DMA still
don't copy them into fifo, once MAC restart, these DMA buffers are not unmapped.
So it should check the dma mapping buffer and unmap them.

Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
---
 drivers/net/ethernet/freescale/fec_main.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 2d1b065..e17d10b 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -818,6 +818,12 @@ static void fec_enet_bd_init(struct net_device *dev)
 		for (i = 0; i < txq->bd.ring_size; i++) {
 			/* Initialize the BD for every fragment in the page. */
 			bdp->cbd_sc = cpu_to_fec16(0);
+			if (bdp->cbd_bufaddr &&
+			    !IS_TSO_HEADER(txq, fec32_to_cpu(bdp->cbd_bufaddr)))
+				dma_unmap_single(&fep->pdev->dev,
+						 fec32_to_cpu(bdp->cbd_bufaddr),
+						 fec16_to_cpu(bdp->cbd_datlen),
+						 DMA_TO_DEVICE);
 			if (txq->tx_skbuff[i]) {
 				dev_kfree_skb_any(txq->tx_skbuff[i]);
 				txq->tx_skbuff[i] = NULL;
-- 
1.9.1

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

* RE: [PATCH net,stable 1/1] net: fec: unmap the xmit buffer that are not transferred by DMA
  2017-12-22  9:12 [PATCH net,stable 1/1] net: fec: unmap the xmit buffer that are not transferred by DMA Fugang Duan
@ 2017-12-27  1:21 ` Andy Duan
  2017-12-27 15:57 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Andy Duan @ 2017-12-27  1:21 UTC (permalink / raw)
  To: Andy Duan, davem; +Cc: netdev

From: Fugang Duan <fugang.duan@nxp.com> Sent: Friday, December 22, 2017 5:12 PM
>The enet IP only support 32 bit, it will use swiotlb buffer to do dma mapping
>when xmit buffer DMA memory address is bigger than 4G in i.MX platform.
>After stress suspend/resume test, it will print out:
>
>log:
>[12826.352864] fec 5b040000.ethernet: swiotlb buffer is full (sz: 191 bytes)
>[12826.359676] DMA: Out of SW-IOMMU space for 191 bytes at device
>5b040000.ethernet [12826.367110] fec 5b040000.ethernet eth0: Tx DMA
>memory map failed
>
>The issue is that the ready xmit buffers that are dma mapped but DMA still
>don't copy them into fifo, once MAC restart, these DMA buffers are not
>unmapped.
>So it should check the dma mapping buffer and unmap them.
>
>Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
>---
Hi David,

The patch pass two days long time suspend/resume test. Pls apply it to net tree and stable tree.

Thanks.

> drivers/net/ethernet/freescale/fec_main.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
>diff --git a/drivers/net/ethernet/freescale/fec_main.c
>b/drivers/net/ethernet/freescale/fec_main.c
>index 2d1b065..e17d10b 100644
>--- a/drivers/net/ethernet/freescale/fec_main.c
>+++ b/drivers/net/ethernet/freescale/fec_main.c
>@@ -818,6 +818,12 @@ static void fec_enet_bd_init(struct net_device *dev)
> 		for (i = 0; i < txq->bd.ring_size; i++) {
> 			/* Initialize the BD for every fragment in the page. */
> 			bdp->cbd_sc = cpu_to_fec16(0);
>+			if (bdp->cbd_bufaddr &&
>+			    !IS_TSO_HEADER(txq, fec32_to_cpu(bdp-
>>cbd_bufaddr)))
>+				dma_unmap_single(&fep->pdev->dev,
>+						 fec32_to_cpu(bdp-
>>cbd_bufaddr),
>+						 fec16_to_cpu(bdp-
>>cbd_datlen),
>+						 DMA_TO_DEVICE);
> 			if (txq->tx_skbuff[i]) {
> 				dev_kfree_skb_any(txq->tx_skbuff[i]);
> 				txq->tx_skbuff[i] = NULL;
>--
>1.9.1

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

* Re: [PATCH net,stable 1/1] net: fec: unmap the xmit buffer that are not transferred by DMA
  2017-12-22  9:12 [PATCH net,stable 1/1] net: fec: unmap the xmit buffer that are not transferred by DMA Fugang Duan
  2017-12-27  1:21 ` Andy Duan
@ 2017-12-27 15:57 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2017-12-27 15:57 UTC (permalink / raw)
  To: fugang.duan; +Cc: netdev

From: Fugang Duan <fugang.duan@nxp.com>
Date: Fri, 22 Dec 2017 17:12:09 +0800

> The enet IP only support 32 bit, it will use swiotlb buffer to do dma
> mapping when xmit buffer DMA memory address is bigger than 4G in i.MX
> platform. After stress suspend/resume test, it will print out:
> 
> log:
> [12826.352864] fec 5b040000.ethernet: swiotlb buffer is full (sz: 191 bytes)
> [12826.359676] DMA: Out of SW-IOMMU space for 191 bytes at device 5b040000.ethernet
> [12826.367110] fec 5b040000.ethernet eth0: Tx DMA memory map failed
> 
> The issue is that the ready xmit buffers that are dma mapped but DMA still
> don't copy them into fifo, once MAC restart, these DMA buffers are not unmapped.
> So it should check the dma mapping buffer and unmap them.
> 
> Signed-off-by: Fugang Duan <fugang.duan@nxp.com>

Applied and queued up for -stable.

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

end of thread, other threads:[~2017-12-27 15:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-22  9:12 [PATCH net,stable 1/1] net: fec: unmap the xmit buffer that are not transferred by DMA Fugang Duan
2017-12-27  1:21 ` Andy Duan
2017-12-27 15:57 ` David Miller

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.