summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/mediatek
diff options
context:
space:
mode:
authorLorenzo Bianconi <lorenzo@kernel.org>2020-07-03 10:16:01 +0200
committerFelix Fietkau <nbd@nbd.name>2020-07-21 19:01:17 +0200
commit894b7767ec2fc21574775c354ab5350e51c2171c (patch)
tree9bbb9684f1dec1a867aa3a7e4e29e8f6cfba237c /drivers/net/wireless/mediatek
parentec4b9f380c15933e3dea72bb4723ea5e21d35b13 (diff)
mt76: mt7615: improve mt7615_driver_own reliability
mt7615_driver_own can fail if it runs too close to mt7615_fw_own. In order to improve mt7615_driver_own reliability, retry to get runtime-pm ownership if mt7615_driver_own fails Co-developed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> 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/mcu.c27
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h2
2 files changed, 19 insertions, 10 deletions
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
index 2d1015451699..2e9e0002331e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
@@ -1891,29 +1891,36 @@ int mt7615_driver_own(struct mt7615_dev *dev)
{
struct mt76_phy *mphy = &dev->mt76.phy;
struct mt76_dev *mdev = &dev->mt76;
- int err = 0;
- u32 addr;
+ int i;
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;
- mt76_wr(dev, addr, MT_CFG_LPCR_HOST_DRV_OWN);
+ for (i = 0; i < MT7615_DRV_OWN_RETRY_COUNT; i++) {
+ u32 addr;
- 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(mdev->dev, "Timeout for driver own\n");
- set_bit(MT76_STATE_PM, &mphy->state);
- err = -EIO;
+ addr = is_mt7663(mdev) ? MT_PCIE_DOORBELL_PUSH : MT_CFG_LPCR_HOST;
+ mt76_wr(dev, addr, MT_CFG_LPCR_HOST_DRV_OWN);
+
+ 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, 50))
+ break;
}
mt7622_trigger_hif_int(dev, false);
+
+ if (i == MT7615_DRV_OWN_RETRY_COUNT) {
+ dev_err(mdev->dev, "driver own failed\n");
+ set_bit(MT76_STATE_PM, &mphy->state);
+ return -EIO;
+ }
+
out:
dev->pm.last_activity = jiffies;
- return err;
+ return 0;
}
EXPORT_SYMBOL_GPL(mt7615_driver_own);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h b/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h
index 9f258270c435..688bd7b68668 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h
@@ -33,6 +33,8 @@
#define MT7615_RX_RING_SIZE 1024
#define MT7615_RX_MCU_RING_SIZE 512
+#define MT7615_DRV_OWN_RETRY_COUNT 10
+
#define MT7615_FIRMWARE_CR4 "mediatek/mt7615_cr4.bin"
#define MT7615_FIRMWARE_N9 "mediatek/mt7615_n9.bin"
#define MT7615_ROM_PATCH "mediatek/mt7615_rom_patch.bin"