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