* [patch 1/3] natsemi: Consistently use interrupt enable/disable functions
2007-03-14 19:49 [patch 0/3] natsemi updates broonie
@ 2007-03-14 19:49 ` broonie
2007-03-15 15:00 ` Jeff Garzik
2007-03-14 19:49 ` [patch 2/3] natsemi: Fix NAPI for interrupt sharing broonie
2007-03-14 19:49 ` [patch 3/3] natsemi: Avoid IntrStatus lossage if RX state machine resets broonie
2 siblings, 1 reply; 5+ messages in thread
From: broonie @ 2007-03-14 19:49 UTC (permalink / raw)
To: Jeff Garzik, Tim Hockin; +Cc: netdev, linux-kernel
[-- Attachment #1: natsemi-consistent-irq-enable --]
[-- Type: text/plain, Size: 1466 bytes --]
The natsemi drivers include functions for enabling and disabling
interrupts from the chip but these are not used in all code paths. This
patch changes the code paths that touch the interrupt enable register to
use the functions. In all cases this adds an extra PCI read to post the
operation but since none of these are in fast paths this shouldn't be
too much of a problem.
Signed-Off-By: Mark Brown <broonie@sirena.org.uk>
Index: linux-2.6/drivers/net/natsemi.c
===================================================================
--- linux-2.6.orig/drivers/net/natsemi.c 2007-03-11 02:27:34.000000000 +0000
+++ linux-2.6/drivers/net/natsemi.c 2007-03-11 02:32:43.000000000 +0000
@@ -1712,7 +1712,7 @@
/* Enable interrupts by setting the interrupt mask. */
writel(DEFAULT_INTR, ioaddr + IntrMask);
- writel(1, ioaddr + IntrEnable);
+ natsemi_irq_enable(dev);
writel(RxOn | TxOn, ioaddr + ChipCmd);
writel(StatsClear, ioaddr + StatsCtrl); /* Clear Stats */
@@ -3071,7 +3071,7 @@
* Could be used to send a netlink message.
*/
writel(WOLPkt | LinkChange, ioaddr + IntrMask);
- writel(1, ioaddr + IntrEnable);
+ natsemi_irq_enable(dev);
}
}
@@ -3202,7 +3202,7 @@
disable_irq(dev->irq);
spin_lock_irq(&np->lock);
- writel(0, ioaddr + IntrEnable);
+ natsemi_irq_disable(dev);
np->hands_off = 1;
natsemi_stop_rxtx(dev);
netif_stop_queue(dev);
--
"You grabbed my hand and we fell into it, like a daydream - or a fever."
^ permalink raw reply [flat|nested] 5+ messages in thread
* [patch 2/3] natsemi: Fix NAPI for interrupt sharing
2007-03-14 19:49 [patch 0/3] natsemi updates broonie
2007-03-14 19:49 ` [patch 1/3] natsemi: Consistently use interrupt enable/disable functions broonie
@ 2007-03-14 19:49 ` broonie
2007-03-14 19:49 ` [patch 3/3] natsemi: Avoid IntrStatus lossage if RX state machine resets broonie
2 siblings, 0 replies; 5+ messages in thread
From: broonie @ 2007-03-14 19:49 UTC (permalink / raw)
To: Jeff Garzik, Tim Hockin
Cc: netdev, linux-kernel, Sergei Shtylyov, Simon Blake
[-- Attachment #1: natsemi-fix-napi-shared-interrupt --]
[-- Type: text/plain, Size: 3212 bytes --]
The interrupt status register for the natsemi chips is clear on read and
was read unconditionally from both the interrupt and from the NAPI poll
routine, meaning that if the interrupt service routine was called (for
example, due to a shared interrupt) while a NAPI poll was scheduled
interrupts could be missed. This patch fixes that by ensuring that the
interrupt status register is only read by the interrupt handler when
interrupts are enabled from the chip.
It also reverts a workaround for this problem from the netpoll hook and
improves the trace for interrupt events.
Thanks to Sergei Shtylyov <sshtylyov@ru.mvista.com> for spotting the
issue, Mark Huth <mhuth@mvista.com> for a simpler method and Simon
Blake <simon@citylink.co.nz> for testing resources.
Signed-Off-By: Mark Brown <broonie@sirena.org.uk>
Index: linux-2.6/drivers/net/natsemi.c
===================================================================
--- linux-2.6.orig/drivers/net/natsemi.c 2007-03-11 02:32:43.000000000 +0000
+++ linux-2.6/drivers/net/natsemi.c 2007-03-13 19:38:31.000000000 +0000
@@ -2119,28 +2119,35 @@
struct netdev_private *np = netdev_priv(dev);
void __iomem * ioaddr = ns_ioaddr(dev);
- if (np->hands_off)
+ /* Reading IntrStatus automatically acknowledges so don't do
+ * that while interrupts are disabled, (for example, while a
+ * poll is scheduled). */
+ if (np->hands_off || !readl(ioaddr + IntrEnable))
return IRQ_NONE;
- /* Reading automatically acknowledges. */
np->intr_status = readl(ioaddr + IntrStatus);
+ if (!np->intr_status)
+ return IRQ_NONE;
+
if (netif_msg_intr(np))
printk(KERN_DEBUG
"%s: Interrupt, status %#08x, mask %#08x.\n",
dev->name, np->intr_status,
readl(ioaddr + IntrMask));
- if (!np->intr_status)
- return IRQ_NONE;
-
prefetch(&np->rx_skbuff[np->cur_rx % RX_RING_SIZE]);
if (netif_rx_schedule_prep(dev)) {
/* Disable interrupts and register for poll */
natsemi_irq_disable(dev);
__netif_rx_schedule(dev);
- }
+ } else
+ printk(KERN_WARNING
+ "%s: Ignoring interrupt, status %#08x, mask %#08x.\n",
+ dev->name, np->intr_status,
+ readl(ioaddr + IntrMask));
+
return IRQ_HANDLED;
}
@@ -2156,6 +2163,12 @@
int work_done = 0;
do {
+ if (netif_msg_intr(np))
+ printk(KERN_DEBUG
+ "%s: Poll, status %#08x, mask %#08x.\n",
+ dev->name, np->intr_status,
+ readl(ioaddr + IntrMask));
+
if (np->intr_status &
(IntrTxDone | IntrTxIntr | IntrTxIdle | IntrTxErr)) {
spin_lock(&np->lock);
@@ -2399,19 +2412,8 @@
#ifdef CONFIG_NET_POLL_CONTROLLER
static void natsemi_poll_controller(struct net_device *dev)
{
- struct netdev_private *np = netdev_priv(dev);
-
disable_irq(dev->irq);
-
- /*
- * A real interrupt might have already reached us at this point
- * but NAPI might still haven't called us back. As the interrupt
- * status register is cleared by reading, we should prevent an
- * interrupt loss in this case...
- */
- if (!np->intr_status)
- intr_handler(dev->irq, dev);
-
+ intr_handler(dev->irq, dev);
enable_irq(dev->irq);
}
#endif
--
"You grabbed my hand and we fell into it, like a daydream - or a fever."
^ permalink raw reply [flat|nested] 5+ messages in thread* [patch 3/3] natsemi: Avoid IntrStatus lossage if RX state machine resets.
2007-03-14 19:49 [patch 0/3] natsemi updates broonie
2007-03-14 19:49 ` [patch 1/3] natsemi: Consistently use interrupt enable/disable functions broonie
2007-03-14 19:49 ` [patch 2/3] natsemi: Fix NAPI for interrupt sharing broonie
@ 2007-03-14 19:49 ` broonie
2 siblings, 0 replies; 5+ messages in thread
From: broonie @ 2007-03-14 19:49 UTC (permalink / raw)
To: Jeff Garzik, Tim Hockin; +Cc: netdev, linux-kernel
[-- Attachment #1: natsemi-fix-poll-ordering --]
[-- Type: text/plain, Size: 1385 bytes --]
This patch fixes the poll routine for the natsemi driver so that if the
driver detects an RX state machine lockup then no interrupts will be
lost while the driver recovers from that.
Signed-Off-By: Mark Brown <broonie@sirena.org.uk>
Index: linux-2.6/drivers/net/natsemi.c
===================================================================
--- linux-2.6.orig/drivers/net/natsemi.c 2007-03-13 19:38:31.000000000 +0000
+++ linux-2.6/drivers/net/natsemi.c 2007-03-13 19:39:08.000000000 +0000
@@ -2169,6 +2169,14 @@
dev->name, np->intr_status,
readl(ioaddr + IntrMask));
+ /* netdev_rx() may read IntrStatus again if the RX state
+ * machine falls over so do it first. */
+ if (np->intr_status &
+ (IntrRxDone | IntrRxIntr | RxStatusFIFOOver |
+ IntrRxErr | IntrRxOverrun)) {
+ netdev_rx(dev, &work_done, work_to_do);
+ }
+
if (np->intr_status &
(IntrTxDone | IntrTxIntr | IntrTxIdle | IntrTxErr)) {
spin_lock(&np->lock);
@@ -2180,12 +2188,6 @@
if (np->intr_status & IntrAbnormalSummary)
netdev_error(dev, np->intr_status);
- if (np->intr_status &
- (IntrRxDone | IntrRxIntr | RxStatusFIFOOver |
- IntrRxErr | IntrRxOverrun)) {
- netdev_rx(dev, &work_done, work_to_do);
- }
-
*budget -= work_done;
dev->quota -= work_done;
--
"You grabbed my hand and we fell into it, like a daydream - or a fever."
^ permalink raw reply [flat|nested] 5+ messages in thread