bd890e5c71c03e4e8b6debcf01f1159bdba097c4
[openwrt/staging/stintel.git] / target / linux / ipq40xx / patches-6.1 / 703-net-qualcomm-ipqess-release-IRQ-s-on-network-device-.patch
1 From 5f15f7f170c76220dfd36cb9037d7848d1fc4aaf Mon Sep 17 00:00:00 2001
2 From: Robert Marko <robimarko@gmail.com>
3 Date: Tue, 15 Aug 2023 14:30:50 +0200
4 Subject: [PATCH] net: qualcomm: ipqess: release IRQ-s on network device stop
5
6 Currently, IPQESS driver is obtaining the IRQ-s during ndo_open, but they
7 are never freed as they are device managed.
8
9 However, it is not enough for them to be released when device is removed
10 as the same network device can be stopped and started multiple times which
11 on the second start would lead to IRQ request to fail with -EBUSY as they
12 have already been requested before and are not of the shared type with:
13 [ 34.480769] ipqess-edma c080000.ethernet eth0: Link is Down
14 [ 34.488070] ipqess-edma c080000.ethernet eth0: ipqess_open
15 [ 34.488131] genirq: Flags mismatch irq 37. 00000001 (c080000.ethernet:txq0) vs. 00000001 (c080000.ethernet:txq0)
16 [ 34.494527] ipqess-edma c080000.ethernet eth0: ipqess_open
17 [ 34.502892] genirq: Flags mismatch irq 37. 00000001 (c080000.ethernet:txq0) vs. 00000001 (c080000.ethernet:txq0)
18 [ 34.508137] qca8k-ipq4019 c000000.switch lan1: failed to open master eth0
19 [ 34.518966] br-lan: port 1(lan1) entered blocking state
20 [ 34.525165] br-lan: port 1(lan1) entered disabled state
21 [ 34.530633] device lan1 entered promiscuous mode
22 [ 34.548598] ipqess-edma c080000.ethernet eth0: ipqess_open
23 [ 34.548660] genirq: Flags mismatch irq 37. 00000001 (c080000.ethernet:txq0) vs. 00000001 (c080000.ethernet:txq0)
24 [ 34.553111] qca8k-ipq4019 c000000.switch lan2: failed to open master eth0
25 [ 34.563841] br-lan: port 2(lan2) entered blocking state
26 [ 34.570083] br-lan: port 2(lan2) entered disabled state
27 [ 34.575530] device lan2 entered promiscuous mode
28 [ 34.587067] ipqess-edma c080000.ethernet eth0: ipqess_open
29 [ 34.587132] genirq: Flags mismatch irq 37. 00000001 (c080000.ethernet:txq0) vs. 00000001 (c080000.ethernet:txq0)
30 [ 34.591579] qca8k-ipq4019 c000000.switch lan3: failed to open master eth0
31 [ 34.602451] br-lan: port 3(lan3) entered blocking state
32 [ 34.608496] br-lan: port 3(lan3) entered disabled state
33 [ 34.614084] device lan3 entered promiscuous mode
34 [ 34.626405] ipqess-edma c080000.ethernet eth0: ipqess_open
35 [ 34.626468] genirq: Flags mismatch irq 37. 00000001 (c080000.ethernet:txq0) vs. 00000001 (c080000.ethernet:txq0)
36 [ 34.630871] qca8k-ipq4019 c000000.switch lan4: failed to open master eth0
37 [ 34.641689] br-lan: port 4(lan4) entered blocking state
38 [ 34.647834] br-lan: port 4(lan4) entered disabled state
39 [ 34.653455] device lan4 entered promiscuous mode
40 [ 34.667282] ipqess-edma c080000.ethernet eth0: ipqess_open
41 [ 34.667364] genirq: Flags mismatch irq 37. 00000001 (c080000.ethernet:txq0) vs. 00000001 (c080000.ethernet:txq0)
42 [ 34.671830] qca8k-ipq4019 c000000.switch wan: failed to open master eth0
43
44 So, lets free the IRQ-s on ndo_stop after stopping NAPI and HW IRQ-s.
45
46 Signed-off-by: Robert Marko <robimarko@gmail.com>
47 ---
48 drivers/net/ethernet/qualcomm/ipqess/ipqess.c | 13 +++++++++++++
49 1 file changed, 13 insertions(+)
50
51 --- a/drivers/net/ethernet/qualcomm/ipqess/ipqess.c
52 +++ b/drivers/net/ethernet/qualcomm/ipqess/ipqess.c
53 @@ -636,9 +636,22 @@ static int ipqess_stop(struct net_device
54 netif_tx_stop_all_queues(netdev);
55 phylink_stop(ess->phylink);
56 ipqess_irq_disable(ess);
57 +
58 for (i = 0; i < IPQESS_NETDEV_QUEUES; i++) {
59 + int qid;
60 +
61 napi_disable(&ess->tx_ring[i].napi_tx);
62 napi_disable(&ess->rx_ring[i].napi_rx);
63 +
64 + qid = ess->tx_ring[i].idx;
65 + devm_free_irq(&netdev->dev,
66 + ess->tx_irq[qid],
67 + &ess->tx_ring[i]);
68 +
69 + qid = ess->rx_ring[i].idx;
70 + devm_free_irq(&netdev->dev,
71 + ess->rx_irq[qid],
72 + &ess->rx_ring[i]);
73 }
74
75 return 0;