blob: ab691e1319bbd9b2217e35f6272f79b5c6b12b3c [file] [log] [blame]
developer9237f442024-06-14 17:13:04 +08001From 5759eb68a8453f211699bb09d74a39dd9e8d4c02 Mon Sep 17 00:00:00 2001
developer66e89bc2024-04-23 14:50:01 +08002From: Bo Jiao <Bo.Jiao@mediatek.com>
3Date: Tue, 21 Nov 2023 09:55:46 +0800
developer9237f442024-06-14 17:13:04 +08004Subject: [PATCH 039/116] mtk: wifi: mt76: mt7996: add SER overlap handle
developer66e89bc2024-04-23 14:50:01 +08005
developer66e89bc2024-04-23 14:50:01 +08006Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
7---
8 mcu.c | 3 ++-
9 mt7996/mac.c | 11 +++++++++++
10 mt7996/mcu.c | 8 ++++++++
11 mt7996/mt7996.h | 2 ++
12 4 files changed, 23 insertions(+), 1 deletion(-)
13
14diff --git a/mcu.c b/mcu.c
developer9237f442024-06-14 17:13:04 +080015index 2926f71..a7afa2d 100644
developer66e89bc2024-04-23 14:50:01 +080016--- a/mcu.c
17+++ b/mcu.c
18@@ -94,7 +94,8 @@ int mt76_mcu_skb_send_and_get_msg(struct mt76_dev *dev, struct sk_buff *skb,
19 if (retry && retry_cnt < MT76_MSG_MAX_RETRY_CNT) {
20 if (test_bit(MT76_MCU_RESET, &dev->phy.state))
21 usleep_range(200000, 500000);
22- dev_err(dev->dev, "send message %08x timeout, try again.\n", cmd);
23+ dev_err(dev->dev, "send message %08x timeout, try again(%d).\n",
24+ cmd, (MT76_MSG_MAX_RETRY_CNT - retry_cnt));
25 }
26
27 ret = dev->mcu_ops->mcu_skb_send_msg(dev, skb_tmp, cmd, &seq);
28diff --git a/mt7996/mac.c b/mt7996/mac.c
developer9237f442024-06-14 17:13:04 +080029index 56827c9..9b5b995 100644
developer66e89bc2024-04-23 14:50:01 +080030--- a/mt7996/mac.c
31+++ b/mt7996/mac.c
32@@ -1885,6 +1885,7 @@ void mt7996_mac_reset_work(struct work_struct *work)
33 if (!(READ_ONCE(dev->recovery.state) & MT_MCU_CMD_STOP_DMA))
34 return;
35
36+ dev->recovery.l1_reset_last = dev->recovery.l1_reset;
37 dev_info(dev->mt76.dev,"\n%s L1 SER recovery start.",
38 wiphy_name(dev->mt76.hw->wiphy));
39
40@@ -1902,6 +1903,10 @@ void mt7996_mac_reset_work(struct work_struct *work)
41
42 set_bit(MT76_RESET, &dev->mphy.state);
43 set_bit(MT76_MCU_RESET, &dev->mphy.state);
44+ if (phy2)
45+ set_bit(MT76_RESET, &phy2->mt76->state);
46+ if (phy3)
47+ set_bit(MT76_RESET, &phy3->mt76->state);
48 wake_up(&dev->mt76.mcu.wait);
49
50 mt76_worker_disable(&dev->mt76.tx_worker);
51@@ -2097,6 +2102,9 @@ void mt7996_coredump(struct mt7996_dev *dev, u8 state)
52
53 void mt7996_reset(struct mt7996_dev *dev)
54 {
55+ dev_info(dev->mt76.dev, "%s SER recovery state: 0x%08x\n",
56+ wiphy_name(dev->mt76.hw->wiphy), READ_ONCE(dev->recovery.state));
57+
58 if (!dev->recovery.hw_init_done)
59 return;
60
61@@ -2116,6 +2124,9 @@ void mt7996_reset(struct mt7996_dev *dev)
62 return;
63 }
64
65+ if ((READ_ONCE(dev->recovery.state) & MT_MCU_CMD_STOP_DMA))
66+ dev->recovery.l1_reset++;
67+
68 queue_work(dev->mt76.wq, &dev->reset_work);
69 wake_up(&dev->reset_wait);
70 }
71diff --git a/mt7996/mcu.c b/mt7996/mcu.c
developer9237f442024-06-14 17:13:04 +080072index 2b9dedb..ce26cfb 100644
developer66e89bc2024-04-23 14:50:01 +080073--- a/mt7996/mcu.c
74+++ b/mt7996/mcu.c
75@@ -246,6 +246,14 @@ mt7996_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb,
76 u32 val;
77 u8 seq;
78
79+ if (dev->recovery.l1_reset_last != dev->recovery.l1_reset) {
80+ dev_info(dev->mt76.dev,"\n%s L1 SER recovery overlap, drop message %08x.",
81+ wiphy_name(dev->mt76.hw->wiphy), cmd);
82+
83+ dev_kfree_skb(skb);
84+ return -EPERM;
85+ }
86+
87 mdev->mcu.timeout = 20 * HZ;
88
89 seq = ++dev->mt76.mcu.msg_seq & 0xf;
90diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h
developer9237f442024-06-14 17:13:04 +080091index dbc4aa6..d40f8bf 100644
developer66e89bc2024-04-23 14:50:01 +080092--- a/mt7996/mt7996.h
93+++ b/mt7996/mt7996.h
94@@ -397,6 +397,8 @@ struct mt7996_dev {
95 wait_queue_head_t reset_wait;
96 struct {
97 u32 state;
98+ u32 l1_reset;
99+ u32 l1_reset_last;
100 u32 wa_reset_count;
101 u32 wm_reset_count;
102 bool hw_full_reset:1;
103--
developer9237f442024-06-14 17:13:04 +08001042.18.0
developer66e89bc2024-04-23 14:50:01 +0800105