Skip to content

Commit 305a0f6

Browse files
Russell King (Oracle)kuba-moo
authored andcommitted
net: stmmac: use stmmac_set_lpi_mode()
Use the new stmmac_set_lpi_mode() API to configure the parameters of the desired LPI mode rather than the older methods. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Link: https://patch.msgid.link/E1tffe2-003ZIg-Mx@rmk-PC.armlinux.org.uk Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent a323ed9 commit 305a0f6

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

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

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -390,11 +390,6 @@ static inline u32 stmmac_rx_dirty(struct stmmac_priv *priv, u32 queue)
390390
return dirty;
391391
}
392392

393-
static void stmmac_enable_hw_lpi_timer(struct stmmac_priv *priv)
394-
{
395-
stmmac_set_eee_lpi_timer(priv, priv->hw, priv->tx_lpi_timer);
396-
}
397-
398393
static bool stmmac_eee_tx_busy(struct stmmac_priv *priv)
399394
{
400395
u32 tx_cnt = priv->plat->tx_queues_to_use;
@@ -431,8 +426,9 @@ static void stmmac_try_to_start_sw_lpi(struct stmmac_priv *priv)
431426

432427
/* Check and enter in LPI mode */
433428
if (!priv->tx_path_in_lpi_mode)
434-
stmmac_set_eee_mode(priv, priv->hw,
435-
priv->plat->flags & STMMAC_FLAG_EN_TX_LPI_CLOCKGATING);
429+
stmmac_set_lpi_mode(priv, priv->hw, STMMAC_LPI_FORCED,
430+
priv->plat->flags & STMMAC_FLAG_EN_TX_LPI_CLOCKGATING,
431+
0);
436432
}
437433

438434
/**
@@ -443,7 +439,7 @@ static void stmmac_try_to_start_sw_lpi(struct stmmac_priv *priv)
443439
static void stmmac_stop_sw_lpi(struct stmmac_priv *priv)
444440
{
445441
del_timer_sync(&priv->eee_ctrl_timer);
446-
stmmac_reset_eee_mode(priv, priv->hw);
442+
stmmac_set_lpi_mode(priv, priv->hw, STMMAC_LPI_DISABLE, false, 0);
447443
priv->tx_path_in_lpi_mode = false;
448444
}
449445

@@ -1046,7 +1042,7 @@ static void stmmac_mac_disable_tx_lpi(struct phylink_config *config)
10461042
netdev_dbg(priv->dev, "disable EEE\n");
10471043
priv->eee_sw_timer_en = false;
10481044
del_timer_sync(&priv->eee_ctrl_timer);
1049-
stmmac_reset_eee_mode(priv, priv->hw);
1045+
stmmac_set_lpi_mode(priv, priv->hw, STMMAC_LPI_DISABLE, false, 0);
10501046
priv->tx_path_in_lpi_mode = false;
10511047

10521048
stmmac_set_eee_timer(priv, priv->hw, 0, STMMAC_DEFAULT_TWT_LS);
@@ -1061,6 +1057,7 @@ static int stmmac_mac_enable_tx_lpi(struct phylink_config *config, u32 timer,
10611057
bool tx_clk_stop)
10621058
{
10631059
struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev));
1060+
int ret;
10641061

10651062
priv->tx_lpi_timer = timer;
10661063
priv->eee_active = true;
@@ -1075,11 +1072,15 @@ static int stmmac_mac_enable_tx_lpi(struct phylink_config *config, u32 timer,
10751072
xpcs_config_eee(priv->hw->xpcs, priv->plat->mult_fact_100ns,
10761073
true);
10771074

1078-
if (priv->plat->has_gmac4 && priv->tx_lpi_timer <= STMMAC_ET_MAX) {
1079-
/* Use hardware LPI mode */
1080-
stmmac_enable_hw_lpi_timer(priv);
1081-
} else {
1082-
/* Use software LPI mode */
1075+
/* Try to cnfigure the hardware timer. */
1076+
ret = stmmac_set_lpi_mode(priv, priv->hw, STMMAC_LPI_TIMER,
1077+
priv->plat->flags & STMMAC_FLAG_EN_TX_LPI_CLOCKGATING,
1078+
priv->tx_lpi_timer);
1079+
1080+
if (ret) {
1081+
/* Hardware timer mode not supported, or value out of range.
1082+
* Fall back to using software LPI mode
1083+
*/
10831084
priv->eee_sw_timer_en = true;
10841085
stmmac_restart_sw_lpi_timer(priv);
10851086
}

0 commit comments

Comments
 (0)