diff mbox series

[net-next] r8169: improve DMA handling in rtl_rx

Message ID 32c6566d-12c3-a01e-c8b0-f68c32949c2c@gmail.com
State Accepted
Delegated to: David Miller
Headers show
Series [net-next] r8169: improve DMA handling in rtl_rx | expand

Commit Message

Heiner Kallweit Aug. 26, 2019, 8:52 p.m. UTC
Move the call to dma_sync_single_for_cpu after calling napi_alloc_skb.
This avoids calling dma_sync_single_for_cpu w/o handing control back
to device if the memory allocation should fail.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/ethernet/realtek/r8169_main.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

David Miller Aug. 26, 2019, 9:33 p.m. UTC | #1
From: Heiner Kallweit <hkallweit1@gmail.com>
Date: Mon, 26 Aug 2019 22:52:36 +0200

> Move the call to dma_sync_single_for_cpu after calling napi_alloc_skb.
> This avoids calling dma_sync_single_for_cpu w/o handing control back
> to device if the memory allocation should fail.
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>

Applied.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
index 6182e7d33..faa4041cf 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -5807,16 +5807,15 @@  static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, u32 budget
 				goto release_descriptor;
 			}
 
-			dma_sync_single_for_cpu(tp_to_dev(tp),
-						le64_to_cpu(desc->addr),
-						pkt_size, DMA_FROM_DEVICE);
-
 			skb = napi_alloc_skb(&tp->napi, pkt_size);
 			if (unlikely(!skb)) {
 				dev->stats.rx_dropped++;
 				goto release_descriptor;
 			}
 
+			dma_sync_single_for_cpu(tp_to_dev(tp),
+						le64_to_cpu(desc->addr),
+						pkt_size, DMA_FROM_DEVICE);
 			prefetch(rx_buf);
 			skb_copy_to_linear_data(skb, rx_buf, pkt_size);
 			skb->tail += pkt_size;