blob: b422e69ef20719ecb278fe41bd96867c81ef9baa [file] [log] [blame]
developerd0c89452024-10-11 16:53:27 +08001From 0b6f875816c6849eaadae1cbf974ee1327af04f2 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
developerd0c89452024-10-11 16:53:27 +08004Subject: [PATCH 033/223] mtk: 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---
developer66e89bc2024-04-23 14:50:01 +08008 mt7996/mac.c | 11 +++++++++++
9 mt7996/mcu.c | 8 ++++++++
10 mt7996/mt7996.h | 2 ++
developerd0c89452024-10-11 16:53:27 +080011 3 files changed, 21 insertions(+)
developer66e89bc2024-04-23 14:50:01 +080012
developer66e89bc2024-04-23 14:50:01 +080013diff --git a/mt7996/mac.c b/mt7996/mac.c
developerd0c89452024-10-11 16:53:27 +080014index 3c9ee0c8..2ce9e839 100644
developer66e89bc2024-04-23 14:50:01 +080015--- a/mt7996/mac.c
16+++ b/mt7996/mac.c
developerd0c89452024-10-11 16:53:27 +080017@@ -1906,6 +1906,7 @@ void mt7996_mac_reset_work(struct work_struct *work)
developer66e89bc2024-04-23 14:50:01 +080018 if (!(READ_ONCE(dev->recovery.state) & MT_MCU_CMD_STOP_DMA))
19 return;
20
21+ dev->recovery.l1_reset_last = dev->recovery.l1_reset;
22 dev_info(dev->mt76.dev,"\n%s L1 SER recovery start.",
23 wiphy_name(dev->mt76.hw->wiphy));
24
developerd0c89452024-10-11 16:53:27 +080025@@ -1923,6 +1924,10 @@ void mt7996_mac_reset_work(struct work_struct *work)
developer66e89bc2024-04-23 14:50:01 +080026
27 set_bit(MT76_RESET, &dev->mphy.state);
28 set_bit(MT76_MCU_RESET, &dev->mphy.state);
29+ if (phy2)
30+ set_bit(MT76_RESET, &phy2->mt76->state);
31+ if (phy3)
32+ set_bit(MT76_RESET, &phy3->mt76->state);
33 wake_up(&dev->mt76.mcu.wait);
34
35 mt76_worker_disable(&dev->mt76.tx_worker);
developerd0c89452024-10-11 16:53:27 +080036@@ -2118,6 +2123,9 @@ void mt7996_coredump(struct mt7996_dev *dev, u8 state)
developer66e89bc2024-04-23 14:50:01 +080037
38 void mt7996_reset(struct mt7996_dev *dev)
39 {
40+ dev_info(dev->mt76.dev, "%s SER recovery state: 0x%08x\n",
41+ wiphy_name(dev->mt76.hw->wiphy), READ_ONCE(dev->recovery.state));
42+
43 if (!dev->recovery.hw_init_done)
44 return;
45
developerd0c89452024-10-11 16:53:27 +080046@@ -2137,6 +2145,9 @@ void mt7996_reset(struct mt7996_dev *dev)
developer66e89bc2024-04-23 14:50:01 +080047 return;
48 }
49
50+ if ((READ_ONCE(dev->recovery.state) & MT_MCU_CMD_STOP_DMA))
51+ dev->recovery.l1_reset++;
52+
53 queue_work(dev->mt76.wq, &dev->reset_work);
54 wake_up(&dev->reset_wait);
55 }
56diff --git a/mt7996/mcu.c b/mt7996/mcu.c
developerd0c89452024-10-11 16:53:27 +080057index 08234b3a..2a647b7b 100644
developer66e89bc2024-04-23 14:50:01 +080058--- a/mt7996/mcu.c
59+++ b/mt7996/mcu.c
developerd0c89452024-10-11 16:53:27 +080060@@ -256,6 +256,14 @@ mt7996_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb,
developer66e89bc2024-04-23 14:50:01 +080061 u32 val;
62 u8 seq;
63
64+ if (dev->recovery.l1_reset_last != dev->recovery.l1_reset) {
65+ dev_info(dev->mt76.dev,"\n%s L1 SER recovery overlap, drop message %08x.",
66+ wiphy_name(dev->mt76.hw->wiphy), cmd);
67+
68+ dev_kfree_skb(skb);
69+ return -EPERM;
70+ }
71+
72 mdev->mcu.timeout = 20 * HZ;
73
74 seq = ++dev->mt76.mcu.msg_seq & 0xf;
75diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h
developerd0c89452024-10-11 16:53:27 +080076index 7bc5504e..22d44542 100644
developer66e89bc2024-04-23 14:50:01 +080077--- a/mt7996/mt7996.h
78+++ b/mt7996/mt7996.h
developerd0c89452024-10-11 16:53:27 +080079@@ -406,6 +406,8 @@ struct mt7996_dev {
developer66e89bc2024-04-23 14:50:01 +080080 wait_queue_head_t reset_wait;
81 struct {
82 u32 state;
83+ u32 l1_reset;
84+ u32 l1_reset_last;
85 u32 wa_reset_count;
86 u32 wm_reset_count;
87 bool hw_full_reset:1;
88--
developerd0c89452024-10-11 16:53:27 +0800892.45.2
developer66e89bc2024-04-23 14:50:01 +080090