summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/mediatek
diff options
context:
space:
mode:
authorLorenzo Bianconi <lorenzo@kernel.org>2020-07-03 10:15:57 +0200
committerFelix Fietkau <nbd@nbd.name>2020-07-21 19:01:17 +0200
commit1f549009b5b2f26db01e334dc00db160ee12c0e1 (patch)
tree3df65039f40192fae9ca64756c166a30ed294746 /drivers/net/wireless/mediatek
parenta2b30bd4096e5c95a7fed72102de6fff2b138ff7 (diff)
mt76: mt7615: do not request {driver,fw}_own if already granted
Check MT76_STATE_PM in mt7615_driver_own/mt7615_firmware_own in order to not requested power ownership if it is already granted Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'drivers/net/wireless/mediatek')
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt7615/init.c1
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt7615/mcu.c21
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt7615/usb_mcu.c2
3 files changed, 14 insertions, 10 deletions
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/init.c b/drivers/net/wireless/mediatek/mt76/mt7615/init.c
index 02a82cd848c4..b3f0e2cae040 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/init.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/init.c
@@ -442,6 +442,7 @@ void mt7615_init_device(struct mt7615_dev *dev)
INIT_WORK(&dev->pm.wake_work, mt7615_pm_wake_work);
init_completion(&dev->pm.wake_cmpl);
spin_lock_init(&dev->pm.txq_lock);
+ set_bit(MT76_STATE_PM, &dev->mphy.state);
INIT_DELAYED_WORK(&dev->phy.mac_work, mt7615_mac_work);
INIT_DELAYED_WORK(&dev->phy.scan_work, mt7615_scan_work);
skb_queue_head_init(&dev->phy.scan_event_list);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
index 72cfc197b936..6118c2eeece8 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
@@ -1894,6 +1894,9 @@ int mt7615_driver_own(struct mt7615_dev *dev)
int err = 0;
u32 addr;
+ if (!test_and_clear_bit(MT76_STATE_PM, &mphy->state))
+ goto out;
+
mt7622_trigger_hif_int(dev, true);
addr = is_mt7663(mdev) ? MT_PCIE_DOORBELL_PUSH : MT_CFG_LPCR_HOST;
@@ -1901,15 +1904,13 @@ int mt7615_driver_own(struct mt7615_dev *dev)
addr = is_mt7663(mdev) ? MT_CONN_HIF_ON_LPCTL : MT_CFG_LPCR_HOST;
if (!mt76_poll_msec(dev, addr, MT_CFG_LPCR_HOST_FW_OWN, 0, 3000)) {
- dev_err(dev->mt76.dev, "Timeout for driver own\n");
+ dev_err(mdev->dev, "Timeout for driver own\n");
+ set_bit(MT76_STATE_PM, &mphy->state);
err = -EIO;
- goto out;
}
- clear_bit(MT76_STATE_PM, &mphy->state);
-
-out:
mt7622_trigger_hif_int(dev, false);
+out:
dev->pm.last_activity = jiffies;
return err;
@@ -1922,22 +1923,22 @@ int mt7615_firmware_own(struct mt7615_dev *dev)
int err = 0;
u32 addr;
- addr = is_mt7663(&dev->mt76) ? MT_CONN_HIF_ON_LPCTL : MT_CFG_LPCR_HOST;
+ if (test_and_set_bit(MT76_STATE_PM, &mphy->state))
+ return 0;
+
mt7622_trigger_hif_int(dev, true);
+ addr = is_mt7663(&dev->mt76) ? MT_CONN_HIF_ON_LPCTL : MT_CFG_LPCR_HOST;
mt76_wr(dev, addr, MT_CFG_LPCR_HOST_FW_OWN);
if (is_mt7622(&dev->mt76) &&
!mt76_poll_msec(dev, addr, MT_CFG_LPCR_HOST_FW_OWN,
MT_CFG_LPCR_HOST_FW_OWN, 300)) {
dev_err(dev->mt76.dev, "Timeout for firmware own\n");
+ clear_bit(MT76_STATE_PM, &mphy->state);
err = -EIO;
- goto out;
}
- set_bit(MT76_STATE_PM, &mphy->state);
-
-out:
mt7622_trigger_hif_int(dev, false);
return err;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/usb_mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/usb_mcu.c
index cd709fd617db..54885ad97891 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/usb_mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/usb_mcu.c
@@ -60,6 +60,8 @@ int mt7663u_mcu_init(struct mt7615_dev *dev)
dev->mt76.mcu_ops = &mt7663u_mcu_ops,
+ /* usb does not support runtime-pm */
+ clear_bit(MT76_STATE_PM, &dev->mphy.state);
mt76_set(dev, MT_UDMA_TX_QSEL, MT_FW_DL_EN);
if (test_and_clear_bit(MT76_STATE_POWER_OFF, &dev->mphy.state)) {