wifi: mt76: mt7925: add handler to hif suspend/resume event

When the system suspend or resume, the WiFi driver sends
an hif_ctrl command to the firmware and waits for an event.
Due to changes in the event format reported by the chip, the
current mt7925's driver does not account for these changes,
resulting in command timeout. Add flow to handle hif_ctrl
event to avoid command timeout. We also exented API
mt76_connac_mcu_set_hif_suspend for connac3 this time.

Signed-off-by: Quan Zhou <[email protected]>
Link: https://patch.msgid.link/3a0844ff5162142c4a9f3cf7104f75076ddd3b87.1735910562.git.quan.zhou@mediatek.com
Signed-off-by: Felix Fietkau <[email protected]>
This commit is contained in:
Quan Zhou
2025-01-13 11:16:33 +01:00
committed by Felix Fietkau
parent d33ea3cab7
commit 5aacd0d73c
14 changed files with 127 additions and 34 deletions
+21 -8
View File
@@ -442,9 +442,10 @@ static int mt7925_pci_suspend(struct device *device)
struct mt76_dev *mdev = pci_get_drvdata(pdev);
struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76);
struct mt76_connac_pm *pm = &dev->pm;
int i, err;
int i, err, ret;
pm->suspended = true;
dev->hif_resumed = false;
flush_work(&dev->reset_work);
cancel_delayed_work_sync(&pm->ps_work);
cancel_work_sync(&pm->wake_work);
@@ -463,9 +464,13 @@ static int mt7925_pci_suspend(struct device *device)
*/
mt7925_mcu_set_deep_sleep(dev, true);
err = mt76_connac_mcu_set_hif_suspend(mdev, true);
if (err)
mt76_connac_mcu_set_hif_suspend(mdev, true, false);
ret = wait_event_timeout(dev->wait,
dev->hif_idle, 3 * HZ);
if (!ret) {
err = -ETIMEDOUT;
goto restore_suspend;
}
napi_disable(&mdev->tx_napi);
mt76_worker_disable(&mdev->tx_worker);
@@ -509,8 +514,11 @@ restore_napi:
if (!pm->ds_enable)
mt7925_mcu_set_deep_sleep(dev, false);
mt76_connac_mcu_set_hif_suspend(mdev, false);
mt76_connac_mcu_set_hif_suspend(mdev, false, false);
ret = wait_event_timeout(dev->wait,
dev->hif_resumed, 3 * HZ);
if (!ret)
err = -ETIMEDOUT;
restore_suspend:
pm->suspended = false;
@@ -526,8 +534,9 @@ static int mt7925_pci_resume(struct device *device)
struct mt76_dev *mdev = pci_get_drvdata(pdev);
struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76);
struct mt76_connac_pm *pm = &dev->pm;
int i, err;
int i, err, ret;
dev->hif_idle = false;
err = mt792x_mcu_drv_pmctrl(dev);
if (err < 0)
goto failed;
@@ -556,9 +565,13 @@ static int mt7925_pci_resume(struct device *device)
napi_schedule(&mdev->tx_napi);
local_bh_enable();
err = mt76_connac_mcu_set_hif_suspend(mdev, false);
if (err < 0)
mt76_connac_mcu_set_hif_suspend(mdev, false, false);
ret = wait_event_timeout(dev->wait,
dev->hif_resumed, 3 * HZ);
if (!ret) {
err = -ETIMEDOUT;
goto failed;
}
/* restore previous ds setting */
if (!pm->ds_enable)