| From cfd870baf9b6200fd0960a24dff0401c0abc4194 Mon Sep 17 00:00:00 2001 |
| From: Bo Jiao <Bo.Jiao@mediatek.com> |
| Date: Mon, 22 May 2023 15:30:21 +0800 |
| Subject: [PATCH 1031/1034] wifi: mt76: mt7915: add debugfs for fw coredump. |
| |
| Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com> |
| --- |
| mt7915/debugfs.c | 22 +++++++++++++++++----- |
| mt7915/mac.c | 30 +++++++++++++++++++++++++++--- |
| mt7915/mcu.h | 6 +++++- |
| mt7915/mt7915.h | 9 +++++++++ |
| 4 files changed, 58 insertions(+), 9 deletions(-) |
| |
| diff --git a/mt7915/debugfs.c b/mt7915/debugfs.c |
| index 19a37b5..ae291a3 100644 |
| --- a/mt7915/debugfs.c |
| +++ b/mt7915/debugfs.c |
| @@ -82,8 +82,10 @@ mt7915_sys_recovery_set(struct file *file, const char __user *user_buf, |
| * 4: trigger & enable system error L3 tx abort |
| * 5: trigger & enable system error L3 tx disable. |
| * 6: trigger & enable system error L3 bf recovery. |
| - * 7: trigger & enable system error full recovery. |
| - * 8: trigger firmware crash. |
| + * 8: trigger & enable system error full recovery. |
| + * 9: trigger firmware crash. |
| + * 10: trigger grab wa firmware coredump. |
| + * 11: trigger grab wm firmware coredump. |
| */ |
| case SER_QUERY: |
| ret = mt7915_mcu_set_ser(dev, 0, 0, band); |
| @@ -108,7 +110,7 @@ mt7915_sys_recovery_set(struct file *file, const char __user *user_buf, |
| if (ret) |
| return ret; |
| |
| - dev->recovery.state |= MT_MCU_CMD_WDT_MASK; |
| + dev->recovery.state |= MT_MCU_CMD_WM_WDT; |
| mt7915_reset(dev); |
| break; |
| |
| @@ -117,6 +119,12 @@ mt7915_sys_recovery_set(struct file *file, const char __user *user_buf, |
| mt76_wr(dev, MT_MCU_WM_CIRQ_EINT_MASK_CLR_ADDR, BIT(18)); |
| mt76_wr(dev, MT_MCU_WM_CIRQ_EINT_SOFT_ADDR, BIT(18)); |
| break; |
| + |
| + case SER_SET_FW_COREDUMP_WA: |
| + mt7915_coredump(dev, MT7915_COREDUMP_MANUAL_WA); |
| + break; |
| + case SER_SET_FW_COREDUMP_WM: |
| + mt7915_coredump(dev, MT7915_COREDUMP_MANUAL_WM); |
| default: |
| break; |
| } |
| @@ -157,9 +165,13 @@ mt7915_sys_recovery_get(struct file *file, char __user *user_buf, |
| desc += scnprintf(buff + desc, bufsz - desc, |
| "6: trigger system error L3 bf recovery\n"); |
| desc += scnprintf(buff + desc, bufsz - desc, |
| - "7: trigger system error full recovery\n"); |
| + "8: trigger system error full recovery\n"); |
| + desc += scnprintf(buff + desc, bufsz - desc, |
| + "9: trigger firmware crash\n"); |
| + desc += scnprintf(buff + desc, bufsz - desc, |
| + "10: trigger grab wa firmware coredump\n"); |
| desc += scnprintf(buff + desc, bufsz - desc, |
| - "8: trigger firmware crash\n"); |
| + "11: trigger grab wm firmware coredump\n"); |
| |
| /* SER statistics */ |
| desc += scnprintf(buff + desc, bufsz - desc, |
| diff --git a/mt7915/mac.c b/mt7915/mac.c |
| index 436fc31..f930c50 100644 |
| --- a/mt7915/mac.c |
| +++ b/mt7915/mac.c |
| @@ -1725,10 +1725,34 @@ void mt7915_mac_dump_work(struct work_struct *work) |
| |
| dev = container_of(work, struct mt7915_dev, dump_work); |
| |
| - if (READ_ONCE(dev->recovery.state) & MT_MCU_CMD_WM_WDT) |
| + if (dev->dump_state == MT7915_COREDUMP_MANUAL_WA || |
| + READ_ONCE(dev->recovery.state) & MT_MCU_CMD_WA_WDT) |
| + mt7915_mac_fw_coredump(dev, MT76_RAM_TYPE_WA); |
| + |
| + if (dev->dump_state == MT7915_COREDUMP_MANUAL_WM || |
| + READ_ONCE(dev->recovery.state) & MT_MCU_CMD_WM_WDT) |
| mt7915_mac_fw_coredump(dev, MT76_RAM_TYPE_WM); |
| |
| - queue_work(dev->mt76.wq, &dev->reset_work); |
| + if (READ_ONCE(dev->recovery.state) & MT_MCU_CMD_WDT_MASK) |
| + queue_work(dev->mt76.wq, &dev->reset_work); |
| + |
| + dev->dump_state = MT7915_COREDUMP_IDLE; |
| +} |
| + |
| +void mt7915_coredump(struct mt7915_dev *dev, u8 state) |
| +{ |
| + if (state == MT7915_COREDUMP_IDLE || |
| + state > MT7915_COREDUMP_AUTO) |
| + return; |
| + |
| + if (dev->dump_state != MT7915_COREDUMP_IDLE) |
| + return; |
| + |
| + dev->dump_state = state; |
| + dev_info(dev->mt76.dev, "%s attempting grab coredump\n", |
| + wiphy_name(dev->mt76.hw->wiphy)); |
| + |
| + queue_work(dev->mt76.wq, &dev->dump_work); |
| } |
| |
| void mt7915_reset(struct mt7915_dev *dev) |
| @@ -1747,7 +1771,7 @@ void mt7915_reset(struct mt7915_dev *dev) |
| wiphy_name(dev->mt76.hw->wiphy)); |
| |
| mt7915_irq_disable(dev, MT_INT_MCU_CMD); |
| - queue_work(dev->mt76.wq, &dev->dump_work); |
| + mt7915_coredump(dev, MT7915_COREDUMP_AUTO); |
| return; |
| } |
| |
| diff --git a/mt7915/mcu.h b/mt7915/mcu.h |
| index 286f7a5..583caca 100644 |
| --- a/mt7915/mcu.h |
| +++ b/mt7915/mcu.h |
| @@ -745,8 +745,12 @@ enum { |
| SER_SET_RECOVER_L3_TX_ABORT, |
| SER_SET_RECOVER_L3_TX_DISABLE, |
| SER_SET_RECOVER_L3_BF, |
| - SER_SET_RECOVER_FULL, |
| + SER_SET_RECOVER_FULL = 8, |
| + /* fw assert */ |
| SER_SET_SYSTEM_ASSERT, |
| + /* coredump */ |
| + SER_SET_FW_COREDUMP_WA, |
| + SER_SET_FW_COREDUMP_WM, |
| /* action */ |
| SER_ENABLE = 2, |
| SER_RECOVER |
| diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h |
| index b3bf8a2..8a5d5f9 100644 |
| --- a/mt7915/mt7915.h |
| +++ b/mt7915/mt7915.h |
| @@ -91,6 +91,13 @@ struct mt7915_sta; |
| struct mt7915_dfs_pulse; |
| struct mt7915_dfs_pattern; |
| |
| +enum mt7915_coredump_state { |
| + MT7915_COREDUMP_IDLE = 0, |
| + MT7915_COREDUMP_MANUAL_WA, |
| + MT7915_COREDUMP_MANUAL_WM, |
| + MT7915_COREDUMP_AUTO, |
| +}; |
| + |
| enum mt7915_txq_id { |
| MT7915_TXQ_FWDL = 16, |
| MT7915_TXQ_MCU_WM, |
| @@ -337,6 +344,7 @@ struct mt7915_dev { |
| |
| /* protects coredump data */ |
| struct mutex dump_mutex; |
| + u8 dump_state; |
| #ifdef CONFIG_DEV_COREDUMP |
| struct { |
| struct mt7915_crash_data *crash_data[__MT76_RAM_TYPE_MAX]; |
| @@ -522,6 +530,7 @@ int mt7915_init_vif(struct mt7915_phy *phy, struct ieee80211_vif *vif, bool bf_e |
| void mt7915_init_txpower(struct mt7915_dev *dev, |
| struct ieee80211_supported_band *sband); |
| void mt7915_reset(struct mt7915_dev *dev); |
| +void mt7915_coredump(struct mt7915_dev *dev, u8 state); |
| int mt7915_run(struct ieee80211_hw *hw); |
| int mt7915_mcu_init(struct mt7915_dev *dev); |
| int mt7915_mcu_init_firmware(struct mt7915_dev *dev); |
| -- |
| 2.18.0 |
| |