@@ -246,7 +246,7 @@ struct stmmac_priv {
};
enum stmmac_state {
- STMMAC_DOWN,
+ STMMAC_UP,
STMMAC_RESET_REQUESTED,
};
@@ -4151,6 +4151,8 @@ static void stmmac_enable_irq(struct stmmac_priv *priv)
stmmac_enable_mac_irq(priv, priv->hw);
+ set_bit(STMMAC_UP, &priv->state);
+
enable_irq(priv->dev->irq);
}
@@ -4165,6 +4167,8 @@ static void stmmac_disable_irq(struct stmmac_priv *priv)
disable_irq(priv->dev->irq);
+ clear_bit(STMMAC_UP, &priv->state);
+
stmmac_disable_mac_irq(priv, priv->hw);
maxq = max(priv->plat->rx_queues_to_use, priv->plat->tx_queues_to_use);
@@ -4213,7 +4217,7 @@ static irqreturn_t stmmac_interrupt(int irq, void *dev_id)
pm_wakeup_event(priv->device, 0);
/* Check if adapter is up */
- if (test_bit(STMMAC_DOWN, &priv->state))
+ if (!test_bit(STMMAC_UP, &priv->state))
return IRQ_HANDLED;
/* Check if a fatal error happened */
if (stmmac_safety_feat_interrupt(priv))
@@ -4739,7 +4743,7 @@ static const struct net_device_ops stmmac_netdev_ops = {
static void stmmac_reset_subtask(struct stmmac_priv *priv)
{
- if (test_bit(STMMAC_DOWN, &priv->state))
+ if (!test_bit(STMMAC_UP, &priv->state))
return;
netdev_err(priv->dev, "Reset adapter.\n");
@@ -4747,10 +4751,8 @@ static void stmmac_reset_subtask(struct stmmac_priv *priv)
rtnl_lock();
netif_trans_update(priv->dev);
- set_bit(STMMAC_DOWN, &priv->state);
dev_close(priv->dev);
dev_open(priv->dev, NULL);
- clear_bit(STMMAC_DOWN, &priv->state);
rtnl_unlock();
}
The flag name and semantics are misleading. Judging by the code the flag will be set only if the networking is requested for being reset, while logically in order to correctly reflect the device state the flag needs to be also set when the network device isn't opened. Let's convert the flag to having a positive meaning instead of keeping it being set all the time the interface is down. This modification will be also helpful for the case of the IRQs request being performed in the device probe method. So the driver could enable/disable the network-related IRQs handlers by synchronous flag switching together with the IRQs unmasking and masking. Luckily the IRQs are normally enabled/disable in the late/early network initialization stages respectively. Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru> --- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-)