kernel: bump 6.1 to 6.1.81
[openwrt/openwrt.git] / target / linux / generic / backport-6.1 / 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 @@ -2527,9 +2527,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 unsigned int bytes_compl = 0, pkts_compl = 0;
36 @@ -2692,7 +2696,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 __netif_tx_unlock_bh(netdev_get_tx_queue(priv->dev, queue));
44
45 @@ -5490,12 +5494,13 @@ static int stmmac_napi_poll_tx(struct na
46 struct stmmac_channel *ch =
47 container_of(napi, struct stmmac_channel, tx_napi);
48 struct stmmac_priv *priv = ch->priv_data;
49 + bool pending_packets = false;
50 u32 chan = ch->index;
51 int work_done;
52
53 priv->xstats.napi_poll++;
54
55 - work_done = stmmac_tx_clean(priv, budget, chan);
56 + work_done = stmmac_tx_clean(priv, budget, chan, &pending_packets);
57 work_done = min(work_done, budget);
58
59 if (work_done < budget && napi_complete_done(napi, work_done)) {
60 @@ -5506,6 +5511,10 @@ static int stmmac_napi_poll_tx(struct na
61 spin_unlock_irqrestore(&ch->lock, flags);
62 }
63
64 + /* TX still have packet to handle, check if we need to arm tx timer */
65 + if (pending_packets)
66 + stmmac_tx_timer_arm(priv, chan);
67 +
68 return work_done;
69 }
70
71 @@ -5514,12 +5523,13 @@ static int stmmac_napi_poll_rxtx(struct
72 struct stmmac_channel *ch =
73 container_of(napi, struct stmmac_channel, rxtx_napi);
74 struct stmmac_priv *priv = ch->priv_data;
75 + bool tx_pending_packets = false;
76 int rx_done, tx_done, rxtx_done;
77 u32 chan = ch->index;
78
79 priv->xstats.napi_poll++;
80
81 - tx_done = stmmac_tx_clean(priv, budget, chan);
82 + tx_done = stmmac_tx_clean(priv, budget, chan, &tx_pending_packets);
83 tx_done = min(tx_done, budget);
84
85 rx_done = stmmac_rx_zc(priv, budget, chan);
86 @@ -5544,6 +5554,10 @@ static int stmmac_napi_poll_rxtx(struct
87 spin_unlock_irqrestore(&ch->lock, flags);
88 }
89
90 + /* TX still have packet to handle, check if we need to arm tx timer */
91 + if (tx_pending_packets)
92 + stmmac_tx_timer_arm(priv, chan);
93 +
94 return min(rxtx_done, budget - 1);
95 }
96