]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
mt76: mt7615: fix a leftover race in runtime-pm
authorLorenzo Bianconi <lorenzo@kernel.org>
Thu, 30 Dec 2021 20:47:06 +0000 (21:47 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Apr 2022 11:58:02 +0000 (13:58 +0200)
[ Upstream commit 42ce8d3b623162f3248db50a38359f294e6b06fd ]

Fix a possible race in mt7615_pm_power_save_work() if rx/tx napi
schedules ps_work and we are currently accessing device register
on a different cpu.

Fixes: db928f1ab9789 ("mt76: mt7663: rely on mt76_connac_pm_ref/mt76_connac_pm_unref in tx/rx napi")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/wireless/mediatek/mt76/mt7615/mac.c

index ec25e5a95d442c3da6c08aca58795b1b0a767ca6..6d0ff5af8fec98136404820bc8b0a6bc33fa36e7 100644 (file)
@@ -2103,6 +2103,14 @@ void mt7615_pm_power_save_work(struct work_struct *work)
            test_bit(MT76_HW_SCHED_SCANNING, &dev->mphy.state))
                goto out;
 
+       if (mutex_is_locked(&dev->mt76.mutex))
+               /* if mt76 mutex is held we should not put the device
+                * to sleep since we are currently accessing device
+                * register map. We need to wait for the next power_save
+                * trigger.
+                */
+               goto out;
+
        if (time_is_after_jiffies(dev->pm.last_activity + delta)) {
                delta = dev->pm.last_activity + delta - jiffies;
                goto out;