Commit d2bf7959 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt76: mt7663: introduce coredump support

Similar to mt7921 devices, introduce coredump support for mt7663 chipset
Co-developed-by: default avatarSean Wang <sean.wang@mediatek.com>
Signed-off-by: default avatarSean Wang <sean.wang@mediatek.com>
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 0da3c795
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
config MT7615_COMMON config MT7615_COMMON
tristate tristate
select WANT_DEV_COREDUMP
select MT76_CONNAC_LIB select MT76_CONNAC_LIB
config MT7615E config MT7615E
......
...@@ -21,6 +21,20 @@ mt7615_radar_pattern_set(void *data, u64 val) ...@@ -21,6 +21,20 @@ mt7615_radar_pattern_set(void *data, u64 val)
DEFINE_DEBUGFS_ATTRIBUTE(fops_radar_pattern, NULL, DEFINE_DEBUGFS_ATTRIBUTE(fops_radar_pattern, NULL,
mt7615_radar_pattern_set, "%lld\n"); mt7615_radar_pattern_set, "%lld\n");
static int mt7615_config(void *data, u64 val)
{
struct mt7615_dev *dev = data;
int ret;
mt7615_mutex_acquire(dev);
ret = mt76_connac_mcu_chip_config(&dev->mt76);
mt7615_mutex_release(dev);
return ret;
}
DEFINE_DEBUGFS_ATTRIBUTE(fops_config, NULL, mt7615_config, "%lld\n");
static int static int
mt7615_scs_set(void *data, u64 val) mt7615_scs_set(void *data, u64 val)
{ {
...@@ -525,6 +539,9 @@ int mt7615_init_debugfs(struct mt7615_dev *dev) ...@@ -525,6 +539,9 @@ int mt7615_init_debugfs(struct mt7615_dev *dev)
debugfs_create_u32("rf_regidx", 0600, dir, &dev->debugfs_rf_reg); debugfs_create_u32("rf_regidx", 0600, dir, &dev->debugfs_rf_reg);
debugfs_create_file_unsafe("rf_regval", 0600, dir, dev, debugfs_create_file_unsafe("rf_regval", 0600, dir, dev,
&fops_rf_reg); &fops_rf_reg);
if (is_mt7663(&dev->mt76))
debugfs_create_file("chip_config", 0600, dir, dev,
&fops_config);
if (mt76_is_sdio(&dev->mt76)) if (mt76_is_sdio(&dev->mt76))
debugfs_create_devm_seqfile(dev->mt76.dev, "sched-quota", dir, debugfs_create_devm_seqfile(dev->mt76.dev, "sched-quota", dir,
mt7663s_sched_quota_read); mt7663s_sched_quota_read);
......
...@@ -488,7 +488,9 @@ void mt7615_init_device(struct mt7615_dev *dev) ...@@ -488,7 +488,9 @@ void mt7615_init_device(struct mt7615_dev *dev)
set_bit(MT76_STATE_PM, &dev->mphy.state); set_bit(MT76_STATE_PM, &dev->mphy.state);
INIT_DELAYED_WORK(&dev->mphy.mac_work, mt7615_mac_work); INIT_DELAYED_WORK(&dev->mphy.mac_work, mt7615_mac_work);
INIT_DELAYED_WORK(&dev->phy.scan_work, mt7615_scan_work); INIT_DELAYED_WORK(&dev->phy.scan_work, mt7615_scan_work);
INIT_DELAYED_WORK(&dev->coredump.work, mt7615_coredump_work);
skb_queue_head_init(&dev->phy.scan_event_list); skb_queue_head_init(&dev->phy.scan_event_list);
skb_queue_head_init(&dev->coredump.msg_list);
INIT_LIST_HEAD(&dev->sta_poll_list); INIT_LIST_HEAD(&dev->sta_poll_list);
spin_lock_init(&dev->sta_poll_lock); spin_lock_init(&dev->sta_poll_lock);
init_waitqueue_head(&dev->reset_wait); init_waitqueue_head(&dev->reset_wait);
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
* Lorenzo Bianconi <lorenzo@kernel.org> * Lorenzo Bianconi <lorenzo@kernel.org>
*/ */
#include <linux/devcoredump.h>
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/timekeeping.h> #include <linux/timekeeping.h>
#include "mt7615.h" #include "mt7615.h"
...@@ -14,6 +15,7 @@ ...@@ -14,6 +15,7 @@
#include "../dma.h" #include "../dma.h"
#include "mt7615_trace.h" #include "mt7615_trace.h"
#include "mac.h" #include "mac.h"
#include "mcu.h"
#define to_rssi(field, rxv) ((FIELD_GET(field, rxv) - 220) / 2) #define to_rssi(field, rxv) ((FIELD_GET(field, rxv) - 220) / 2)
...@@ -2272,3 +2274,44 @@ int mt7615_mac_set_beacon_filter(struct mt7615_phy *phy, ...@@ -2272,3 +2274,44 @@ int mt7615_mac_set_beacon_filter(struct mt7615_phy *phy,
return 0; return 0;
} }
void mt7615_coredump_work(struct work_struct *work)
{
struct mt7615_dev *dev;
char *dump, *data;
dev = (struct mt7615_dev *)container_of(work, struct mt7615_dev,
coredump.work.work);
if (time_is_after_jiffies(dev->coredump.last_activity +
4 * MT76_CONNAC_COREDUMP_TIMEOUT)) {
queue_delayed_work(dev->mt76.wq, &dev->coredump.work,
MT76_CONNAC_COREDUMP_TIMEOUT);
return;
}
dump = vzalloc(MT76_CONNAC_COREDUMP_SZ);
data = dump;
while (true) {
struct sk_buff *skb;
spin_lock_bh(&dev->mt76.lock);
skb = __skb_dequeue(&dev->coredump.msg_list);
spin_unlock_bh(&dev->mt76.lock);
if (!skb)
break;
skb_pull(skb, sizeof(struct mt7615_mcu_rxd));
if (data + skb->len - dump > MT76_CONNAC_COREDUMP_SZ)
break;
memcpy(data, skb->data, skb->len);
data += skb->len;
dev_kfree_skb(skb);
}
dev_coredumpv(dev->mt76.dev, dump, MT76_CONNAC_COREDUMP_SZ,
GFP_KERNEL);
}
...@@ -543,6 +543,10 @@ mt7615_mcu_rx_unsolicited_event(struct mt7615_dev *dev, struct sk_buff *skb) ...@@ -543,6 +543,10 @@ mt7615_mcu_rx_unsolicited_event(struct mt7615_dev *dev, struct sk_buff *skb)
case MCU_EVENT_BSS_ABSENCE: case MCU_EVENT_BSS_ABSENCE:
mt7615_mcu_bss_event(dev, skb); mt7615_mcu_bss_event(dev, skb);
break; break;
case MCU_EVENT_COREDUMP:
mt76_connac_mcu_coredump_event(&dev->mt76, skb,
&dev->coredump);
return;
default: default:
break; break;
} }
...@@ -561,6 +565,7 @@ void mt7615_mcu_rx_event(struct mt7615_dev *dev, struct sk_buff *skb) ...@@ -561,6 +565,7 @@ void mt7615_mcu_rx_event(struct mt7615_dev *dev, struct sk_buff *skb)
rxd->eid == MCU_EVENT_SCHED_SCAN_DONE || rxd->eid == MCU_EVENT_SCHED_SCAN_DONE ||
rxd->eid == MCU_EVENT_BSS_ABSENCE || rxd->eid == MCU_EVENT_BSS_ABSENCE ||
rxd->eid == MCU_EVENT_SCAN_DONE || rxd->eid == MCU_EVENT_SCAN_DONE ||
rxd->eid == MCU_EVENT_COREDUMP ||
rxd->eid == MCU_EVENT_ROC || rxd->eid == MCU_EVENT_ROC ||
!rxd->seq) !rxd->seq)
mt7615_mcu_rx_unsolicited_event(dev, skb); mt7615_mcu_rx_unsolicited_event(dev, skb);
......
...@@ -92,6 +92,7 @@ enum { ...@@ -92,6 +92,7 @@ enum {
MCU_EVENT_SCHED_SCAN_DONE = 0x23, MCU_EVENT_SCHED_SCAN_DONE = 0x23,
MCU_EVENT_EXT = 0xed, MCU_EVENT_EXT = 0xed,
MCU_EVENT_RESTART_DL = 0xef, MCU_EVENT_RESTART_DL = 0xef,
MCU_EVENT_COREDUMP = 0xf0,
}; };
/* ext event table */ /* ext event table */
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/ktime.h> #include <linux/ktime.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include "../mt76_connac.h" #include "../mt76_connac_mcu.h"
#include "regs.h" #include "regs.h"
#define MT7615_MAX_INTERFACES 16 #define MT7615_MAX_INTERFACES 16
...@@ -277,6 +277,7 @@ struct mt7615_dev { ...@@ -277,6 +277,7 @@ struct mt7615_dev {
u32 muar_mask; u32 muar_mask;
struct mt76_connac_pm pm; struct mt76_connac_pm pm;
struct mt76_connac_coredump coredump;
}; };
enum tx_pkt_queue_idx { enum tx_pkt_queue_idx {
...@@ -554,6 +555,7 @@ int mt7615_mcu_update_arp_filter(struct ieee80211_hw *hw, ...@@ -554,6 +555,7 @@ int mt7615_mcu_update_arp_filter(struct ieee80211_hw *hw,
int __mt7663_load_firmware(struct mt7615_dev *dev); int __mt7663_load_firmware(struct mt7615_dev *dev);
u32 mt7615_mcu_reg_rr(struct mt76_dev *dev, u32 offset); u32 mt7615_mcu_reg_rr(struct mt76_dev *dev, u32 offset);
void mt7615_mcu_reg_wr(struct mt76_dev *dev, u32 offset, u32 val); void mt7615_mcu_reg_wr(struct mt76_dev *dev, u32 offset, u32 val);
void mt7615_coredump_work(struct work_struct *work);
/* usb */ /* usb */
int mt7663_usb_sdio_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, int mt7663_usb_sdio_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment