[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <E1tUmAt-007VXh-TZ@rmk-PC.armlinux.org.uk>
Date: Mon, 06 Jan 2025 12:25:39 +0000
From: "Russell King (Oracle)" <rmk+kernel@...linux.org.uk>
To: Andrew Lunn <andrew@...n.ch>,
Heiner Kallweit <hkallweit1@...il.com>
Cc: Alexandre Torgue <alexandre.torgue@...s.st.com>,
Andrew Lunn <andrew+netdev@...n.ch>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Jose Abreu <joabreu@...opsys.com>,
linux-arm-kernel@...ts.infradead.org,
linux-stm32@...md-mailman.stormreply.com,
Maxime Coquelin <mcoquelin.stm32@...il.com>,
netdev@...r.kernel.org,
Paolo Abeni <pabeni@...hat.com>
Subject: [PATCH net-next v2 11/17] net: stmmac: move priv->eee_enabled into
stmmac_eee_init()
All call sites for stmmac_eee_init() assign the return code to
priv->eee_enabled. Rather than having this coded at each call site,
move the assignment inside stmmac_eee_init().
Since stmmac_init_eee() takes priv->lock before checking the state of
priv->eee_enabled, move the assignment within the locked region. Also,
stmmac_suspend() checks the state of this member under the lock. While
two concurrent calls to stmmac_init_eee() aren't possible, there is
a possibility that stmmac_suspend() may run concurrently with a change
of priv->eee_enabled unless we modify it under the lock.
Signed-off-by: Russell King (Oracle) <rmk+kernel@...linux.org.uk>
---
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 7cce2eb3d82e..cf294fe3f726 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -464,11 +464,13 @@ static void stmmac_eee_ctrl_timer(struct timer_list *t)
* can also manage EEE, this function enable the LPI state and start related
* timer.
*/
-static bool stmmac_eee_init(struct stmmac_priv *priv)
+static void stmmac_eee_init(struct stmmac_priv *priv)
{
/* Check if MAC core supports the EEE feature. */
- if (!priv->dma_cap.eee)
- return false;
+ if (!priv->dma_cap.eee) {
+ priv->eee_enabled = false;
+ return;
+ }
mutex_lock(&priv->lock);
@@ -485,8 +487,9 @@ static bool stmmac_eee_init(struct stmmac_priv *priv)
priv->plat->mult_fact_100ns,
false);
}
+ priv->eee_enabled = false;
mutex_unlock(&priv->lock);
- return false;
+ return;
}
if (priv->eee_active && !priv->eee_enabled) {
@@ -509,9 +512,10 @@ static bool stmmac_eee_init(struct stmmac_priv *priv)
STMMAC_LPI_T(priv->tx_lpi_timer));
}
+ priv->eee_enabled = true;
+
mutex_unlock(&priv->lock);
netdev_dbg(priv->dev, "Energy-Efficient Ethernet initialized\n");
- return true;
}
/* stmmac_get_tx_hwtstamp - get HW TX timestamps
@@ -969,7 +973,7 @@ static void stmmac_mac_link_down(struct phylink_config *config,
stmmac_mac_set(priv, priv->ioaddr, false);
priv->eee_active = false;
- priv->eee_enabled = stmmac_eee_init(priv);
+ stmmac_eee_init(priv);
stmmac_set_eee_pls(priv, priv->hw, false);
if (stmmac_fpe_supported(priv))
@@ -1082,7 +1086,7 @@ static void stmmac_mac_link_up(struct phylink_config *config,
STMMAC_FLAG_RX_CLK_RUNS_IN_LPI));
priv->tx_lpi_timer = phy->eee_cfg.tx_lpi_timer;
priv->eee_active = phy->enable_tx_lpi;
- priv->eee_enabled = stmmac_eee_init(priv);
+ stmmac_eee_init(priv);
stmmac_set_eee_pls(priv, priv->hw, true);
}
--
2.30.2
Powered by blists - more mailing lists