Skip to content

Commit 7a1723d

Browse files
committed
Merge branch 'net-stmmac-further-eee-cleanups-and-one-fix'
Russell King says: ==================== net: stmmac: further EEE cleanups (and one fix!) This series continues the EEE cleanup of the stmmac driver, and includes one fix. As mentioned in the previous series, I wasn't entirely happy with the "stmmac_disable_sw_eee_mode" name, so the first patch renames this to "stmmac_stop_sw_lpi" instead, which I think better describes what this function is doing - stopping the transmit of the LPI state because we have a packet ot send. Patch 2 corrects the priv->eee_sw_timer_en flag when EEE has been disabled. Currently upon disable, priv->eee_enabled is set false, but through the weird logic that was present prior to the previous series, priv->eee_sw_timer_en was set true. This behaviour was kept as the previous series was cleanup, not fixes. This patch fixes this. Having fixed priv->eee_sw_timer_en to actually indicate whether software timed EEE mode is being used, it becomes no longer necessary to test priv->eee_enabled in addition. Patch 3 removes the redundant test. Patch 4 also uses priv->eee_sw_timer_en before manipulating the software EEE state in the suspend method rather than using priv->eee_enabled, which brings consistency. Patch 5 provides stmmac_try_to_start_sw_lpi() which complements stmmac_stop_sw_lpi(), and allows us to move duplicated code into one location. Patch 6 splits stmmac_enable_eee_mode() - one part of this function tests whether there are any queues that have unfinished work (in other words are busy). Separate out this code into a separate function. Patch 7 also splits out the mod_timer() for the software EEE timer intoi a seperate function (the reason will be in patch 9.) Patch 8 merges the remains of stmmac_enable_eee_mode() into stmmac_try_to_start_sw_lpi(). Patch 9 fixes the delay between transmit and entering LPI. Currently, when cleaning the transmit queues, if we discover that we have finished cleaning up all queues, we immediately instruct the hardware to enter LPI mode without waiting for the LPI timer. However, we should wait for the LPI timer to expire. Therefore, the transmit cleanup path needs to call stmmac_restart_sw_lpi_timer() instead of stmmac_try_to_start_sw_lpi(). ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 5b4c2fd + d28e892 commit 7a1723d

File tree

1 file changed

+33
-25
lines changed

1 file changed

+33
-25
lines changed

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

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -400,13 +400,7 @@ static void stmmac_enable_hw_lpi_timer(struct stmmac_priv *priv)
400400
stmmac_set_eee_lpi_timer(priv, priv->hw, priv->tx_lpi_timer);
401401
}
402402

403-
/**
404-
* stmmac_enable_eee_mode - check and enter in LPI mode
405-
* @priv: driver private structure
406-
* Description: this function is to verify and enter in LPI mode in case of
407-
* EEE.
408-
*/
409-
static int stmmac_enable_eee_mode(struct stmmac_priv *priv)
403+
static bool stmmac_eee_tx_busy(struct stmmac_priv *priv)
410404
{
411405
u32 tx_cnt = priv->plat->tx_queues_to_use;
412406
u32 queue;
@@ -416,23 +410,42 @@ static int stmmac_enable_eee_mode(struct stmmac_priv *priv)
416410
struct stmmac_tx_queue *tx_q = &priv->dma_conf.tx_queue[queue];
417411

418412
if (tx_q->dirty_tx != tx_q->cur_tx)
419-
return -EBUSY; /* still unfinished work */
413+
return true; /* still unfinished work */
414+
}
415+
416+
return false;
417+
}
418+
419+
static void stmmac_restart_sw_lpi_timer(struct stmmac_priv *priv)
420+
{
421+
mod_timer(&priv->eee_ctrl_timer, STMMAC_LPI_T(priv->tx_lpi_timer));
422+
}
423+
424+
/**
425+
* stmmac_try_to_start_sw_lpi - check and enter in LPI mode
426+
* @priv: driver private structure
427+
* Description: this function is to verify and enter in LPI mode in case of
428+
* EEE.
429+
*/
430+
static void stmmac_try_to_start_sw_lpi(struct stmmac_priv *priv)
431+
{
432+
if (stmmac_eee_tx_busy(priv)) {
433+
stmmac_restart_sw_lpi_timer(priv);
434+
return;
420435
}
421436

422437
/* Check and enter in LPI mode */
423438
if (!priv->tx_path_in_lpi_mode)
424439
stmmac_set_eee_mode(priv, priv->hw,
425440
priv->plat->flags & STMMAC_FLAG_EN_TX_LPI_CLOCKGATING);
426-
return 0;
427441
}
428442

429443
/**
430-
* stmmac_disable_sw_eee_mode - disable and exit from LPI mode
444+
* stmmac_stop_sw_lpi - stop transmitting LPI
431445
* @priv: driver private structure
432-
* Description: this function is to exit and disable EEE in case of
433-
* LPI state is true. This is called by the xmit.
446+
* Description: When using software-controlled LPI, stop transmitting LPI state.
434447
*/
435-
static void stmmac_disable_sw_eee_mode(struct stmmac_priv *priv)
448+
static void stmmac_stop_sw_lpi(struct stmmac_priv *priv)
436449
{
437450
stmmac_reset_eee_mode(priv, priv->hw);
438451
del_timer_sync(&priv->eee_ctrl_timer);
@@ -450,8 +463,7 @@ static void stmmac_eee_ctrl_timer(struct timer_list *t)
450463
{
451464
struct stmmac_priv *priv = from_timer(priv, t, eee_ctrl_timer);
452465

453-
if (stmmac_enable_eee_mode(priv))
454-
mod_timer(&priv->eee_ctrl_timer, STMMAC_LPI_T(priv->tx_lpi_timer));
466+
stmmac_try_to_start_sw_lpi(priv);
455467
}
456468

457469
/**
@@ -479,7 +491,7 @@ static void stmmac_eee_init(struct stmmac_priv *priv, bool active)
479491
if (!priv->eee_active) {
480492
if (priv->eee_enabled) {
481493
netdev_dbg(priv->dev, "disable EEE\n");
482-
priv->eee_sw_timer_en = true;
494+
priv->eee_sw_timer_en = false;
483495
stmmac_disable_hw_lpi_timer(priv);
484496
del_timer_sync(&priv->eee_ctrl_timer);
485497
stmmac_set_eee_timer(priv, priv->hw, 0,
@@ -513,8 +525,7 @@ static void stmmac_eee_init(struct stmmac_priv *priv, bool active)
513525
/* Use software LPI mode */
514526
priv->eee_sw_timer_en = true;
515527
stmmac_disable_hw_lpi_timer(priv);
516-
mod_timer(&priv->eee_ctrl_timer,
517-
STMMAC_LPI_T(priv->tx_lpi_timer));
528+
stmmac_restart_sw_lpi_timer(priv);
518529
}
519530

520531
priv->eee_enabled = true;
@@ -2783,11 +2794,8 @@ static int stmmac_tx_clean(struct stmmac_priv *priv, int budget, u32 queue,
27832794
xmits = budget;
27842795
}
27852796

2786-
if (priv->eee_enabled && !priv->tx_path_in_lpi_mode &&
2787-
priv->eee_sw_timer_en) {
2788-
if (stmmac_enable_eee_mode(priv))
2789-
mod_timer(&priv->eee_ctrl_timer, STMMAC_LPI_T(priv->tx_lpi_timer));
2790-
}
2797+
if (priv->eee_sw_timer_en && !priv->tx_path_in_lpi_mode)
2798+
stmmac_restart_sw_lpi_timer(priv);
27912799

27922800
/* We still have pending packets, let's call for a new scheduling */
27932801
if (tx_q->dirty_tx != tx_q->cur_tx)
@@ -4497,7 +4505,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
44974505
first_tx = tx_q->cur_tx;
44984506

44994507
if (priv->tx_path_in_lpi_mode && priv->eee_sw_timer_en)
4500-
stmmac_disable_sw_eee_mode(priv);
4508+
stmmac_stop_sw_lpi(priv);
45014509

45024510
/* Manage oversized TCP frames for GMAC4 device */
45034511
if (skb_is_gso(skb) && priv->tso) {
@@ -7721,7 +7729,7 @@ int stmmac_suspend(struct device *dev)
77217729
for (chan = 0; chan < priv->plat->tx_queues_to_use; chan++)
77227730
hrtimer_cancel(&priv->dma_conf.tx_queue[chan].txtimer);
77237731

7724-
if (priv->eee_enabled) {
7732+
if (priv->eee_sw_timer_en) {
77257733
priv->tx_path_in_lpi_mode = false;
77267734
del_timer_sync(&priv->eee_ctrl_timer);
77277735
}

0 commit comments

Comments
 (0)