From: Leon Yen <Leon.Yen@xxxxxxxxxxxx> cleanup/reset chip fw before reboot to avoid unstable problems in next run. Co-developed-by: Deren Wu <deren.wu@xxxxxxxxxxxx> Signed-off-by: Deren Wu <deren.wu@xxxxxxxxxxxx> Signed-off-by: Leon Yen <Leon.Yen@xxxxxxxxxxxx> --- .../net/wireless/mediatek/mt76/mt7921/pci.c | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c index 28342ec940f0..4e9021c349b9 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c @@ -226,6 +226,25 @@ static u32 mt7921_rmw(struct mt76_dev *mdev, u32 offset, u32 mask, u32 val) return dev->bus_ops->rmw(mdev, addr, mask, val); } +static int mt7921e_reboot_notifier(struct notifier_block *nb, + unsigned long code, void *unused) +{ + struct mt76_dev *mdev = container_of(nb, struct mt76_dev, + reboot_nb); + struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76); + struct mt76_connac_pm *pm = &dev->pm; + + cancel_delayed_work_sync(&pm->ps_work); + cancel_work_sync(&pm->wake_work); + + /* chip cleanup before reboot */ + mt7921_mcu_drv_pmctrl(dev); + mt7921_dma_cleanup(dev); + mt7921_wfsys_reset(dev); + + return NOTIFY_DONE; +} + static int mt7921_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) { @@ -357,6 +376,8 @@ static int mt7921_pci_probe(struct pci_dev *pdev, if (ret) goto err_free_irq; + mdev->reboot_nb.notifier_call = mt7921e_reboot_notifier; + ret = mt7921_register_device(dev); if (ret) goto err_free_irq; -- 2.18.0