771-v6.7-02-net-stmmac-move-TX-timer-arm-after-DMA-enable.patch 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. From a594166387fe08e6f5a32130c400249a35b298f9 Mon Sep 17 00:00:00 2001
  2. From: Christian Marangi <[email protected]>
  3. Date: Wed, 18 Oct 2023 14:35:49 +0200
  4. Subject: [PATCH 2/3] net: stmmac: move TX timer arm after DMA enable
  5. Move TX timer arm call after DMA interrupt is enabled again.
  6. The TX timer arm function changed logic and now is skipped if a napi is
  7. already scheduled. By moving the TX timer arm call after DMA is enabled,
  8. we permit to correctly skip if a DMA interrupt has been fired and a napi
  9. has been scheduled again.
  10. Signed-off-by: Christian Marangi <[email protected]>
  11. Signed-off-by: Paolo Abeni <[email protected]>
  12. ---
  13. .../net/ethernet/stmicro/stmmac/stmmac_main.c | 22 +++++++++++++++----
  14. 1 file changed, 18 insertions(+), 4 deletions(-)
  15. --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
  16. +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
  17. @@ -2528,9 +2528,13 @@ static void stmmac_bump_dma_threshold(st
  18. * @priv: driver private structure
  19. * @budget: napi budget limiting this functions packet handling
  20. * @queue: TX queue index
  21. + * @pending_packets: signal to arm the TX coal timer
  22. * Description: it reclaims the transmit resources after transmission completes.
  23. + * If some packets still needs to be handled, due to TX coalesce, set
  24. + * pending_packets to true to make NAPI arm the TX coal timer.
  25. */
  26. -static int stmmac_tx_clean(struct stmmac_priv *priv, int budget, u32 queue)
  27. +static int stmmac_tx_clean(struct stmmac_priv *priv, int budget, u32 queue,
  28. + bool *pending_packets)
  29. {
  30. struct stmmac_tx_queue *tx_q = &priv->dma_conf.tx_queue[queue];
  31. unsigned int bytes_compl = 0, pkts_compl = 0;
  32. @@ -2693,7 +2697,7 @@ static int stmmac_tx_clean(struct stmmac
  33. /* We still have pending packets, let's call for a new scheduling */
  34. if (tx_q->dirty_tx != tx_q->cur_tx)
  35. - stmmac_tx_timer_arm(priv, queue);
  36. + *pending_packets = true;
  37. __netif_tx_unlock_bh(netdev_get_tx_queue(priv->dev, queue));
  38. @@ -5486,12 +5490,13 @@ static int stmmac_napi_poll_tx(struct na
  39. struct stmmac_channel *ch =
  40. container_of(napi, struct stmmac_channel, tx_napi);
  41. struct stmmac_priv *priv = ch->priv_data;
  42. + bool pending_packets = false;
  43. u32 chan = ch->index;
  44. int work_done;
  45. priv->xstats.napi_poll++;
  46. - work_done = stmmac_tx_clean(priv, budget, chan);
  47. + work_done = stmmac_tx_clean(priv, budget, chan, &pending_packets);
  48. work_done = min(work_done, budget);
  49. if (work_done < budget && napi_complete_done(napi, work_done)) {
  50. @@ -5502,6 +5507,10 @@ static int stmmac_napi_poll_tx(struct na
  51. spin_unlock_irqrestore(&ch->lock, flags);
  52. }
  53. + /* TX still have packet to handle, check if we need to arm tx timer */
  54. + if (pending_packets)
  55. + stmmac_tx_timer_arm(priv, chan);
  56. +
  57. return work_done;
  58. }
  59. @@ -5510,12 +5519,13 @@ static int stmmac_napi_poll_rxtx(struct
  60. struct stmmac_channel *ch =
  61. container_of(napi, struct stmmac_channel, rxtx_napi);
  62. struct stmmac_priv *priv = ch->priv_data;
  63. + bool tx_pending_packets = false;
  64. int rx_done, tx_done, rxtx_done;
  65. u32 chan = ch->index;
  66. priv->xstats.napi_poll++;
  67. - tx_done = stmmac_tx_clean(priv, budget, chan);
  68. + tx_done = stmmac_tx_clean(priv, budget, chan, &tx_pending_packets);
  69. tx_done = min(tx_done, budget);
  70. rx_done = stmmac_rx_zc(priv, budget, chan);
  71. @@ -5540,6 +5550,10 @@ static int stmmac_napi_poll_rxtx(struct
  72. spin_unlock_irqrestore(&ch->lock, flags);
  73. }
  74. + /* TX still have packet to handle, check if we need to arm tx timer */
  75. + if (tx_pending_packets)
  76. + stmmac_tx_timer_arm(priv, chan);
  77. +
  78. return min(rxtx_done, budget - 1);
  79. }