From: Thierry Reding <treding@nvidia.com>
Date: Thu, 28 Aug 2014 10:38:03 +0000 (+0200)
Subject: rtl8169: Defer network packet processing
X-Git-Tag: v2025.01-rc5-pxa1908~14693
X-Git-Url: http://git.dujemihanovic.xyz/html/static/gitweb.css?a=commitdiff_plain;h=5d9f423ddb2d4739eeee14990f5369508dee5e9d;p=u-boot.git

rtl8169: Defer network packet processing

When network protocol errors occur (such as a file not being found on a
TFTP server), the processing done by the NetReceive() function will end
up calling the driver's .halt() implementation. However, after that the
device no longer has access to the memory buffers and will cause errors
such as this in the rtl_recv() function when trying to hand descriptors
back to the device:

	pci_hose_bus_to_phys: invalid physical address

This can be fixed by deferring processing of network packets until the
descriptors have been handed back. That way rtl_halt() tearing down
network buffers is not going to prevent access to the buffers.

Reported-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---

diff --git a/drivers/net/rtl8169.c b/drivers/net/rtl8169.c
index d040ab171b..c3ce17516c 100644
--- a/drivers/net/rtl8169.c
+++ b/drivers/net/rtl8169.c
@@ -469,7 +469,6 @@ static int rtl_recv(struct eth_device *dev)
 
 			rtl_inval_buffer(tpc->RxBufferRing[cur_rx], length);
 			memcpy(rxdata, tpc->RxBufferRing[cur_rx], length);
-			NetReceive(rxdata, length);
 
 			if (cur_rx == NUM_RX_DESC - 1)
 				tpc->RxDescArray[cur_rx].status =
@@ -480,6 +479,8 @@ static int rtl_recv(struct eth_device *dev)
 			tpc->RxDescArray[cur_rx].buf_addr =
 				cpu_to_le32(bus_to_phys(tpc->RxBufferRing[cur_rx]));
 			rtl_flush_rx_desc(&tpc->RxDescArray[cur_rx]);
+
+			NetReceive(rxdata, length);
 		} else {
 			puts("Error Rx");
 		}