7d2b7eccbf976952b15f1e31bf27fc6d3a9f7e1d
[openwrt/openwrt.git] / package / kernel / mt76 / patches / 101-wifi-mt76-mt7603-add-debugfs-attr-for-disabling-fram.patch
1 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
2 Date: Mon, 25 Mar 2024 18:54:02 +0100
3 Subject: [PATCH] wifi: mt76: mt7603: add debugfs attr for disabling frames
4 buffering
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 MT7603EN and MT7628AN were reported by multiple users to be unstable
10 under high traffic. Transmission of packets could stop for seconds often
11 leading to disconnections.
12
13 Long research & debugging revelaed a close relation between MCU
14 interrupts of type PKT_TYPE_TXS and slowdowns / stalls. That led to
15 questioning frames buffering feature.
16
17 It turns out that disabling SKBs loopback code makes mt7603 devices much
18 more stable under load. There are still some traffic hiccups but those
19 happen like once every an hour and end up in recovery in most cases.
20
21 Add a debugfs option for disabling frames buffering so users can give it
22 a try. If this solution yields a success we can make this feature
23 disabled by default.
24
25 This change was successfully tested using 2 GHz AP interface on:
26 1. Netgear R6220 - MT7621ST (SoC) + MT7603EN (WiFi) + MT7612EN (WiFi)
27 2. Xiaomi Mi Router 4C - MT7628AN (Wi-Fi SoC)
28
29 Link: https://lore.kernel.org/linux-wireless/7c96d5ee-86c1-8068-1b58-40db6087a24f@gmail.com/
30 Closes: https://github.com/openwrt/mt76/issues/865
31 Fixes: c8846e101502 ("mt76: add driver for MT7603E and MT7628/7688")
32 Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
33 ---
34 mt7603/debugfs.c | 2 ++
35 mt7603/dma.c | 3 +++
36 mt7603/init.c | 1 +
37 mt7603/mt7603.h | 2 ++
38 4 files changed, 8 insertions(+)
39
40 --- a/mt7603/debugfs.c
41 +++ b/mt7603/debugfs.c
42 @@ -115,4 +115,6 @@ void mt7603_init_debugfs(struct mt7603_d
43 &dev->sensitivity_limit);
44 debugfs_create_bool("dynamic_sensitivity", 0600, dir,
45 &dev->dynamic_sensitivity);
46 + debugfs_create_bool("frames_buffering", 0600, dir,
47 + &dev->frames_buffering);
48 }
49 --- a/mt7603/dma.c
50 +++ b/mt7603/dma.c
51 @@ -27,6 +27,9 @@ mt7603_rx_loopback_skb(struct mt7603_dev
52 u32 val;
53 u8 tid = 0;
54
55 + if (!dev->frames_buffering)
56 + goto free;
57 +
58 if (skb->len < MT_TXD_SIZE + sizeof(struct ieee80211_hdr))
59 goto free;
60
61 --- a/mt7603/init.c
62 +++ b/mt7603/init.c
63 @@ -517,6 +517,7 @@ int mt7603_register_device(struct mt7603
64 dev->slottime = 9;
65 dev->sensitivity_limit = 28;
66 dev->dynamic_sensitivity = true;
67 + dev->frames_buffering = true;
68
69 ret = mt7603_init_hardware(dev);
70 if (ret)
71 --- a/mt7603/mt7603.h
72 +++ b/mt7603/mt7603.h
73 @@ -155,6 +155,8 @@ struct mt7603_dev {
74 u32 reset_test;
75
76 unsigned int reset_cause[__RESET_CAUSE_MAX];
77 +
78 + bool frames_buffering;
79 };
80
81 extern const struct mt76_driver_ops mt7603_drv_ops;