Skip to contentSkip to conversation

2.6.3 - 8139too timeout debug info

DISCUSSION Nick Warne 4 participants 10 messages Feb 29, 2004 – Apr 4, 2004 2 messages not in the archive Network drivers

lore
Share & tools
lore

Nick Warne

author
#2 lore raw
In reply to a message not in the archive
Quoted 8 lines

Please try,

	8139too-debug + 8139too-revert01

and if it still is the same,

	8139too-debug + 8139too-revert01 + 8139too-revert02

OK, I have patched as asked, and still get the problem.

Information here, 2 new files:

http://www.linicks.net/8139too_debug/

debug_with_patch01.txt

&

debug_with_patch01_patch02.txt

Thank you for your time in this.

Nick

Signature · 2 lines
"When you're chewing on life's gristle,
Don't grumble, Give a whistle..."
#3 lore raw
Quoted 11 lines · Nick Warne

OK, I have patched as asked, and still get the problem.

Information here, 2 new files:

http://www.linicks.net/8139too_debug/

debug_with_patch01.txt

&

debug_with_patch01_patch02.txt

Thanks. Umm.. strange, already NAPI reverted.
Does these patches change the behavior?

debug + revert01 + revert02 + revert03

after

debug + revert01 + revert02 + revert03 + revert04

Signature · 1 line
OGAWA Hirofumi <[email protected]>

---

 drivers/net/8139too.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletion(-)
drivers/net/8139too.c renamed from drivers/net/8139too.c~8139too-revert03 +7 -1
diff -puN drivers/net/8139too.c~8139too-revert03 drivers/net/8139too.c
@@ -1374,7 +1374,7 @@ static int rtl8139_open (struct net_devi
 
 	rtl8139_start_thread(dev);
 
-	printk("%s: revert02\n", dev->name);
+	printk("%s: revert03\n", dev->name);
 	spin_lock_irq(&tp->lock);
 	RTL8139_DUMP(dev);
 	spin_unlock_irq(&tp->lock);
@@ -2172,8 +2172,11 @@ static irqreturn_t rtl8139_interrupt (in
 	u16 status, ackstat;
 	int link_changed = 0; /* avoid bogus "uninit" warning */
 	int handled = 0;
+	int boguscnt = 20;
 
 	spin_lock (&tp->lock);
+	do {
+
 	status = RTL_R16 (IntrStatus);
 
 	/* shared irq? */
@@ -2216,6 +2219,9 @@ static irqreturn_t rtl8139_interrupt (in
 		if (status & TxErr)
 			RTL_W16 (IntrStatus, TxErr);
 	}
+
+		boguscnt--;
+	} while(boguscnt > 0);
  out:
 	spin_unlock (&tp->lock);
 

_

---

 drivers/net/8139too.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletion(-)
drivers/net/8139too.c renamed from drivers/net/8139too.c~8139too-revert04 +9 -1
diff -puN drivers/net/8139too.c~8139too-revert04 drivers/net/8139too.c
@@ -1374,7 +1374,7 @@ static int rtl8139_open (struct net_devi
 
 	rtl8139_start_thread(dev);
 
-	printk("%s: revert03\n", dev->name);
+	printk("%s: revert04\n", dev->name);
 	spin_lock_irq(&tp->lock);
 	RTL8139_DUMP(dev);
 	spin_unlock_irq(&tp->lock);
@@ -2225,6 +2225,14 @@ static irqreturn_t rtl8139_interrupt (in
  out:
 	spin_unlock (&tp->lock);
 
+	if (boguscnt <= 0) {
+		printk (KERN_WARNING "%s: Too much work at interrupt, "
+			"IntrStatus=0x%4.4x.\n", dev->name, status);
+
+		/* Clear all interrupt sources. */
+		RTL_W16 (IntrStatus, 0xffff);
+	}
+
 	DPRINTK ("%s: exiting interrupt, intr_status=%#4.4x.\n",
 		 dev->name, RTL_R16 (IntrStatus));
 	return IRQ_RETVAL(handled);

_

author
#4 lore raw
Quoted 6 lines

Thanks. Umm.. strange, already NAPI reverted.
Does these patches change the behavior?

debug + revert01 + revert02 + revert03

**BINGO**

Excellent. patch03 has stopped the timeouts. I have just tested. I moved (via ftp) a 30MB file from network -> eth0, and at the same time downloaded a 30MB file (via httpd) from the Internet -> eth1.

I was getting 10Mbs internal, and 30Kbs external (as expected). NO TIMEOUTS :) :)

Before, just the internal FTP timed out in 5 seconds.

dmesg is basically very quiet:

http://www.linicks.net/8139too_debug/bingo.txt

Quoted 3 lines

after

debug + revert01 + revert02 + revert03 + revert04

I haven't applied patch04.

I will continue to run the debug kernel.

Thank you :)

Nick

Signature · 2 lines
"When you're chewing on life's gristle,
Don't grumble, Give a whistle..."
#5 lore raw
Quoted 20 lines · Nick Warne
Quoted 4 lines

Thanks. Umm.. strange, already NAPI reverted.
Does these patches change the behavior?

debug + revert01 + revert02 + revert03

**BINGO**

Excellent. patch03 has stopped the timeouts. I have just tested. I moved (via ftp) a 30MB file from network -> eth0, and at the same time downloaded a 30MB file (via httpd) from the Internet -> eth1.

I was getting 10Mbs internal, and 30Kbs external (as expected). NO TIMEOUTS :) :)

Before, just the internal FTP timed out in 5 seconds.

dmesg is basically very quiet:

http://www.linicks.net/8139too_debug/bingo.txt

Quoted 7 lines
Quoted 3 lines

after

debug + revert01 + revert02 + revert03 + revert04

I haven't applied patch04.

I will continue to run the debug kernel.

Ok, thanks for debugging. Looks like this problem is not 8139too. And same problem should happen with the old driver (probably, it appear with "max_interrupt_work=1").

Umm... I guess this problem is miss config of Edge/Level-Trigger or something. Sorry, I don't know detail.

Jeff, I think CONFIG_8139TOO_NAPI is useful for now. What do you think of these? Any idea?

8139too-config-napi.patch - add CONFIG_8139TOO_NAPI
(dirty #ifdef, the cleanup may be needed)
8139too-useful-txtimeout.patch - more debug info for rtl8139_tx_timeout()

Thanks.

Signature · 1 line
OGAWA Hirofumi <[email protected]>

[PATCH] 8139too: add CONFIG_8139TOO_NAPI

This patch adds the CONFIG_8139TOO_NAPI.

---

 drivers/net/8139too.c |  102 ++++++++++++++++++++++++++++++++++++++++++++++++--
 drivers/net/Kconfig   |    4 +
 2 files changed, 102 insertions(+), 4 deletions(-)
drivers/net/8139too.c renamed from drivers/net/8139too.c~8139too-config-napi +98 -4
diff -puN drivers/net/8139too.c~8139too-config-napi drivers/net/8139too.c
@@ -159,6 +159,11 @@
 static int media[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1};
 static int full_duplex[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1};
 
+#ifndef CONFIG_8139TOO_NAPI
+/* Maximum events (Rx packets, etc.) to handle at each interrupt. */
+static int max_interrupt_work = 20;
+#endif
+
 /* 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.  */
 static int multicast_filter_limit = 32;
@@ -592,6 +597,10 @@ MODULE_AUTHOR ("Jeff Garzik <jgarzik@pob
 MODULE_DESCRIPTION ("RealTek RTL-8139 Fast Ethernet driver");
 MODULE_LICENSE("GPL");
 
+#ifndef CONFIG_8139TOO_NAPI
+MODULE_PARM (max_interrupt_work, "i");
+MODULE_PARM_DESC (max_interrupt_work, "8139too maximum events handled per interrupt");
+#endif
 MODULE_PARM (multicast_filter_limit, "i");
 MODULE_PARM (media, "1-" __MODULE_STRING(MAX_UNITS) "i");
 MODULE_PARM (full_duplex, "1-" __MODULE_STRING(MAX_UNITS) "i");
@@ -611,7 +620,9 @@ static void rtl8139_tx_timeout (struct n
 static void rtl8139_init_ring (struct net_device *dev);
 static int rtl8139_start_xmit (struct sk_buff *skb,
 			       struct net_device *dev);
+#ifdef CONFIG_8139TOO_NAPI
 static int rtl8139_poll(struct net_device *dev, int *budget);
+#endif
 #ifdef CONFIG_NET_POLL_CONTROLLER
 static void rtl8139_poll_controller(struct net_device *dev);
 #endif
@@ -983,8 +994,10 @@ static int __devinit rtl8139_init_one (s
 	/* The Rtl8139-specific entries in the device structure. */
 	dev->open = rtl8139_open;
 	dev->hard_start_xmit = rtl8139_start_xmit;
+#ifdef CONFIG_8139TOO_NAPI
 	dev->poll = rtl8139_poll;
 	dev->weight = 64;
+#endif
 	dev->stop = rtl8139_close;
 	dev->get_stats = rtl8139_get_stats;
 	dev->set_multicast_list = rtl8139_set_rx_mode;
@@ -1938,7 +1951,10 @@ static int rtl8139_rx(struct net_device 
 		 RTL_R16 (RxBufAddr),
 		 RTL_R16 (RxBufPtr), RTL_R8 (ChipCmd));
 
-	while (netif_running(dev) && received < budget 
+	while (netif_running(dev)
+#ifdef CONFIG_8139TOO_NAPI
+	       && received < budget
+#endif
 	       && (RTL_R8 (ChipCmd) & RxBufEmpty) == 0) {
 		u32 ring_offset = cur_rx % RX_BUF_LEN;
 		u32 rx_status;
@@ -2009,8 +2025,11 @@ static int rtl8139_rx(struct net_device 
 			dev->last_rx = jiffies;
 			tp->stats.rx_bytes += pkt_size;
 			tp->stats.rx_packets++;
-
+#ifdef CONFIG_8139TOO_NAPI
 			netif_receive_skb (skb);
+#else
+			netif_rx (skb);
+#endif
 		} else {
 			if (net_ratelimit()) 
 				printk (KERN_WARNING
@@ -2088,6 +2107,7 @@ static void rtl8139_weird_interrupt (str
 	}
 }
 
+#ifdef CONFIG_8139TOO_NAPI
 static int rtl8139_poll(struct net_device *dev, int *budget)
 {
 	struct rtl8139_private *tp = dev->priv;
@@ -2138,13 +2158,13 @@ static irqreturn_t rtl8139_interrupt (in
 	status = RTL_R16 (IntrStatus);
 
 	/* shared irq? */
-	if (unlikely((status & rtl8139_intr_mask) == 0)) 
+	if (unlikely((status & rtl8139_intr_mask) == 0))
 		goto out;
 
 	handled = 1;
 
 	/* h/w no longer present (hotplug?) or major error, bail */
-	if (unlikely(status == 0xFFFF)) 
+	if (unlikely(status == 0xFFFF))
 		goto out;
 
 	/* close possible race's with dev_close */
@@ -2188,6 +2208,80 @@ static irqreturn_t rtl8139_interrupt (in
 		 dev->name, RTL_R16 (IntrStatus));
 	return IRQ_RETVAL(handled);
 }
+#else /* !CONFIG_8139TOO_NAPI */
+static irqreturn_t rtl8139_interrupt (int irq, void *dev_instance,
+			       struct pt_regs *regs)
+{
+	struct net_device *dev = (struct net_device *) dev_instance;
+	struct rtl8139_private *tp = dev->priv;
+	int boguscnt = max_interrupt_work;
+	void *ioaddr = tp->mmio_addr;
+	u16 status, ackstat;
+	int link_changed = 0; /* avoid bogus "uninit" warning */
+	int handled = 0;
+
+	spin_lock (&tp->lock);
+
+	do {
+		status = RTL_R16 (IntrStatus);
+
+		/* shared irq? */
+		if (unlikely((status & rtl8139_intr_mask) == 0))
+			goto out;
+
+		handled = 1;
+
+		/* h/w no longer present (hotplug?) or major error, bail */
+		if (unlikely(status == 0xFFFF))
+			goto out;
+
+		/* close possible race's with dev_close */
+		if (unlikely(!netif_running(dev))) {
+			RTL_W16 (IntrMask, 0);
+			goto out;
+		}
+
+		/* Acknowledge all of the current interrupt sources ASAP, but
+		   an first get an additional status bit from CSCR. */
+		if (unlikely(status & RxUnderrun))
+			link_changed = RTL_R16 (CSCR) & CSCR_LinkChangeBit;
+
+		ackstat = status & ~(RxAckBits | TxErr);
+		if (ackstat)
+			RTL_W16 (IntrStatus, ackstat);
+
+		if (status & RxAckBits)
+			rtl8139_rx (dev, tp, 0);
+
+		/* Check uncommon events with one test. */
+		if (unlikely(status & (PCIErr|PCSTimeout|RxUnderrun|RxErr)))
+			rtl8139_weird_interrupt (dev, tp, ioaddr,
+						 status, link_changed);
+
+		if (status & (TxOK | TxErr)) {
+			rtl8139_tx_interrupt (dev, tp, ioaddr);
+			if (status & TxErr)
+				RTL_W16 (IntrStatus, TxErr);
+		}
+
+		boguscnt--;
+	} while (boguscnt > 0);
+ out:
+	if (boguscnt <= 0) {
+		printk (KERN_WARNING "%s: Too much work at interrupt, "
+			"IntrStatus=0x%4.4x.\n", dev->name, status);
+
+		/* Clear all interrupt sources. */
+		RTL_W16 (IntrStatus, 0xffff);
+	}
+
+	spin_unlock (&tp->lock);
+
+	DPRINTK ("%s: exiting interrupt, intr_status=%#4.4x.\n",
+		 dev->name, RTL_R16 (IntrStatus));
+	return IRQ_RETVAL(handled);
+}
+#endif /* !CONFIG_8139TOO_NAPI */
 
 #ifdef CONFIG_NET_POLL_CONTROLLER
 /*
drivers/net/Kconfig renamed from drivers/net/Kconfig~8139too-config-napi +4 -0
diff -puN drivers/net/Kconfig~8139too-config-napi drivers/net/Kconfig
@@ -1543,6 +1543,10 @@ config 8139TOO
 	  To compile this driver as a module, choose M here: the module
 	  will be called 8139too.  This is recommended.
 
+config 8139TOO_NAPI
+	bool "Use Rx Polling (NAPI)"
+	depends on 8139TOO
+
 config 8139TOO_PIO
 	bool "Use PIO instead of MMIO"
 	default y

_

[PATCH] 8139too: more useful debug info for tx_timeout

	/* disable Tx ASAP, if not already */
	tmp8 = RTL_R8 (ChipCmd);
	if (tmp8 & CmdTxEnb)
		RTL_W8 (ChipCmd, CmdRxEnb);

The above will clear the Tx Descs. So, this prints the debugging info before rtl8139_tx_timeout() does it. And IntrStatus etc. also prints anytime for the debug.

---

 drivers/net/8139too.c |   28 +++++++++++++---------------
 1 files changed, 13 insertions(+), 15 deletions(-)
drivers/net/8139too.c renamed from drivers/net/8139too.c~8139too-useful-txtimeout +13 -15
diff -puN drivers/net/8139too.c~8139too-useful-txtimeout drivers/net/8139too.c
@@ -1686,11 +1686,19 @@ static void rtl8139_tx_timeout (struct n
 	u8 tmp8;
 	unsigned long flags;
 
-	DPRINTK ("%s: Transmit timeout, status %2.2x %4.4x "
-		 "media %2.2x.\n", dev->name,
-		 RTL_R8 (ChipCmd),
-		 RTL_R16 (IntrStatus),
-		 RTL_R8 (MediaStatus));
+	spin_lock(&tp->rx_lock);
+	printk (KERN_DEBUG "%s: Transmit timeout, status %2.2x %4.4x %4.4x "
+		"media %2.2x.\n", dev->name, RTL_R8 (ChipCmd),
+		RTL_R16(IntrStatus), RTL_R16(IntrMask), RTL_R8(MediaStatus));
+	/* Emit info to figure out what went wrong. */
+	printk (KERN_DEBUG "%s: Tx queue start entry %ld  dirty entry %ld.\n",
+		dev->name, tp->cur_tx, tp->dirty_tx);
+	for (i = 0; i < NUM_TX_DESC; i++)
+		printk (KERN_DEBUG "%s:  Tx descriptor %d is %8.8lx.%s\n",
+			dev->name, i, RTL_R32 (TxStatus0 + (i * 4)),
+			i == tp->dirty_tx % NUM_TX_DESC ?
+				" (queue head)" : "");
+	spin_unlock(&tp->rx_lock);
 
 	tp->xstats.tx_timeouts++;
 
@@ -1703,15 +1711,6 @@ static void rtl8139_tx_timeout (struct n
 	/* Disable interrupts by clearing the interrupt mask. */
 	RTL_W16 (IntrMask, 0x0000);
 
-	/* Emit info to figure out what went wrong. */
-	printk (KERN_DEBUG "%s: Tx queue start entry %ld  dirty entry %ld.\n",
-		dev->name, tp->cur_tx, tp->dirty_tx);
-	for (i = 0; i < NUM_TX_DESC; i++)
-		printk (KERN_DEBUG "%s:  Tx descriptor %d is %8.8lx.%s\n",
-			dev->name, i, RTL_R32 (TxStatus0 + (i * 4)),
-			i == tp->dirty_tx % NUM_TX_DESC ?
-				" (queue head)" : "");
-
 	/* Stop a shared interrupt from scavenging while we are. */
 	spin_lock_irqsave (&tp->lock, flags);
 	rtl8139_tx_clear (tp);
@@ -1723,7 +1722,6 @@ static void rtl8139_tx_timeout (struct n
 		netif_wake_queue (dev);
 	}
 	spin_unlock(&tp->rx_lock);
-	
 }
 
 

_

author
#6 lore raw
Quoted 6 lines

Ok, thanks for debugging. Looks like this problem is not 8139too. And same problem should happen with the old driver (probably, it appear with "max_interrupt_work=1").

Umm... I guess this problem is miss config of Edge/Level-Trigger or something. Sorry, I don't know detail.

Well, after running whatever patches you supplied for me to test, I can confirm after running it for 30 hours, it works a treat - and without having any true measuring devices on network performance, I can tell you it is very much faster and responsive all round... on downloads, web browsing, FTP - everything. (as you do say, I did used to get pauses sometimes during large file movement/downloads etc., but just thought it was normal network activity - I do not get them any more!).

Insomuchso I have kept this debug 8139too.c build as a running kernel now.

Thank you,

Nick

Signature · 2 lines
"When you're chewing on life's gristle,
Don't grumble, Give a whistle..."
#7 lore raw

What was the final resolution of the 8139too debugging?

#9 lore raw
Quoted 5 lines · OGAWA Hirofumi
Quoted 1 line · Jeff Garzik

What was the final resolution of the 8139too debugging?

http://marc.theaimsgroup.com/?l=linux-kernel&m=107919285122190&w=2
The cause of his problem was BIOS configuration. It was edge-trigger.

not sure if that was the only reason. 2.6.3 and everything up breaks the rtl nic in my laptop and i cant configure anything like edge-trigger in my bios.

The nic works without problems when i use 2.6.2 version of 8139too.c. Is there any possibility to get these or similar patches into 2.6.5 to support a config option to get the old behavior?

#10 lore raw
Quoted 11 lines · Christian Gut
Quoted 5 lines · OGAWA Hirofumi
Quoted 1 line · Jeff Garzik

What was the final resolution of the 8139too debugging?

http://marc.theaimsgroup.com/?l=linux-kernel&m=107919285122190&w=2
The cause of his problem was BIOS configuration. It was edge-trigger.

not sure if that was the only reason. 2.6.3 and everything up breaks the rtl nic in my laptop and i cant configure anything like edge-trigger in my bios.

Could you please tell more detail, what happened? And please send the /proc/interrupt, dmesg, lspci -vvvxxx.

Quoted 3 lines

The nic works without problems when i use 2.6.2 version of 8139too.c. Is there any possibility to get these or similar patches into 2.6.5 to support a config option to get the old behavior?

Signature · 1 line
OGAWA Hirofumi <[email protected]>
#11 lore raw
Quoted 5 lines · OGAWA Hirofumi
Quoted 3 lines · Christian Gut
Quoted 1 line · OGAWA Hirofumi

Jeff Garzik <[email protected]> writes:

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 1 line

What was the final resolution of the 8139too debugging?

http://marc.theaimsgroup.com/?l=linux-kernel&m=107919285122190&w=2
The cause of his problem was BIOS configuration. It was edge-trigger.

not sure if that was the only reason. 2.6.3 and everything up breaks the rtl nic in my laptop and i cant configure anything like edge-trigger in my bios.

This problem was also edge-triggered interrupt. In his case, ACPI enable fixes it.

Looks like APCI does the following in acpi_pci_irq_enable(),

	/* 
	 * Make sure all (legacy) PCI IRQs are set as level-triggered.
	 */
#ifdef CONFIG_X86
	{
		static u16 irq_mask;
		if ((dev->irq < 16) &&  !((1 << dev->irq) & irq_mask)) {
			ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Setting IRQ %d as level-triggered\n", dev->irq));
			irq_mask |= (1 << dev->irq);
			eisa_set_level_irq(dev->irq);
		}
	}

#endif

This one is useful as workaround. But I think eisa_set_level_irq() is not enough for doing this, because looks like the some chips needs additional setting.

Probably we need the proper interface... Ummm..

Signature · 1 line
OGAWA Hirofumi <[email protected]>