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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. @@ -2551,9 +2551,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. struct stmmac_txq_stats *txq_stats = &priv->xstats.txq_stats[queue];
  32. @@ -2713,7 +2717,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. u64_stats_update_begin(&txq_stats->napi_syncp);
  38. u64_stats_add(&txq_stats->napi.tx_packets, tx_packets);
  39. @@ -5605,6 +5609,7 @@ static int stmmac_napi_poll_tx(struct na
  40. container_of(napi, struct stmmac_channel, tx_napi);
  41. struct stmmac_priv *priv = ch->priv_data;
  42. struct stmmac_txq_stats *txq_stats;
  43. + bool pending_packets = false;
  44. u32 chan = ch->index;
  45. int work_done;
  46. @@ -5613,7 +5618,7 @@ static int stmmac_napi_poll_tx(struct na
  47. u64_stats_inc(&txq_stats->napi.poll);
  48. u64_stats_update_end(&txq_stats->napi_syncp);
  49. - work_done = stmmac_tx_clean(priv, budget, chan);
  50. + work_done = stmmac_tx_clean(priv, budget, chan, &pending_packets);
  51. work_done = min(work_done, budget);
  52. if (work_done < budget && napi_complete_done(napi, work_done)) {
  53. @@ -5624,6 +5629,10 @@ static int stmmac_napi_poll_tx(struct na
  54. spin_unlock_irqrestore(&ch->lock, flags);
  55. }
  56. + /* TX still have packet to handle, check if we need to arm tx timer */
  57. + if (pending_packets)
  58. + stmmac_tx_timer_arm(priv, chan);
  59. +
  60. return work_done;
  61. }
  62. @@ -5632,6 +5641,7 @@ static int stmmac_napi_poll_rxtx(struct
  63. struct stmmac_channel *ch =
  64. container_of(napi, struct stmmac_channel, rxtx_napi);
  65. struct stmmac_priv *priv = ch->priv_data;
  66. + bool tx_pending_packets = false;
  67. int rx_done, tx_done, rxtx_done;
  68. struct stmmac_rxq_stats *rxq_stats;
  69. struct stmmac_txq_stats *txq_stats;
  70. @@ -5647,7 +5657,7 @@ static int stmmac_napi_poll_rxtx(struct
  71. u64_stats_inc(&txq_stats->napi.poll);
  72. u64_stats_update_end(&txq_stats->napi_syncp);
  73. - tx_done = stmmac_tx_clean(priv, budget, chan);
  74. + tx_done = stmmac_tx_clean(priv, budget, chan, &tx_pending_packets);
  75. tx_done = min(tx_done, budget);
  76. rx_done = stmmac_rx_zc(priv, budget, chan);
  77. @@ -5672,6 +5682,10 @@ static int stmmac_napi_poll_rxtx(struct
  78. spin_unlock_irqrestore(&ch->lock, flags);
  79. }
  80. + /* TX still have packet to handle, check if we need to arm tx timer */
  81. + if (tx_pending_packets)
  82. + stmmac_tx_timer_arm(priv, chan);
  83. +
  84. return min(rxtx_done, budget - 1);
  85. }