Subject: Re: r8169: IO_PAGE_FAULT & netdev watchdog

From: Vincent Pelletier <[email-masked]>
Date: Sat, 2 Jun 2012 11:08:52 +0200

Le vendredi 01 juin 2012 14:59:49, Francois Romieu a écrit :
> You can apply the attached patch but it may not do much for your problem.

After failing to build the module alone in a way that it would accept loading 
in debian-provided kernel, I fall back to building vanilla kernel + proposed 
patches.

I first went for 3.4, but realised the patch you attached was already applied 
there.

So I went with 3.3.7, and patch failed to apply, at least partly because 3.3.7 
lacks "r8169: fix early queue wake-up."[1] . I solved the conflicts manually, 
but I'm not sure of the result. Could you confirm attached patch might give 
expected result ? Or should I stick to 3.4 and only test inlined patch ?

[1] ae1f23fb433ac0aaff8aeaa5a7b14348e9aa8277

Regards,
-- 
Vincent Pelletier
--- drivers/net/ethernet/realtek/r8169.c.orig	2012-06-02 10:26:45.000000000 +0200
+++ drivers/net/ethernet/realtek/r8169.c	2012-06-02 10:58:37.000000000 +0200
@@ -62,8 +62,12 @@
 #define R8169_MSG_DEFAULT \
 	(NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_IFUP | NETIF_MSG_IFDOWN)
 
-#define TX_BUFFS_AVAIL(tp) \
-	(tp->dirty_tx + NUM_TX_DESC - tp->cur_tx - 1)
+#define TX_SLOTS_AVAIL(tp) \
+	(tp->dirty_tx + NUM_TX_DESC - tp->cur_tx)
+
+/* A skbuff with nr_frags needs nr_frags+1 entries in the tx queue */
+#define TX_FRAGS_READY_FOR(tp,nr_frags) \
+	(TX_SLOTS_AVAIL(tp) >= (nr_frags + 1))
 
 /* Maximum number of multicast addresses to filter (vs. Rx-all-multicast).
    The RTL chips use a 64 element hash table based on the Ethernet CRC. */
@@ -5513,7 +5517,7 @@
 	u32 opts[2];
 	int frags;
 
-	if (unlikely(TX_BUFFS_AVAIL(tp) < skb_shinfo(skb)->nr_frags)) {
+	if (unlikely(!TX_FRAGS_READY_FOR(tp, skb_shinfo(skb)->nr_frags))) {
 		netif_err(tp, drv, dev, "BUG! Tx Ring full when queue awake!\n");
 		goto err_stop_0;
 	}
@@ -5561,10 +5565,10 @@
 
 	RTL_W8(TxPoll, NPQ);
 
-	if (TX_BUFFS_AVAIL(tp) < MAX_SKB_FRAGS) {
+	if (!TX_FRAGS_READY_FOR(tp, MAX_SKB_FRAGS)) {
 		netif_stop_queue(dev);
 		smp_rmb();
-		if (TX_BUFFS_AVAIL(tp) >= MAX_SKB_FRAGS)
+		if (TX_FRAGS_READY_FOR(tp, MAX_SKB_FRAGS))
 			netif_wake_queue(dev);
 	}
 
@@ -5666,7 +5670,7 @@
 		tp->dirty_tx = dirty_tx;
 		smp_wmb();
 		if (netif_queue_stopped(dev) &&
-		    (TX_BUFFS_AVAIL(tp) >= MAX_SKB_FRAGS)) {
+		    TX_FRAGS_READY_FOR(tp, MAX_SKB_FRAGS)) {
 			netif_wake_queue(dev);
 		}
 		/*