blob: 0e8423234bd18ac4638e28042d0bdbceb9fad9a8 [file] [log] [blame]
developera46f6132024-03-26 14:09:54 +08001From 37da0074c6570badb26e2fd527b55621bc571aca Mon Sep 17 00:00:00 2001
2From: Bo Jiao <Bo.Jiao@mediatek.com>
3Date: Tue, 6 Feb 2024 14:46:59 +0800
4Subject: [PATCH 1048/1051] wifi: mt76: mt7915: add SER overlap handle
5
6CR-ID: WCNCR00355921
7Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
8---
9 dma.c | 3 ++-
10 mcu.c | 7 +++++--
11 mt76.h | 9 +++++++++
12 mt7915/mac.c | 11 +++++++++++
13 mt7915/mcu.c | 7 +++++++
14 5 files changed, 34 insertions(+), 3 deletions(-)
15
16diff --git a/dma.c b/dma.c
17index 133a50dc..100d2aff 100644
18--- a/dma.c
19+++ b/dma.c
20@@ -506,7 +506,8 @@ mt76_dma_tx_queue_skb_raw(struct mt76_dev *dev, struct mt76_queue *q,
21 dma_addr_t addr;
22 int ret = -ENOMEM;
23
24- if (test_bit(MT76_MCU_RESET, &dev->phy.state)) {
25+ if (test_bit(MT76_MCU_RESET, &dev->phy.state) ||
26+ dev->recovery_state == MT76_RECOVERY_TRIGGERED) {
27 ret = -EAGAIN;
28 goto error;
29 }
30diff --git a/mcu.c b/mcu.c
31index de185cc9..1bc94e85 100644
32--- a/mcu.c
33+++ b/mcu.c
34@@ -42,7 +42,9 @@ struct sk_buff *mt76_mcu_get_response(struct mt76_dev *dev,
35 timeout = expires - jiffies;
36 wait_event_timeout(dev->mcu.wait,
37 (!skb_queue_empty(&dev->mcu.res_q) ||
38- test_bit(MT76_MCU_RESET, &dev->phy.state)),
39+ test_bit(MT76_MCU_RESET, &dev->phy.state) ||
40+ dev->recovery_state == MT76_RECOVERY_TRIGGERED ||
41+ dev->recovery_state == MT76_RECOVERY_OVERLAP_TRIGGERED),
42 timeout);
43 return skb_dequeue(&dev->mcu.res_q);
44 }
45@@ -92,7 +94,8 @@ int mt76_mcu_skb_send_and_get_msg(struct mt76_dev *dev, struct sk_buff *skb,
46 goto out;
47
48 if (retry && retry_cnt < MT76_MSG_MAX_RETRY_CNT) {
49- if (test_bit(MT76_MCU_RESET, &dev->phy.state))
50+ if (test_bit(MT76_MCU_RESET, &dev->phy.state) ||
51+ dev->recovery_state == MT76_RECOVERY_TRIGGERED)
52 usleep_range(200000, 500000);
53 dev_err(dev->dev, "send message %08x timeout, try again(%d).\n",
54 cmd, (MT76_MSG_MAX_RETRY_CNT - retry_cnt));
55diff --git a/mt76.h b/mt76.h
56index b023f38d..fb50d88b 100644
57--- a/mt76.h
58+++ b/mt76.h
59@@ -478,6 +478,14 @@ enum {
60 MT76_STATE_WED_RESET,
61 };
62
63+enum {
64+ MT76_RECOVERY_INIT,
65+ MT76_RECOVERY_TRIGGERED,
66+ MT76_RECOVERY_OVERLAP_TRIGGERED,
67+ MT76_RECOVERY_PROCESS,
68+ MT76_RECOVERY_DONE = MT76_RECOVERY_INIT,
69+};
70+
71 struct mt76_hw_cap {
72 bool has_2ghz;
73 bool has_5ghz;
74@@ -944,6 +952,7 @@ struct mt76_dev {
75 wait_queue_head_t tx_wait;
76 /* spinclock used to protect wcid pktid linked list */
77 spinlock_t status_lock;
78+ u16 recovery_state;
79
80 u32 wcid_mask[DIV_ROUND_UP(MT76_N_WCIDS, 32)];
81 u32 wcid_phy_mask[DIV_ROUND_UP(MT76_N_WCIDS, 32)];
82diff --git a/mt7915/mac.c b/mt7915/mac.c
83index dbc1095c..e9f50a38 100644
84--- a/mt7915/mac.c
85+++ b/mt7915/mac.c
86@@ -1579,6 +1579,7 @@ void mt7915_mac_reset_work(struct work_struct *work)
87 if (!(READ_ONCE(dev->recovery.state) & MT_MCU_CMD_STOP_DMA))
88 return;
89
90+ dev->mt76.recovery_state = MT76_RECOVERY_PROCESS;
91 dev_info(dev->mt76.dev,"\n%s L1 SER recovery start.",
92 wiphy_name(dev->mt76.hw->wiphy));
93
94@@ -1645,6 +1646,7 @@ void mt7915_mac_reset_work(struct work_struct *work)
95
96 mt7915_update_beacons(dev);
97
98+ dev->mt76.recovery_state = MT76_RECOVERY_DONE;
99 dev_info(dev->mt76.dev,"\n%s L1 SER recovery completed.",
100 wiphy_name(dev->mt76.hw->wiphy));
101 }
102@@ -1783,6 +1785,15 @@ void mt7915_reset(struct mt7915_dev *dev)
103 return;
104 }
105
106+ if ((READ_ONCE(dev->recovery.state) & MT_MCU_CMD_STOP_DMA)) {
107+ if (dev->mt76.recovery_state != MT76_RECOVERY_DONE)
108+ dev->mt76.recovery_state = MT76_RECOVERY_OVERLAP_TRIGGERED;
109+ else
110+ dev->mt76.recovery_state = MT76_RECOVERY_TRIGGERED;
111+
112+ wake_up(&dev->mt76.mcu.wait);
113+ }
114+
115 queue_work(dev->mt76.wq, &dev->reset_work);
116 wake_up(&dev->reset_wait);
117 }
118diff --git a/mt7915/mcu.c b/mt7915/mcu.c
119index c099c1d3..e6c2c3dc 100644
120--- a/mt7915/mcu.c
121+++ b/mt7915/mcu.c
122@@ -198,6 +198,13 @@ mt7915_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb,
123 enum mt76_mcuq_id qid;
124 int ret;
125
126+ if (mdev->recovery_state == MT76_RECOVERY_OVERLAP_TRIGGERED) {
127+ dev_info(dev->mt76.dev,"\n%s L1 SER recovery overlap, drop message %08x.",
128+ wiphy_name(dev->mt76.hw->wiphy), cmd);
129+ dev_kfree_skb(skb);
130+ return -EPERM;
131+ }
132+
133 ret = mt76_connac2_mcu_fill_message(mdev, skb, cmd, wait_seq);
134
135 if (ret)
136--
1372.18.0
138