wifi: mt76: mt7925: add pci restore for hibernate
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>
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user