Skip to contentSkip to conversation

fix a race at the end of NAPI

PATCH Superseded Figo.zhang 3 participants 4 messages Jun 8, 2010 – Jun 11, 2010

Subsystems (2)
lore
Share & tools
lore

Figo.zhang

author
#0 lore raw

PATCH 1/1 fix a race at the end of NAPI

fix a race at the end of NAPI complete processing. it had better do __napi_complete() first before re-enable interrupt.

---

 drivers/net/8139cp.c  |    2 +-
 drivers/net/8139too.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/8139cp.c +1 -1
old mode 100644
new mode 100755
index 9c14975..284a5f4
@@ -598,8 +598,8 @@ rx_next:
 			goto rx_status_loop;
 
 		spin_lock_irqsave(&cp->lock, flags);
-		cpw16_f(IntrMask, cp_intr_mask);
 		__napi_complete(napi);
+		cpw16_f(IntrMask, cp_intr_mask);
 		spin_unlock_irqrestore(&cp->lock, flags);
 	}
 
drivers/net/8139too.c +1 -1
old mode 100644
new mode 100755
index 4ba7293..a7bca8c
@@ -2088,8 +2088,8 @@ static int rtl8139_poll(struct napi_struct *napi, int budget)
 		 * again when we think we are done.
 		 */
 		spin_lock_irqsave(&tp->lock, flags);
-		RTL_W16_F(IntrMask, rtl8139_intr_mask);
 		__napi_complete(napi);
+		RTL_W16_F(IntrMask, rtl8139_intr_mask);
 		spin_unlock_irqrestore(&tp->lock, flags);
 	}
 	spin_unlock(&tp->rx_lock);
#1 lore raw
Quoted 4 lines · Figo.zhang

fix a race at the end of NAPI complete processing. it had better do __napi_complete() first before re-enable interrupt.

Patch title is misleading

drivers/net/8139cp.c

Quoted 8 lines

---

 drivers/net/8139cp.c  |    2 +-
 drivers/net/8139too.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/8139cp.c +0 -0
old mode 100644
new mode 100755

Why do you change file modes ?

Quoted 31 lines

index 9c14975..284a5f4

drivers/net/8139cp.c +1 -1
@@ -598,8 +598,8 @@ rx_next:
 			goto rx_status_loop;
 
 		spin_lock_irqsave(&cp->lock, flags);
-		cpw16_f(IntrMask, cp_intr_mask);
 		__napi_complete(napi);
+		cpw16_f(IntrMask, cp_intr_mask);
 		spin_unlock_irqrestore(&cp->lock, flags);
 	}
 
drivers/net/8139too.c +1 -1
old mode 100644
new mode 100755
index 4ba7293..a7bca8c
@@ -2088,8 +2088,8 @@ static int rtl8139_poll(struct napi_struct *napi, int budget)
 		 * again when we think we are done.
 		 */
 		spin_lock_irqsave(&tp->lock, flags);
-		RTL_W16_F(IntrMask, rtl8139_intr_mask);
 		__napi_complete(napi);
+		RTL_W16_F(IntrMask, rtl8139_intr_mask);
 		spin_unlock_irqrestore(&tp->lock, flags);
 	}
 	spin_unlock(&tp->rx_lock);
author
#2 lore raw

PATCH v2 1/1 net8139: fix a race at the end of NAPI

In reply to Figo.zhang

fix a race at the end of NAPI complete processing, it had better do __napi_complete() first before re-enable interrupt.

in v2, i motify it using vim.

---
 drivers/net/8139cp.c  |    2 +-
 drivers/net/8139too.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/8139cp.c +1 -1
index 9c14975..284a5f4 100644
@@ -598,8 +598,8 @@ rx_next:
 			goto rx_status_loop;
 
 		spin_lock_irqsave(&cp->lock, flags);
-		cpw16_f(IntrMask, cp_intr_mask);
 		__napi_complete(napi);
+		cpw16_f(IntrMask, cp_intr_mask);
 		spin_unlock_irqrestore(&cp->lock, flags);
 	}
 
drivers/net/8139too.c +1 -1
index 4ba7293..a7bca8c 100644
@@ -2088,8 +2088,8 @@ static int rtl8139_poll(struct napi_struct *napi, int budget)
 		 * again when we think we are done.
 		 */
 		spin_lock_irqsave(&tp->lock, flags);
-		RTL_W16_F(IntrMask, rtl8139_intr_mask);
 		__napi_complete(napi);
+		RTL_W16_F(IntrMask, rtl8139_intr_mask);
 		spin_unlock_irqrestore(&tp->lock, flags);
 	}
 	spin_unlock(&tp->rx_lock);
maintainer Applied
#3 lore raw

Re: [PATCH v2] net8139: fix a race at the end of NAPI

From: "Figo.zhang" <[email protected]>
Date: Tue, 08 Jun 2010 15:13:22 +0800

Quoted 5 lines

fix a race at the end of NAPI complete processing, it had better do __napi_complete() first before re-enable interrupt.

Applied, thank you.