Skip to contentSkip to conversation

gianfar: fix sleep in atomic...

PATCH In review Daniel J Blueman 3 participants 4 messages Nov 2, 2010 – Nov 12, 2010

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

PATCH 1/1 gianfar: fix sleep in atomic...

Since device_set_wakeup_enable now sleeps, it should not be called from a critical section. Since wol_en is not updated elsewhere, we can omit the locking entirely.

drivers/net/gianfar_ethtool.c +0 -0
index 5c566eb..e641d7c 100644
@@ -635,10 +635,8 @@ static int gfar_set_wol(struct net_device *dev,

struct ethtool_wolinfo *wol)
if (wol->wolopts & ~WAKE_MAGIC)
return -EINVAL;

- spin_lock_irqsave(&priv->bflock, flags);
priv->wol_en = wol->wolopts & WAKE_MAGIC ? 1 : 0; device_set_wakeup_enable(&dev->dev, priv->wol_en);
- spin_unlock_irqrestore(&priv->bflock, flags);

return 0;
}

Signature · 1 line
Daniel J Blueman
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Daniel J Blueman

Since device_set_wakeup_enable now sleeps, it should not be called from a critical section. Since wol_en is not updated elsewhere, we can omit the locking entirely.

Quoted 17 lines
drivers/net/gianfar_ethtool.c +0 -2
index 5c566eb..e641d7c 100644
@@ -635,10 +635,8 @@ static int gfar_set_wol(struct net_device *dev,
 struct ethtool_wolinfo *wol)
 	if (wol->wolopts & ~WAKE_MAGIC)
 		return -EINVAL;
 
-	spin_lock_irqsave(&priv->bflock, flags);
 	priv->wol_en = wol->wolopts & WAKE_MAGIC ? 1 : 0;
 	device_set_wakeup_enable(&dev->dev, priv->wol_en);
-	spin_unlock_irqrestore(&priv->bflock, flags);
 
 	return 0;

}

#2 lore raw

PATCH 1/1 gianfar: Do not call device_set_wakeup_enable() under a spinlock

Quoted 8 lines · Rafael J. Wysocki
Quoted 5 lines · Daniel J Blueman

Since device_set_wakeup_enable now sleeps, it should not be called from a critical section. Since wol_en is not updated elsewhere, we can omit the locking entirely.

Having reconsidered that I think it may be better to do something like in the patch below.

This is a regression fix, so please apply if there are no objections.

Thanks,
Rafael

---
From: Rafael J. Wysocki <[email protected]>
Subject: gianfar: Do not call device_set_wakeup_enable() under a spinlock

The gianfar driver calls device_set_wakeup_enable() under a spinlock, which causes a problem to happen after the recent core power management changes, because this function can sleep now. Fix this by moving the device_set_wakeup_enable() call out of the spinlock-protected area.

---
 drivers/net/gianfar_ethtool.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/gianfar_ethtool.c +3 -2
Index: linux-2.6/drivers/net/gianfar_ethtool.c
===================================================================
@@ -635,9 +635,10 @@ static int gfar_set_wol(struct net_devic
 	if (wol->wolopts & ~WAKE_MAGIC)
 		return -EINVAL;
 
+	device_set_wakeup_enable(&dev->dev, wol->wolopts & WAKE_MAGIC);
+
 	spin_lock_irqsave(&priv->bflock, flags);
-	priv->wol_en = wol->wolopts & WAKE_MAGIC ? 1 : 0;
-	device_set_wakeup_enable(&dev->dev, priv->wol_en);
+	priv->wol_en =  !!device_may_wakeup(&dev->dev);
 	spin_unlock_irqrestore(&priv->bflock, flags);
 
 	return 0;
maintainer
#3 lore raw

Re: [PATCH] gianfar: Do not call device_set_wakeup_enable() under a spinlock

From: "Rafael J. Wysocki" <[email protected]>
Date: Tue, 9 Nov 2010 22:54:19 +0100

Quoted 7 lines

The gianfar driver calls device_set_wakeup_enable() under a spinlock, which causes a problem to happen after the recent core power management changes, because this function can sleep now. Fix this by moving the device_set_wakeup_enable() call out of the spinlock-protected area.

Patch applied, thank you.