Commit 894b7767 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

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: default avatarSean Wang <sean.wang@mediatek.com>
Signed-off-by: default avatarSean Wang <sean.wang@mediatek.com>
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent ec4b9f38
...@@ -1891,29 +1891,36 @@ int mt7615_driver_own(struct mt7615_dev *dev) ...@@ -1891,29 +1891,36 @@ int mt7615_driver_own(struct mt7615_dev *dev)
{ {
struct mt76_phy *mphy = &dev->mt76.phy; struct mt76_phy *mphy = &dev->mt76.phy;
struct mt76_dev *mdev = &dev->mt76; struct mt76_dev *mdev = &dev->mt76;
int err = 0; int i;
u32 addr;
if (!test_and_clear_bit(MT76_STATE_PM, &mphy->state)) if (!test_and_clear_bit(MT76_STATE_PM, &mphy->state))
goto out; goto out;
mt7622_trigger_hif_int(dev, true); mt7622_trigger_hif_int(dev, true);
for (i = 0; i < MT7615_DRV_OWN_RETRY_COUNT; i++) {
u32 addr;
addr = is_mt7663(mdev) ? MT_PCIE_DOORBELL_PUSH : MT_CFG_LPCR_HOST; addr = is_mt7663(mdev) ? MT_PCIE_DOORBELL_PUSH : MT_CFG_LPCR_HOST;
mt76_wr(dev, addr, MT_CFG_LPCR_HOST_DRV_OWN); mt76_wr(dev, addr, MT_CFG_LPCR_HOST_DRV_OWN);
addr = is_mt7663(mdev) ? MT_CONN_HIF_ON_LPCTL : MT_CFG_LPCR_HOST; 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)) { if (mt76_poll_msec(dev, addr, MT_CFG_LPCR_HOST_FW_OWN, 0, 50))
dev_err(mdev->dev, "Timeout for driver own\n"); break;
set_bit(MT76_STATE_PM, &mphy->state);
err = -EIO;
} }
mt7622_trigger_hif_int(dev, false); 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: out:
dev->pm.last_activity = jiffies; dev->pm.last_activity = jiffies;
return err; return 0;
} }
EXPORT_SYMBOL_GPL(mt7615_driver_own); EXPORT_SYMBOL_GPL(mt7615_driver_own);
......
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
#define MT7615_RX_RING_SIZE 1024 #define MT7615_RX_RING_SIZE 1024
#define MT7615_RX_MCU_RING_SIZE 512 #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_CR4 "mediatek/mt7615_cr4.bin"
#define MT7615_FIRMWARE_N9 "mediatek/mt7615_n9.bin" #define MT7615_FIRMWARE_N9 "mediatek/mt7615_n9.bin"
#define MT7615_ROM_PATCH "mediatek/mt7615_rom_patch.bin" #define MT7615_ROM_PATCH "mediatek/mt7615_rom_patch.bin"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment