]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
wifi: mt76: mt7925: add pci restore for hibernate
authorJack Kao <jack.kao@mediatek.com>
Mon, 1 Sep 2025 07:32:00 +0000 (15:32 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Nov 2025 20:37:22 +0000 (15:37 -0500)
[ Upstream commit d54424fbc53b4d6be00f90a8b529cd368f20d357 ]

Due to hibernation causing a power off and power on,
this modification adds mt7925_pci_restore callback function for kernel.
When hibernation resumes, it calls mt7925_pci_restore to reset the device,
allowing it to return to the state it was in before the power off.

Signed-off-by: Jack Kao <jack.kao@mediatek.com>
Signed-off-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com>
Link: https://patch.msgid.link/20250901073200.230033-1-mingyen.hsieh@mediatek.com
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/wireless/mediatek/mt76/mt7925/pci.c

index 89dc30f7c6b7a298e0c23bf6f45edca29fa261ac..8eb1fe1082d155fa275685667abe9bc6bae7db74 100644 (file)
@@ -529,7 +529,7 @@ restore_suspend:
        return err;
 }
 
-static int mt7925_pci_resume(struct device *device)
+static int _mt7925_pci_resume(struct device *device, bool restore)
 {
        struct pci_dev *pdev = to_pci_dev(device);
        struct mt76_dev *mdev = pci_get_drvdata(pdev);
@@ -569,6 +569,9 @@ static int mt7925_pci_resume(struct device *device)
        napi_schedule(&mdev->tx_napi);
        local_bh_enable();
 
+       if (restore)
+               goto failed;
+
        mt76_connac_mcu_set_hif_suspend(mdev, false, false);
        ret = wait_event_timeout(dev->wait,
                                 dev->hif_resumed, 3 * HZ);
@@ -585,7 +588,7 @@ static int mt7925_pci_resume(struct device *device)
 failed:
        pm->suspended = false;
 
-       if (err < 0)
+       if (err < 0 || restore)
                mt792x_reset(&dev->mt76);
 
        return err;
@@ -596,7 +599,24 @@ static void mt7925_pci_shutdown(struct pci_dev *pdev)
        mt7925_pci_remove(pdev);
 }
 
-static DEFINE_SIMPLE_DEV_PM_OPS(mt7925_pm_ops, mt7925_pci_suspend, mt7925_pci_resume);
+static int mt7925_pci_resume(struct device *device)
+{
+       return _mt7925_pci_resume(device, false);
+}
+
+static int mt7925_pci_restore(struct device *device)
+{
+       return _mt7925_pci_resume(device, true);
+}
+
+static const struct dev_pm_ops mt7925_pm_ops = {
+       .suspend = pm_sleep_ptr(mt7925_pci_suspend),
+       .resume  = pm_sleep_ptr(mt7925_pci_resume),
+       .freeze = pm_sleep_ptr(mt7925_pci_suspend),
+       .thaw = pm_sleep_ptr(mt7925_pci_resume),
+       .poweroff = pm_sleep_ptr(mt7925_pci_suspend),
+       .restore = pm_sleep_ptr(mt7925_pci_restore),
+};
 
 static struct pci_driver mt7925_pci_driver = {
        .name           = KBUILD_MODNAME,