Skip to content

Commit 0a900ea

Browse files
Russell King (Oracle)kuba-moo
authored andcommitted
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. Reviewed-by: Andrew Lunn <[email protected]> Tested-by: Choong Yong Liang <[email protected]> Signed-off-by: Russell King (Oracle) <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 2914a5c commit 0a900ea

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -462,11 +462,13 @@ static void stmmac_eee_ctrl_timer(struct timer_list *t)
462462
* can also manage EEE, this function enable the LPI state and start related
463463
* timer.
464464
*/
465-
static bool stmmac_eee_init(struct stmmac_priv *priv)
465+
static void stmmac_eee_init(struct stmmac_priv *priv)
466466
{
467467
/* Check if MAC core supports the EEE feature. */
468-
if (!priv->dma_cap.eee)
469-
return false;
468+
if (!priv->dma_cap.eee) {
469+
priv->eee_enabled = false;
470+
return;
471+
}
470472

471473
mutex_lock(&priv->lock);
472474

@@ -483,8 +485,9 @@ static bool stmmac_eee_init(struct stmmac_priv *priv)
483485
priv->plat->mult_fact_100ns,
484486
false);
485487
}
488+
priv->eee_enabled = false;
486489
mutex_unlock(&priv->lock);
487-
return false;
490+
return;
488491
}
489492

490493
if (priv->eee_active && !priv->eee_enabled) {
@@ -507,9 +510,10 @@ static bool stmmac_eee_init(struct stmmac_priv *priv)
507510
STMMAC_LPI_T(priv->tx_lpi_timer));
508511
}
509512

513+
priv->eee_enabled = true;
514+
510515
mutex_unlock(&priv->lock);
511516
netdev_dbg(priv->dev, "Energy-Efficient Ethernet initialized\n");
512-
return true;
513517
}
514518

515519
/* stmmac_get_tx_hwtstamp - get HW TX timestamps
@@ -967,7 +971,7 @@ static void stmmac_mac_link_down(struct phylink_config *config,
967971

968972
stmmac_mac_set(priv, priv->ioaddr, false);
969973
priv->eee_active = false;
970-
priv->eee_enabled = stmmac_eee_init(priv);
974+
stmmac_eee_init(priv);
971975
stmmac_set_eee_pls(priv, priv->hw, false);
972976

973977
if (stmmac_fpe_supported(priv))
@@ -1080,7 +1084,7 @@ static void stmmac_mac_link_up(struct phylink_config *config,
10801084
STMMAC_FLAG_RX_CLK_RUNS_IN_LPI));
10811085
priv->tx_lpi_timer = phy->eee_cfg.tx_lpi_timer;
10821086
priv->eee_active = phy->enable_tx_lpi;
1083-
priv->eee_enabled = stmmac_eee_init(priv);
1087+
stmmac_eee_init(priv);
10841088
stmmac_set_eee_pls(priv, priv->hw, true);
10851089
}
10861090

0 commit comments

Comments
 (0)