Skip to contentSkip to conversation

skge napi->poll() locking bug

PATCH In review [email protected] 4 participants 5 messages Mar 27, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 3/3 skge napi->poll() locking bug

From: Marin Mitov <[email protected]>

According to: Documentation/networking/netdevices.txt:

<cite>
napi->poll:
..........
Context: softirq
will be called with interrupts disabled by netconsole.
</cite>

napi->poll() could be called either with interrupts enabled (in softirq context) or disabled (by netconsole), so the irq flag should be preserved.

Inspired by Ingo's resent forcedeth patch :-)

---

 drivers/net/skge.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/skge.c renamed from drivers/net/skge.c~skge-napi-poll-locking-bug +4 -2
diff -puN drivers/net/skge.c~skge-napi-poll-locking-bug drivers/net/skge.c
@@ -3199,12 +3199,14 @@ static int skge_poll(struct napi_struct 
 	skge_write8(hw, Q_ADDR(rxqaddr[skge->port], Q_CSR), CSR_START);
 
 	if (work_done < to_do) {
-		spin_lock_irq(&hw->hw_lock);
+		unsigned long flags;
+
+		spin_lock_irqsave(&hw->hw_lock, flags);
 		__netif_rx_complete(dev, napi);
 		hw->intr_mask |= napimask[skge->port];
 		skge_write32(hw, B0_IMSK, hw->intr_mask);
 		skge_read32(hw, B0_IMSK);
-		spin_unlock_irq(&hw->hw_lock);
+		spin_unlock_irqrestore(&hw->hw_lock, flags);
 	}
 
 	return work_done;

_

#1 lore raw
Quoted 11 lines · you

From: Marin Mitov <[email protected]>

According to: Documentation/networking/netdevices.txt:

<cite>
napi->poll:
..........
Context: softirq
will be called with interrupts disabled by netconsole.
</cite>

Quoted 6 lines

napi->poll() could be called either with interrupts enabled (in softirq context) or disabled (by netconsole), so the irq flag should be preserved.

Inspired by Ingo's resent forcedeth patch :-)

As far as skge driver has not changed since 2.6.24, the patch could be applied to the stable 2.6.24.5 release too.

Marin Mitov

Quoted 31 lines

---

 drivers/net/skge.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff -puN drivers/net/skge.c~skge-napi-poll-locking-bug drivers/net/skge.c

drivers/net/skge.c renamed from drivers/net/skge.c~skge-napi-poll-locking-bug +4 -2
@@ -3199,12 +3199,14 @@ static int skge_poll(struct napi_struct 
 	skge_write8(hw, Q_ADDR(rxqaddr[skge->port], Q_CSR), CSR_START);
 
 	if (work_done < to_do) {
-		spin_lock_irq(&hw->hw_lock);
+		unsigned long flags;
+
+		spin_lock_irqsave(&hw->hw_lock, flags);
 		__netif_rx_complete(dev, napi);
 		hw->intr_mask |= napimask[skge->port];
 		skge_write32(hw, B0_IMSK, hw->intr_mask);
 		skge_read32(hw, B0_IMSK);
-		spin_unlock_irq(&hw->hw_lock);
+		spin_unlock_irqrestore(&hw->hw_lock, flags);
 	}
 
 	return work_done;

_

#2 lore raw
In reply to [email protected]
Quoted 33 lines · [email protected] wrote:

From: Marin Mitov <[email protected]>

According to: Documentation/networking/netdevices.txt:

<cite>
napi->poll:
..........
Context: softirq
will be called with interrupts disabled by netconsole.
</cite>

napi->poll() could be called either with interrupts enabled (in softirq context) or disabled (by netconsole), so the irq flag should be preserved.

Inspired by Ingo's resent forcedeth patch :-)

---

 drivers/net/skge.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff -puN drivers/net/skge.c~skge-napi-poll-locking-bug drivers/net/skge.c

drivers/net/skge.c renamed from drivers/net/skge.c~skge-napi-poll-locking-bug +0 -0
@@ -3199,12 +3199,14 @@ static int skge_poll(struct napi_struct 
 	skge_write8(hw, Q_ADDR(rxqaddr[skge->port], Q_CSR), CSR_START);
 
 	if (work_done < to_do) {

drivers/net/skge.c static int skge_poll(struct napi_struct · line 3209

Quoted 10 lines
drivers/net/skge.c renamed from drivers/net/skge.c~skge-napi-poll-locking-bug +4 -2
-		spin_lock_irq(&hw->hw_lock);
+		unsigned long flags;
+
+		spin_lock_irqsave(&hw->hw_lock, flags);
 		__netif_rx_complete(dev, napi);
 		hw->intr_mask |= napimask[skge->port];
 		skge_write32(hw, B0_IMSK, hw->intr_mask);
 		skge_read32(hw, B0_IMSK);
-		spin_unlock_irq(&hw->hw_lock);
+		spin_unlock_irqrestore(&hw->hw_lock, flags);

davem already has this

#3 lore raw
Quoted 1 line · On Thu, 27 Mar 2008 08:23:13 -0400 Jeff Garzik <[email protected]> wrote:

davem already has this

In which I discover that net-2.6.26 doesn't include net-2.6?

hrm.

maintainer
#4 lore raw

From: Andrew Morton <[email protected]>
Date: Thu, 27 Mar 2008 10:11:42 -0700

Quoted 5 lines · On Thu, 27 Mar 2008 08:23:13 -0400 Jeff Garzik <[email protected]> wrote:
Quoted 2 lines

davem already has this

In which I discover that net-2.6.26 doesn't include net-2.6?

They get merged into eachother, as needed.