Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1411367 > unrolled thread

[PATCH] stmmac: do not sleep in atomic context for mdio_reset

Started byVincent Palatin <vpalatin@chromium.org>
First post2016-06-01 18:00 +0200
Last post2016-06-02 21:20 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] stmmac: do not sleep in atomic context for mdio_reset Vincent Palatin <vpalatin@chromium.org> - 2016-06-01 18:00 +0200
    Re: [PATCH] stmmac: do not sleep in atomic context for mdio_reset David Miller <davem@davemloft.net> - 2016-06-02 21:20 +0200

#1411367 — [PATCH] stmmac: do not sleep in atomic context for mdio_reset

FromVincent Palatin <vpalatin@chromium.org>
Date2016-06-01 18:00 +0200
Subject[PATCH] stmmac: do not sleep in atomic context for mdio_reset
Message-ID<rFgIN-1Ow-9@gated-at.bofh.it>
stmmac_mdio_reset() has been updated to use msleep rather udelay
(as some PHY requires a one second delay there).
It called from stmmac_resume() within the spin_lock_irqsave block
atomic context triggering 'scheduling while atomic'.

The stmmac_priv lock usage is not fully documented, but it seems
to protect the access to the MAC registers / DMA structures rather
than the MDIO bus or the PHY (which have separate locking),
so we can push the spin_lock after the stmmac_mdio_reset call.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index eac45d0..a473c18 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -3450,8 +3450,6 @@ int stmmac_resume(struct device *dev)
 	if (!netif_running(ndev))
 		return 0;
 
-	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
 	 * is received. Anyway, it's better to manually clear
@@ -3459,7 +3457,9 @@ int stmmac_resume(struct device *dev)
 	 * from another devices (e.g. serial console).
 	 */
 	if (device_may_wakeup(priv->device)) {
+		spin_lock_irqsave(&priv->lock, flags);
 		priv->hw->mac->pmt(priv->hw, 0);
+		spin_unlock_irqrestore(&priv->lock, flags);
 		priv->irq_wake = 0;
 	} else {
 		pinctrl_pm_select_default_state(priv->device);
@@ -3473,6 +3473,8 @@ int stmmac_resume(struct device *dev)
 
 	netif_device_attach(ndev);
 
+	spin_lock_irqsave(&priv->lock, flags);
+
 	priv->cur_rx = 0;
 	priv->dirty_rx = 0;
 	priv->dirty_tx = 0;
-- 
2.8.0.rc3.226.g39d4020

[toc] | [next] | [standalone]


#1412515

FromDavid Miller <davem@davemloft.net>
Date2016-06-02 21:20 +0200
Message-ID<rFGjT-1DM-11@gated-at.bofh.it>
In reply to#1411367
From: Vincent Palatin <vpalatin@chromium.org>
Date: Wed,  1 Jun 2016 08:53:48 -0700

> stmmac_mdio_reset() has been updated to use msleep rather udelay
> (as some PHY requires a one second delay there).
> It called from stmmac_resume() within the spin_lock_irqsave block
> atomic context triggering 'scheduling while atomic'.
> 
> The stmmac_priv lock usage is not fully documented, but it seems
> to protect the access to the MAC registers / DMA structures rather
> than the MDIO bus or the PHY (which have separate locking),
> so we can push the spin_lock after the stmmac_mdio_reset call.
> 
> Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

Applied, thanks.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web