kernel: bump 6.1 to 6.1.68
[openwrt/staging/stintel.git] / target / linux / ipq806x / patches-6.1 / 700-02-net-stmmac-move-TX-timer-arm-after-DMA-enable.patch
1 From fb04db35447d1e8ff557c8e57139164cecab7de5 Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Wed, 27 Sep 2023 15:38:31 +0200
4 Subject: [PATCH 2/4] 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 ---
15 .../net/ethernet/stmicro/stmmac/stmmac_main.c | 19 +++++++++++++++----
16 1 file changed, 15 insertions(+), 4 deletions(-)
17
18 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
19 +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
20 @@ -2530,7 +2530,8 @@ static void stmmac_bump_dma_threshold(st
21 * @queue: TX queue index
22 * Description: it reclaims the transmit resources after transmission completes.
23 */
24 -static int stmmac_tx_clean(struct stmmac_priv *priv, int budget, u32 queue)
25 +static int stmmac_tx_clean(struct stmmac_priv *priv, int budget, u32 queue,
26 + bool *pending_packets)
27 {
28 struct stmmac_tx_queue *tx_q = &priv->dma_conf.tx_queue[queue];
29 unsigned int bytes_compl = 0, pkts_compl = 0;
30 @@ -2693,7 +2694,7 @@ static int stmmac_tx_clean(struct stmmac
31
32 /* We still have pending packets, let's call for a new scheduling */
33 if (tx_q->dirty_tx != tx_q->cur_tx)
34 - stmmac_tx_timer_arm(priv, queue);
35 + *pending_packets = true;
36
37 __netif_tx_unlock_bh(netdev_get_tx_queue(priv->dev, queue));
38
39 @@ -5476,12 +5477,13 @@ static int stmmac_napi_poll_tx(struct na
40 struct stmmac_channel *ch =
41 container_of(napi, struct stmmac_channel, tx_napi);
42 struct stmmac_priv *priv = ch->priv_data;
43 + bool pending_packets = false;
44 u32 chan = ch->index;
45 int work_done;
46
47 priv->xstats.napi_poll++;
48
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
53 if (work_done < budget && napi_complete_done(napi, work_done)) {
54 @@ -5492,6 +5494,10 @@ static int stmmac_napi_poll_tx(struct na
55 spin_unlock_irqrestore(&ch->lock, flags);
56 }
57
58 + /* TX still have packet to handle, check if we need to arm tx timer */
59 + if (pending_packets)
60 + stmmac_tx_timer_arm(priv, chan);
61 +
62 return work_done;
63 }
64
65 @@ -5501,11 +5507,12 @@ static int stmmac_napi_poll_rxtx(struct
66 container_of(napi, struct stmmac_channel, rxtx_napi);
67 struct stmmac_priv *priv = ch->priv_data;
68 int rx_done, tx_done, rxtx_done;
69 + bool tx_pending_packets = false;
70 u32 chan = ch->index;
71
72 priv->xstats.napi_poll++;
73
74 - tx_done = stmmac_tx_clean(priv, budget, chan);
75 + tx_done = stmmac_tx_clean(priv, budget, chan, &tx_pending_packets);
76 tx_done = min(tx_done, budget);
77
78 rx_done = stmmac_rx_zc(priv, budget, chan);
79 @@ -5530,6 +5537,10 @@ static int stmmac_napi_poll_rxtx(struct
80 spin_unlock_irqrestore(&ch->lock, flags);
81 }
82
83 + /* TX still have packet to handle, check if we need to arm tx timer */
84 + if (tx_pending_packets)
85 + stmmac_tx_timer_arm(priv, chan);
86 +
87 return min(rxtx_done, budget - 1);
88 }
89