ipq40xx: switch default to 6.6
[openwrt/staging/stintel.git] / target / linux / ipq40xx / patches-6.1 / 711-net-qualcomm-ipqess-fix-TX-timeout-errors.patch
1 From d0055b03d9c8d48ad2b971821989b09ba95c39f8 Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Sun, 17 Sep 2023 20:18:31 +0200
4 Subject: [PATCH] net: qualcomm: ipqess: fix TX timeout errors
5
6 Currently logic to handle napi tx completion is flawed and on the long
7 run on loaded condition cause TX timeout error with the queue not being
8 able to handle any new packet.
9
10 There are 2 main cause of this:
11 - incrementing the packet done value wrongly
12 - handling 2 times the tx_ring tail
13
14 ipqess_tx_unmap_and_free may return 2 kind values:
15 - 0: we are handling first and middle descriptor for the packet
16 - packet len: we are at the last descriptor for the packet
17
18 Done value was wrongly incremented also for first and intermediate
19 descriptor for the packet resulting causing panic and TX timeouts by
20 comunicating to the kernel an inconsistent value of packet handling not
21 matching the expected ones.
22
23 Tx_ring tail was handled twice for ipqess_tx_complete run resulting in
24 again done value incremented wrongly and also problem with idx handling
25 by actually skipping descriptor for some packets.
26
27 Rework the loop logic to fix these 2 problem and also add some comments
28 to make sure ipqess_tx_unmap_and_free ret value is better
29 understandable.
30
31 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
32 ---
33 drivers/net/ethernet/qualcomm/ipqess/ipqess.c | 13 ++++++++++---
34 1 file changed, 10 insertions(+), 3 deletions(-)
35
36 --- a/drivers/net/ethernet/qualcomm/ipqess/ipqess.c
37 +++ b/drivers/net/ethernet/qualcomm/ipqess/ipqess.c
38 @@ -453,13 +453,22 @@ static int ipqess_tx_complete(struct ipq
39 tail >>= IPQESS_TPD_CONS_IDX_SHIFT;
40 tail &= IPQESS_TPD_CONS_IDX_MASK;
41
42 - do {
43 + while ((tx_ring->tail != tail) && (done < budget)) {
44 ret = ipqess_tx_unmap_and_free(&tx_ring->ess->pdev->dev,
45 &tx_ring->buf[tx_ring->tail]);
46 - tx_ring->tail = IPQESS_NEXT_IDX(tx_ring->tail, tx_ring->count);
47 + /* ipqess_tx_unmap_and_free may return 2 kind values:
48 + * - 0: we are handling first and middle descriptor for the packet
49 + * - packet len: we are at the last descriptor for the packet
50 + * Increment total bytes handled and packet done only if we are
51 + * handling the last descriptor for the packet.
52 + */
53 + if (ret) {
54 + total += ret;
55 + done++;
56 + }
57
58 - total += ret;
59 - } while ((++done < budget) && (tx_ring->tail != tail));
60 + tx_ring->tail = IPQESS_NEXT_IDX(tx_ring->tail, tx_ring->count);
61 + };
62
63 ipqess_w32(tx_ring->ess, IPQESS_REG_TX_SW_CONS_IDX_Q(tx_ring->idx),
64 tx_ring->tail);