Skip to contentSkip to conversation

sungem: fix suspend regression due to NAPI changes

PATCH In review Johannes Berg 3 participants 3 messages Nov 12, 2007 – Nov 13, 2007

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

PATCH 1/1 sungem: fix suspend regression due to NAPI changes

Commit bea3348e (the NAPI changes) made sungem unconditionally enable NAPI when resuming and unconditionally disable when suspending, this, however, makes napi_disable() hang when suspending when the interface was taken down before suspend because taking the interface down also disables NAPI. This patch makes touching the napi struct in suspend/resume code paths depend on having the interface up, thereby fixing the hang on suspend.

The patch also moves the napi_disable() in gem_close() under the lock so that the NAPI state is always modified atomically together with the "opened" variable.

---
 drivers/net/sungem.c |   11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/net/sungem.c +5 -6
@@ -2333,10 +2333,10 @@ static int gem_close(struct net_device *
 {
 	struct gem *gp = dev->priv;
 
-	napi_disable(&gp->napi);
-
 	mutex_lock(&gp->pm_mutex);
 
+	napi_disable(&gp->napi);
+
 	gp->opened = 0;
 	if (!gp->asleep)
 		gem_do_stop(dev, 0);
@@ -2355,8 +2355,6 @@ static int gem_suspend(struct pci_dev *p
 
 	mutex_lock(&gp->pm_mutex);
 
-	napi_disable(&gp->napi);
-
 	printk(KERN_INFO "%s: suspending, WakeOnLan %s\n",
 	       dev->name,
 	       (gp->wake_on_lan && gp->opened) ? "enabled" : "disabled");
@@ -2370,6 +2368,8 @@ static int gem_suspend(struct pci_dev *p
 
 	/* If the driver is opened, we stop the MAC */
 	if (gp->opened) {
+		napi_disable(&gp->napi);
+
 		/* Stop traffic, mark us closed */
 		netif_device_detach(dev);
 
@@ -2460,6 +2460,7 @@ static int gem_resume(struct pci_dev *pd
 		/* Re-attach net device */
 		netif_device_attach(dev);
 
+		napi_enable(&gp->napi);
 	}
 
 	spin_lock_irqsave(&gp->lock, flags);
@@ -2479,8 +2480,6 @@ static int gem_resume(struct pci_dev *pd
 	spin_unlock(&gp->tx_lock);
 	spin_unlock_irqrestore(&gp->lock, flags);
 
-	napi_enable(&gp->napi);
-
 	mutex_unlock(&gp->pm_mutex);
 
 	return 0;
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Johannes Berg

Commit bea3348e (the NAPI changes) made sungem unconditionally enable NAPI when resuming and unconditionally disable when suspending, this, however, makes napi_disable() hang when suspending when the interface was taken down before suspend because taking the interface down also disables NAPI. This patch makes touching the napi struct in suspend/resume code paths depend on having the interface up, thereby fixing the hang on suspend.

Quoted 5 lines

The patch also moves the napi_disable() in gem_close() under the lock so that the NAPI state is always modified atomically together with the "opened" variable.

Thanks for fixing that !

---

Quoted 55 lines
---
 drivers/net/sungem.c |   11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/net/sungem.c +5 -6
@@ -2333,10 +2333,10 @@ static int gem_close(struct net_device *
 {
 	struct gem *gp = dev->priv;
 
-	napi_disable(&gp->napi);
-
 	mutex_lock(&gp->pm_mutex);
 
+	napi_disable(&gp->napi);
+
 	gp->opened = 0;
 	if (!gp->asleep)
 		gem_do_stop(dev, 0);
@@ -2355,8 +2355,6 @@ static int gem_suspend(struct pci_dev *p
 
 	mutex_lock(&gp->pm_mutex);
 
-	napi_disable(&gp->napi);
-
 	printk(KERN_INFO "%s: suspending, WakeOnLan %s\n",
 	       dev->name,
 	       (gp->wake_on_lan && gp->opened) ? "enabled" : "disabled");
@@ -2370,6 +2368,8 @@ static int gem_suspend(struct pci_dev *p
 
 	/* If the driver is opened, we stop the MAC */
 	if (gp->opened) {
+		napi_disable(&gp->napi);
+
 		/* Stop traffic, mark us closed */
 		netif_device_detach(dev);
 
@@ -2460,6 +2460,7 @@ static int gem_resume(struct pci_dev *pd
 		/* Re-attach net device */
 		netif_device_attach(dev);
 
+		napi_enable(&gp->napi);
 	}
 
 	spin_lock_irqsave(&gp->lock, flags);
@@ -2479,8 +2480,6 @@ static int gem_resume(struct pci_dev *pd
 	spin_unlock(&gp->tx_lock);
 	spin_unlock_irqrestore(&gp->lock, flags);
 
-	napi_enable(&gp->napi);
-
 	mutex_unlock(&gp->pm_mutex);
 
 	return 0;
maintainer
#2 lore raw

From: Benjamin Herrenschmidt <[email protected]>
Date: Tue, 13 Nov 2007 09:32:46 +1100

Quoted 14 lines · Johannes Berg
Quoted 12 lines

Commit bea3348e (the NAPI changes) made sungem unconditionally enable NAPI when resuming and unconditionally disable when suspending, this, however, makes napi_disable() hang when suspending when the interface was taken down before suspend because taking the interface down also disables NAPI. This patch makes touching the napi struct in suspend/resume code paths depend on having the interface up, thereby fixing the hang on suspend.

The patch also moves the napi_disable() in gem_close() under the lock so that the NAPI state is always modified atomically together with the "opened" variable.

Quoted 5 lines
Quoted 1 line

Thanks for fixing that !

Indeed, thanks a lot Johannes.

Patch applied.