mt76: mt7921e: fix race issue between reset and suspend/resume
From: Sean Wang <[email protected]>
Quoted 4 lines
Quoted 4 lines
From: Sean Wang <[email protected]>
It is unexpected that the reset work is running simultaneously with the suspend or resume context and it is possible that reset work is
<snip>
Quoted 8 lines
Review static int mt7921_pci_suspend(struct device *device) · line 366
Quoted 5 lines
(quoted diff) +1
-0@@ -363,6 +363,7 @@ static int mt7921_pci_suspend(struct device *device) int i, err; pm->suspended = true; + cancel_work_sync(&dev->reset_work);should we just wait for the reset to complete here instead of cancelling? (e.g.
flush_work)
yes, that seemed look better to me. It would wait until the queued reset request finishes.
Quoted 48 lines
Regards,
LorenzoQuoted 43 lines
(quoted diff) +8
-5cancel_delayed_work_sync(&pm->ps_work); cancel_work_sync(&pm->wake_work);@@ -424,6 +425,9 @@ static int mt7921_pci_suspend(struct device *device) restore_suspend: pm->suspended = false; + if (err < 0) + mt7921_reset(&dev->mt76); + return err; }@@ -437,7 +441,7 @@ static int mt7921_pci_resume(struct device *device) err = mt7921_mcu_drv_pmctrl(dev); if (err < 0) - return err; + goto failed; mt7921_wpdma_reinit_cond(dev);@@ -467,11 +471,12 @@ static int mt7921_pci_resume(struct device *device) mt76_connac_mcu_set_deep_sleep(&dev->mt76, false); err = mt76_connac_mcu_set_hif_suspend(mdev, false); - if (err) - return err; - +failed: pm->suspended = false; + if (err < 0) + mt7921_reset(&dev->mt76); + return err; } --2.25.1