forked from openwrt/openwrt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mt76: re-add ranys patch to test further
- Loading branch information
Showing
1 changed file
with
300 additions
and
0 deletions.
There are no files selected for viewing
300 changes: 300 additions & 0 deletions
300
package/kernel/mt76/patches/002-do-not-use-event-format.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,300 @@ | ||
From 18cc739263004d4846991c9afbc6ba45c39293a1 Mon Sep 17 00:00:00 2001 | ||
From: rany <ranygh@riseup.net> | ||
Date: Sat, 23 Mar 2024 11:08:23 +0200 | ||
Subject: [PATCH] mt76: mt7915: do not use event format to get survey data | ||
|
||
Using the event format to get survey data results in the chip | ||
eventually crashing with no chance of recovery. The only possible | ||
course of action is to restart the system and hope it never happens | ||
again. | ||
|
||
Signed-off-by: rany <ranygh@riseup.net> | ||
--- | ||
...7915-do-not-use-event-format-to-get-.patch | 278 ++++++++++++++++++ | ||
1 file changed, 278 insertions(+) | ||
create mode 100644 package/kernel/mt76/patches/9004-wifi-mt76-mt7915-do-not-use-event-format-to-get-.patch | ||
|
||
diff --git a/package/kernel/mt76/patches/9004-wifi-mt76-mt7915-do-not-use-event-format-to-get-.patch b/package/kernel/mt76/patches/9004-wifi-mt76-mt7915-do-not-use-event-format-to-get-.patch | ||
new file mode 100644 | ||
index 00000000000..bb3e4aa1800 | ||
--- /dev/null | ||
+++ b/package/kernel/mt76/patches/9004-wifi-mt76-mt7915-do-not-use-event-format-to-get-.patch | ||
@@ -0,0 +1,278 @@ | ||
+From 9b6482b0e42da5b69e5abe4473c99d1d0f518e28 Mon Sep 17 00:00:00 2001 | ||
+From: rany <ranygh@riseup.net> | ||
+Date: Fri, 26 May 2023 19:41:12 +0300 | ||
+Subject: [PATCH] wifi: mt76: mt7915: do not use event format to get survey | ||
+ data | ||
+ | ||
+Using the event format to get survey data results in the chip | ||
+eventually crashing with no chance of recovery. The only possible | ||
+course of action is to restart the system and hope it never happens | ||
+again. | ||
+ | ||
+Signed-off-by: rany <ranygh@riseup.net> | ||
+--- | ||
+ mt76_connac_mcu.h | 1 - | ||
+ mt7915/init.c | 1 + | ||
+ mt7915/mac.c | 40 ++++++++++++++++++++++---- | ||
+ mt7915/mcu.c | 72 ----------------------------------------------- | ||
+ mt7915/mcu.h | 21 -------------- | ||
+ mt7915/mt7915.h | 1 - | ||
+ mt7915/regs.h | 13 +++++++++ | ||
+ 7 files changed, 49 insertions(+), 100 deletions(-) | ||
+ | ||
+--- a/mt76_connac_mcu.h | ||
++++ b/mt76_connac_mcu.h | ||
+@@ -1216,7 +1216,6 @@ enum { | ||
+ MCU_EXT_CMD_EFUSE_FREE_BLOCK = 0x4f, | ||
+ MCU_EXT_CMD_TX_POWER_FEATURE_CTRL = 0x58, | ||
+ MCU_EXT_CMD_RXDCOC_CAL = 0x59, | ||
+- MCU_EXT_CMD_GET_MIB_INFO = 0x5a, | ||
+ #ifdef MTK_DEBUG | ||
+ MCU_EXT_CMD_RED_SHOW_STA = 0x69, | ||
+ MCU_EXT_CMD_RED_TARGET_DELAY = 0x6A, | ||
+--- a/mt7915/init.c | ||
++++ b/mt7915/init.c | ||
+@@ -494,6 +494,7 @@ mt7915_mac_init_band(struct mt7915_dev * | ||
+ mask = MT_WF_RMAC_MIB_OBSS_BACKOFF | MT_WF_RMAC_MIB_ED_OFFSET; | ||
+ set = FIELD_PREP(MT_WF_RMAC_MIB_OBSS_BACKOFF, 0) | | ||
+ FIELD_PREP(MT_WF_RMAC_MIB_ED_OFFSET, 4); | ||
++ mt76_rmw(dev, MT_WF_RMAC_MIB_TIME0(band), mask, set); | ||
+ mt76_rmw(dev, MT_WF_RMAC_MIB_AIRTIME0(band), mask, set); | ||
+ | ||
+ /* filter out non-resp frames and get instanstaeous signal reporting */ | ||
+--- a/mt7915/mac.c | ||
++++ b/mt7915/mac.c | ||
+@@ -1210,10 +1210,14 @@ void mt7915_mac_reset_counters(struct mt | ||
+ memset(phy->mt76->aggr_stats, 0, sizeof(phy->mt76->aggr_stats)); | ||
+ | ||
+ /* reset airtime counters */ | ||
++ mt76_rr(dev, MT_MIB_SDR9(phy->mt76->band_idx)); | ||
++ mt76_rr(dev, MT_MIB_SDR36(phy->mt76->band_idx)); | ||
++ mt76_rr(dev, MT_MIB_SDR37(phy->mt76->band_idx)); | ||
++ | ||
++ mt76_set(dev, MT_WF_RMAC_MIB_TIME0(phy->mt76->band_idx), | ||
++ MT_WF_RMAC_MIB_RXTIME_CLR); | ||
+ mt76_set(dev, MT_WF_RMAC_MIB_AIRTIME0(phy->mt76->band_idx), | ||
+ MT_WF_RMAC_MIB_RXTIME_CLR); | ||
+- | ||
+- mt7915_mcu_get_chan_mib_info(phy, true); | ||
+ } | ||
+ | ||
+ void mt7915_mac_set_timing(struct mt7915_phy *phy) | ||
+@@ -1275,23 +1279,49 @@ mt7915_phy_get_nf(struct mt7915_phy *phy | ||
+ return sum / n; | ||
+ } | ||
+ | ||
+-void mt7915_update_channel(struct mt76_phy *mphy) | ||
++static void | ||
++mt7915_phy_update_channel(struct mt76_phy *mphy, u8 idx) | ||
+ { | ||
++ struct mt7915_dev *dev = container_of(mphy->dev, struct mt7915_dev, mt76); | ||
+ struct mt7915_phy *phy = mphy->priv; | ||
+ struct mt76_channel_state *state = mphy->chan_state; | ||
++ u64 busy_time, tx_time, rx_time, obss_time; | ||
+ int nf; | ||
+ | ||
+- mt7915_mcu_get_chan_mib_info(phy, false); | ||
++ busy_time = mt76_get_field(dev, MT_MIB_SDR9(idx), | ||
++ MT_MIB_SDR9_BUSY_MASK); | ||
++ tx_time = mt76_get_field(dev, MT_MIB_SDR36(idx), | ||
++ MT_MIB_SDR36_TXTIME_MASK); | ||
++ rx_time = mt76_get_field(dev, MT_MIB_SDR37(idx), | ||
++ MT_MIB_SDR37_RXTIME_MASK); | ||
++ obss_time = mt76_get_field(dev, MT_WF_RMAC_MIB_AIRTIME14(idx), | ||
++ MT_MIB_OBSSTIME_MASK); | ||
+ | ||
+- nf = mt7915_phy_get_nf(phy, phy->mt76->band_idx); | ||
++ nf = mt7915_phy_get_nf(phy, idx); | ||
+ if (!phy->noise) | ||
+ phy->noise = nf << 4; | ||
+ else if (nf) | ||
+ phy->noise += nf - (phy->noise >> 4); | ||
+ | ||
++ state->cc_busy += busy_time; | ||
++ state->cc_tx += tx_time; | ||
++ state->cc_rx += rx_time + obss_time; | ||
++ state->cc_bss_rx += rx_time; | ||
+ state->noise = -(phy->noise >> 4); | ||
+ } | ||
+ | ||
++void mt7915_update_channel(struct mt76_phy *mphy) | ||
++{ | ||
++ struct mt7915_phy *phy = (struct mt7915_phy *)mphy->priv; | ||
++ struct mt7915_dev *dev = phy->dev; | ||
++ | ||
++ mt7915_phy_update_channel(mphy, phy->mt76->band_idx); | ||
++ | ||
++ /* reset obss airtime */ | ||
++ mt76_set(dev, MT_WF_RMAC_MIB_TIME0(phy->mt76->band_idx), | ||
++ MT_WF_RMAC_MIB_RXTIME_CLR); | ||
++} | ||
++ | ||
+ static bool | ||
+ mt7915_wait_reset_state(struct mt7915_dev *dev, u32 state) | ||
+ { | ||
+--- a/mt7915/mcu.c | ||
++++ b/mt7915/mcu.c | ||
+@@ -3347,78 +3347,6 @@ int mt7915_mcu_apply_tx_dpd(struct mt791 | ||
+ return 0; | ||
+ } | ||
+ | ||
+-int mt7915_mcu_get_chan_mib_info(struct mt7915_phy *phy, bool chan_switch) | ||
+-{ | ||
+- struct mt76_channel_state *state = phy->mt76->chan_state; | ||
+- struct mt76_channel_state *state_ts = &phy->state_ts; | ||
+- struct mt7915_dev *dev = phy->dev; | ||
+- struct mt7915_mcu_mib *res, req[5]; | ||
+- struct sk_buff *skb; | ||
+- static const u32 *offs; | ||
+- int i, ret, len, offs_cc; | ||
+- u64 cc_tx; | ||
+- | ||
+- /* strict order */ | ||
+- if (is_mt7915(&dev->mt76)) { | ||
+- static const u32 chip_offs[] = { | ||
+- MIB_NON_WIFI_TIME, | ||
+- MIB_TX_TIME, | ||
+- MIB_RX_TIME, | ||
+- MIB_OBSS_AIRTIME, | ||
+- MIB_TXOP_INIT_COUNT, | ||
+- }; | ||
+- len = ARRAY_SIZE(chip_offs); | ||
+- offs = chip_offs; | ||
+- offs_cc = 20; | ||
+- } else { | ||
+- static const u32 chip_offs[] = { | ||
+- MIB_NON_WIFI_TIME_V2, | ||
+- MIB_TX_TIME_V2, | ||
+- MIB_RX_TIME_V2, | ||
+- MIB_OBSS_AIRTIME_V2 | ||
+- }; | ||
+- len = ARRAY_SIZE(chip_offs); | ||
+- offs = chip_offs; | ||
+- offs_cc = 0; | ||
+- } | ||
+- | ||
+- for (i = 0; i < len; i++) { | ||
+- req[i].band = cpu_to_le32(phy->mt76->band_idx); | ||
+- req[i].offs = cpu_to_le32(offs[i]); | ||
+- } | ||
+- | ||
+- ret = mt76_mcu_send_and_get_msg(&dev->mt76, MCU_EXT_CMD(GET_MIB_INFO), | ||
+- req, len * sizeof(req[0]), true, &skb); | ||
+- if (ret) | ||
+- return ret; | ||
+- | ||
+- res = (struct mt7915_mcu_mib *)(skb->data + offs_cc); | ||
+- | ||
+-#define __res_u64(s) le64_to_cpu(res[s].data) | ||
+- /* subtract Tx backoff time from Tx duration */ | ||
+- cc_tx = is_mt7915(&dev->mt76) ? __res_u64(1) - __res_u64(4) : __res_u64(1); | ||
+- | ||
+- if (chan_switch) | ||
+- goto out; | ||
+- | ||
+- state->cc_tx += cc_tx - state_ts->cc_tx; | ||
+- state->cc_bss_rx += __res_u64(2) - state_ts->cc_bss_rx; | ||
+- state->cc_rx += __res_u64(2) + __res_u64(3) - state_ts->cc_rx; | ||
+- state->cc_busy += __res_u64(0) + cc_tx + __res_u64(2) + __res_u64(3) - | ||
+- state_ts->cc_busy; | ||
+- | ||
+-out: | ||
+- state_ts->cc_tx = cc_tx; | ||
+- state_ts->cc_bss_rx = __res_u64(2); | ||
+- state_ts->cc_rx = __res_u64(2) + __res_u64(3); | ||
+- state_ts->cc_busy = __res_u64(0) + cc_tx + __res_u64(2) + __res_u64(3); | ||
+-#undef __res_u64 | ||
+- | ||
+- dev_kfree_skb(skb); | ||
+- | ||
+- return 0; | ||
+-} | ||
+- | ||
+ int mt7915_mcu_get_temperature(struct mt7915_phy *phy) | ||
+ { | ||
+ struct mt7915_dev *dev = phy->dev; | ||
+--- a/mt7915/mcu.h | ||
++++ b/mt7915/mcu.h | ||
+@@ -263,27 +263,6 @@ struct mt7915_mcu_phy_rx_info { | ||
+ u8 bw; | ||
+ }; | ||
+ | ||
+-struct mt7915_mcu_mib { | ||
+- __le32 band; | ||
+- __le32 offs; | ||
+- __le64 data; | ||
+-} __packed; | ||
+- | ||
+-enum mt7915_chan_mib_offs { | ||
+- /* mt7915 */ | ||
+- MIB_TX_TIME = 81, | ||
+- MIB_RX_TIME, | ||
+- MIB_OBSS_AIRTIME = 86, | ||
+- MIB_NON_WIFI_TIME, | ||
+- MIB_TXOP_INIT_COUNT, | ||
+- | ||
+- /* mt7916 */ | ||
+- MIB_TX_TIME_V2 = 6, | ||
+- MIB_RX_TIME_V2 = 8, | ||
+- MIB_OBSS_AIRTIME_V2 = 490, | ||
+- MIB_NON_WIFI_TIME_V2 | ||
+-}; | ||
+- | ||
+ struct mt7915_mcu_txpower_sku { | ||
+ u8 format_id; | ||
+ u8 limit_type; | ||
+--- a/mt7915/mt7915.h | ||
++++ b/mt7915/mt7915.h | ||
+@@ -670,7 +670,6 @@ int mt7915_mcu_set_muru_ctrl(struct mt79 | ||
+ int mt7915_set_muru_cfg(struct mt7915_phy *phy, u8 mode, u8 val); | ||
+ int mt7915_mcu_apply_group_cal(struct mt7915_dev *dev); | ||
+ int mt7915_mcu_apply_tx_dpd(struct mt7915_phy *phy); | ||
+-int mt7915_mcu_get_chan_mib_info(struct mt7915_phy *phy, bool chan_switch); | ||
+ int mt7915_mcu_get_temperature(struct mt7915_phy *phy); | ||
+ int mt7915_mcu_set_thermal_throttling(struct mt7915_phy *phy, u8 state); | ||
+ int mt7915_mcu_set_thermal_protect(struct mt7915_phy *phy); | ||
+--- a/mt7915/regs.h | ||
++++ b/mt7915/regs.h | ||
+@@ -323,6 +323,9 @@ enum offs_rev { | ||
+ #define MT_MIB_SDR3_FCS_ERR_MASK GENMASK(15, 0) | ||
+ #define MT_MIB_SDR3_FCS_ERR_MASK_MT7916 GENMASK(31, 16) | ||
+ | ||
++#define MT_MIB_SDR9(_band) MT_WF_MIB(_band, 0x02c) | ||
++#define MT_MIB_SDR9_BUSY_MASK GENMASK(23, 0) | ||
++ | ||
+ #define MT_MIB_SDR4(_band) MT_WF_MIB(_band, __OFFS(MIB_SDR4)) | ||
+ #define MT_MIB_SDR4_RX_FIFO_FULL_MASK GENMASK(15, 0) | ||
+ | ||
+@@ -424,6 +427,11 @@ enum offs_rev { | ||
+ #define MT_MIB_SDR33(_band) MT_WF_MIB(_band, 0x088) | ||
+ #define MT_MIB_SDR33_TX_PKT_IBF_CNT GENMASK(15, 0) | ||
+ | ||
++#define MT_MIB_SDR36(_band) MT_WF_MIB(_band, 0x098) | ||
++#define MT_MIB_SDR36_TXTIME_MASK GENMASK(23, 0) | ||
++#define MT_MIB_SDR37(_band) MT_WF_MIB(_band, 0x09c) | ||
++#define MT_MIB_SDR37_RXTIME_MASK GENMASK(23, 0) | ||
++ | ||
+ #define MT_MIB_SDRMUBF(_band) MT_WF_MIB(_band, __OFFS(MIB_SDRMUBF)) | ||
+ #define MT_MIB_MU_BF_TX_CNT GENMASK(15, 0) | ||
+ | ||
+@@ -575,6 +583,7 @@ enum offs_rev { | ||
+ #define MT_WF_RMAC_RSVD0(_band) MT_WF_RMAC(_band, 0x02e0) | ||
+ #define MT_WF_RMAC_RSVD0_EIFS_CLR BIT(21) | ||
+ | ||
++#define MT_WF_RMAC_MIB_TIME0(_band) MT_WF_RMAC(_band, 0x03c4) | ||
+ #define MT_WF_RMAC_MIB_AIRTIME0(_band) MT_WF_RMAC(_band, 0x0380) | ||
+ #define MT_WF_RMAC_MIB_RXTIME_CLR BIT(31) | ||
+ #define MT_WF_RMAC_MIB_OBSS_BACKOFF GENMASK(15, 0) | ||
+@@ -589,6 +598,10 @@ enum offs_rev { | ||
+ #define MT_WF_RMAC_MIB_AIRTIME4(_band) MT_WF_RMAC(_band, 0x0390) | ||
+ #define MT_WF_RMAC_MIB_QOS23_BACKOFF GENMASK(31, 0) | ||
+ | ||
++#define MT_WF_RMAC_MIB_AIRTIME14(_band) MT_WF_RMAC(_band, 0x03b8) | ||
++#define MT_MIB_OBSSTIME_MASK GENMASK(23, 0) | ||
++#define MT_WF_RMAC_MIB_AIRTIME0(_band) MT_WF_RMAC(_band, 0x0380) | ||
++ | ||
+ /* WFDMA0 */ | ||
+ #define MT_WFDMA0_BASE __REG(WFDMA0_ADDR) | ||
+ #define MT_WFDMA0(ofs) (MT_WFDMA0_BASE + (ofs)) |