Some combinations of hosts cannnot detect wifi chip after reboot. The interoperability issue is caused by the status mismatch between host and chip fw. In such cases, the driver should stop chip activities and reset chip to default state before reboot. This is a preliminary patch to add mt7921e reboot notifier support. Reviewed-by: Shayne Chen <shayne.chen@xxxxxxxxxxxx> Signed-off-by: Deren Wu <deren.wu@xxxxxxxxxxxx> --- drivers/net/wireless/mediatek/mt76/mac80211.c | 21 +++++++++++++++++++ drivers/net/wireless/mediatek/mt76/mt76.h | 2 ++ 2 files changed, 23 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c index fc608b369b3c..a8515cb2527e 100644 --- a/drivers/net/wireless/mediatek/mt76/mac80211.c +++ b/drivers/net/wireless/mediatek/mt76/mac80211.c @@ -230,6 +230,22 @@ static void mt76_led_cleanup(struct mt76_dev *dev) led_classdev_unregister(&dev->led_cdev); } +static int mt76_notifier_init(struct mt76_dev *dev) +{ + if (!dev->reboot_nb.notifier_call) + return 0; + + return register_reboot_notifier(&dev->reboot_nb); +} + +static void mt76_notifier_cleanup(struct mt76_dev *dev) +{ + if (!dev->reboot_nb.notifier_call) + return; + + unregister_reboot_notifier(&dev->reboot_nb); +} + static void mt76_init_stream_cap(struct mt76_phy *phy, struct ieee80211_supported_band *sband, bool vht) @@ -658,6 +674,10 @@ int mt76_register_device(struct mt76_dev *dev, bool vht, return ret; } + ret = mt76_notifier_init(dev); + if (ret) + return ret; + ret = ieee80211_register_hw(hw); if (ret) return ret; @@ -675,6 +695,7 @@ void mt76_unregister_device(struct mt76_dev *dev) if (IS_ENABLED(CONFIG_MT76_LEDS)) mt76_led_cleanup(dev); + mt76_notifier_cleanup(dev); mt76_tx_status_check(dev, true); ieee80211_unregister_hw(hw); } diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index 32a77a0ae9da..73a504016288 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -13,6 +13,7 @@ #include <linux/leds.h> #include <linux/usb.h> #include <linux/average.h> +#include <linux/reboot.h> #include <linux/soc/mediatek/mtk_wed.h> #include <net/mac80211.h> #include "util.h" @@ -835,6 +836,7 @@ struct mt76_dev { struct mt76_usb usb; struct mt76_sdio sdio; }; + struct notifier_block reboot_nb; }; struct mt76_power_limits { -- 2.18.0