blob: b8314fd87e9127187c2fff595ce8009851c306e5 [file] [log] [blame]
developera20cdc22024-05-31 18:57:31 +08001From 0f8d644d9c7ab28e9e4da56151987a3e4be1f55f Mon Sep 17 00:00:00 2001
developera46f6132024-03-26 14:09:54 +08002From: Bo Jiao <Bo.Jiao@mediatek.com>
3Date: Tue, 6 Feb 2024 14:46:59 +0800
developera20cdc22024-05-31 18:57:31 +08004Subject: [PATCH 1047/1051] wifi: mt76: mt7915: add SER overlap handle
developera46f6132024-03-26 14:09:54 +08005
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
developerdc9eeae2024-04-08 14:36:46 +080017index 133a50d..100d2af 100644
developera46f6132024-03-26 14:09:54 +080018--- 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
developerdc9eeae2024-04-08 14:36:46 +080031index de185cc..1bc94e8 100644
developera46f6132024-03-26 14:09:54 +080032--- 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
developera20cdc22024-05-31 18:57:31 +080056index a7a8ece..e6482e5 100644
developera46f6132024-03-26 14:09:54 +080057--- 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
developera20cdc22024-05-31 18:57:31 +080083index b3c9163..c84b957 100644
developera46f6132024-03-26 14:09:54 +080084--- a/mt7915/mac.c
85+++ b/mt7915/mac.c
developera20cdc22024-05-31 18:57:31 +080086@@ -1538,6 +1538,7 @@ void mt7915_mac_reset_work(struct work_struct *work)
developera46f6132024-03-26 14:09:54 +080087 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
developera20cdc22024-05-31 18:57:31 +080094@@ -1604,6 +1605,7 @@ void mt7915_mac_reset_work(struct work_struct *work)
developera46f6132024-03-26 14:09:54 +080095
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 }
developera20cdc22024-05-31 18:57:31 +0800102@@ -1742,6 +1744,15 @@ void mt7915_reset(struct mt7915_dev *dev)
developera46f6132024-03-26 14:09:54 +0800103 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
developera20cdc22024-05-31 18:57:31 +0800119index cb78961..f890063 100644
developera46f6132024-03-26 14:09:54 +0800120--- 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