Skip to content

Commit

Permalink
stmmac: fix suspend/resume locking
Browse files Browse the repository at this point in the history
Upon resume from standby, there is a possible interrupt
unsafe locking scenario raised when configure the Kernel
with CONFIG_PROVE_LOCKING. So this patch fixes that in
PM driver stuff by calling lock/unlock_irqsave/restore.

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Giuseppe CAVALLARO authored and David S. Miller committed May 14, 2012
1 parent b9cde0a commit f8c5a87
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1989,14 +1989,15 @@ int stmmac_suspend(struct net_device *ndev)
{
struct stmmac_priv *priv = netdev_priv(ndev);
int dis_ic = 0;
unsigned long flags;

if (!ndev || !netif_running(ndev))
return 0;

if (priv->phydev)
phy_stop(priv->phydev);

spin_lock(&priv->lock);
spin_lock_irqsave(&priv->lock, flags);

netif_device_detach(ndev);
netif_stop_queue(ndev);
Expand Down Expand Up @@ -2024,18 +2025,19 @@ int stmmac_suspend(struct net_device *ndev)
/* Disable clock in case of PWM is off */
stmmac_clk_disable(priv);
}
spin_unlock(&priv->lock);
spin_unlock_irqrestore(&priv->lock, flags);
return 0;
}

int stmmac_resume(struct net_device *ndev)
{
struct stmmac_priv *priv = netdev_priv(ndev);
unsigned long flags;

if (!netif_running(ndev))
return 0;

spin_lock(&priv->lock);
spin_lock_irqsave(&priv->lock, flags);

/* Power Down bit, into the PM register, is cleared
* automatically as soon as a magic packet or a Wake-up frame
Expand Down Expand Up @@ -2063,7 +2065,7 @@ int stmmac_resume(struct net_device *ndev)

netif_start_queue(ndev);

spin_unlock(&priv->lock);
spin_unlock_irqrestore(&priv->lock, flags);

if (priv->phydev)
phy_start(priv->phydev);
Expand Down

0 comments on commit f8c5a87

Please sign in to comment.