generic: 6.6: manually refresh backport patches
[openwrt/openwrt.git] / target / linux / generic / backport-6.6 / 771-v6.7-02-net-stmmac-move-TX-timer-arm-after-DMA-enable.patch
1 From a594166387fe08e6f5a32130c400249a35b298f9 Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
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
6 Move TX timer arm call after DMA interrupt is enabled again.
7
8 The TX timer arm function changed logic and now is skipped if a napi is
9 already scheduled. By moving the TX timer arm call after DMA is enabled,
10 we permit to correctly skip if a DMA interrupt has been fired and a napi
11 has been scheduled again.
12
13 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
14 Signed-off-by: Paolo Abeni <pabeni@redhat.com>
15 ---
16 .../net/ethernet/stmicro/stmmac/stmmac_main.c | 22 +++++++++++++++----
17 1 file changed, 18 insertions(+), 4 deletions(-)
18
19 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
20 +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
21 @@ -2551,9 +2551,13 @@ static void stmmac_bump_dma_threshold(st
22 * @priv: driver private structure
23 * @budget: napi budget limiting this functions packet handling
24 * @queue: TX queue index
25 + * @pending_packets: signal to arm the TX coal timer
26 * Description: it reclaims the transmit resources after transmission completes.
27 + * If some packets still needs to be handled, due to TX coalesce, set
28 + * pending_packets to true to make NAPI arm the TX coal timer.
29 */
30 -static int stmmac_tx_clean(struct stmmac_priv *priv, int budget, u32 queue)
31 +static int stmmac_tx_clean(struct stmmac_priv *priv, int budget, u32 queue,
32 + bool *pending_packets)
33 {
34 struct stmmac_tx_queue *tx_q = &priv->dma_conf.tx_queue[queue];
35 struct stmmac_txq_stats *txq_stats = &priv->xstats.txq_stats[queue];
36 @@ -2713,7 +2717,7 @@ static int stmmac_tx_clean(struct stmmac
37
38 /* We still have pending packets, let's call for a new scheduling */
39 if (tx_q->dirty_tx != tx_q->cur_tx)
40 - stmmac_tx_timer_arm(priv, queue);
41 + *pending_packets = true;
42
43 u64_stats_update_begin(&txq_stats->napi_syncp);
44 u64_stats_add(&txq_stats->napi.tx_packets, tx_packets);
45 @@ -5603,6 +5607,7 @@ static int stmmac_napi_poll_tx(struct na
46 container_of(napi, struct stmmac_channel, tx_napi);
47 struct stmmac_priv *priv = ch->priv_data;
48 struct stmmac_txq_stats *txq_stats;
49 + bool pending_packets = false;
50 u32 chan = ch->index;
51 int work_done;
52
53 @@ -5611,7 +5616,7 @@ static int stmmac_napi_poll_tx(struct na
54 u64_stats_inc(&txq_stats->napi.poll);
55 u64_stats_update_end(&txq_stats->napi_syncp);
56
57 - work_done = stmmac_tx_clean(priv, budget, chan);
58 + work_done = stmmac_tx_clean(priv, budget, chan, &pending_packets);
59 work_done = min(work_done, budget);
60
61 if (work_done < budget && napi_complete_done(napi, work_done)) {
62 @@ -5622,6 +5627,10 @@ static int stmmac_napi_poll_tx(struct na
63 spin_unlock_irqrestore(&ch->lock, flags);
64 }
65
66 + /* TX still have packet to handle, check if we need to arm tx timer */
67 + if (pending_packets)
68 + stmmac_tx_timer_arm(priv, chan);
69 +
70 return work_done;
71 }
72
73 @@ -5630,6 +5639,7 @@ static int stmmac_napi_poll_rxtx(struct
74 struct stmmac_channel *ch =
75 container_of(napi, struct stmmac_channel, rxtx_napi);
76 struct stmmac_priv *priv = ch->priv_data;
77 + bool tx_pending_packets = false;
78 int rx_done, tx_done, rxtx_done;
79 struct stmmac_rxq_stats *rxq_stats;
80 struct stmmac_txq_stats *txq_stats;
81 @@ -5645,7 +5655,7 @@ static int stmmac_napi_poll_rxtx(struct
82 u64_stats_inc(&txq_stats->napi.poll);
83 u64_stats_update_end(&txq_stats->napi_syncp);
84
85 - tx_done = stmmac_tx_clean(priv, budget, chan);
86 + tx_done = stmmac_tx_clean(priv, budget, chan, &tx_pending_packets);
87 tx_done = min(tx_done, budget);
88
89 rx_done = stmmac_rx_zc(priv, budget, chan);
90 @@ -5670,6 +5680,10 @@ static int stmmac_napi_poll_rxtx(struct
91 spin_unlock_irqrestore(&ch->lock, flags);
92 }
93
94 + /* TX still have packet to handle, check if we need to arm tx timer */
95 + if (tx_pending_packets)
96 + stmmac_tx_timer_arm(priv, chan);
97 +
98 return min(rxtx_done, budget - 1);
99 }
100