Skip to content

Commit

Permalink
mt76: mt7615: do not set MT76_STATE_PM at bootstrap
Browse files Browse the repository at this point in the history
Remove MT76_STATE_PM in mt7615_init_device() and introduce
__mt7663s_mcu_drv_pmctrl for fw loading in mt7663s.
This patch fixes a crash at bootstrap for device (e.g. mt7622) that do
not support runtime-pm

Fixes: 7f2bc8b ("mt76: connac: introduce wake counter for fw_pmctrl synchronization")
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
Link: https://lore.kernel.org/r/e5a2618574007113d844874420f7855891abf167.1621085028.git.lorenzo@kernel.org
  • Loading branch information
LorenzoBianconi authored and Kalle Valo committed May 30, 2021
1 parent 2c2bdd2 commit 02de318
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
1 change: 0 additions & 1 deletion drivers/net/wireless/mediatek/mt76/mt7615/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,6 @@ void mt7615_init_device(struct mt7615_dev *dev)
mutex_init(&dev->pm.mutex);
init_waitqueue_head(&dev->pm.wait);
spin_lock_init(&dev->pm.txq_lock);
set_bit(MT76_STATE_PM, &dev->mphy.state);
INIT_DELAYED_WORK(&dev->mphy.mac_work, mt7615_mac_work);
INIT_DELAYED_WORK(&dev->phy.scan_work, mt7615_scan_work);
INIT_DELAYED_WORK(&dev->coredump.work, mt7615_coredump_work);
Expand Down
19 changes: 12 additions & 7 deletions drivers/net/wireless/mediatek/mt76/mt7615/sdio_mcu.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,13 @@ mt7663s_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb,
return ret;
}

static int mt7663s_mcu_drv_pmctrl(struct mt7615_dev *dev)
static int __mt7663s_mcu_drv_pmctrl(struct mt7615_dev *dev)
{
struct sdio_func *func = dev->mt76.sdio.func;
struct mt76_phy *mphy = &dev->mt76.phy;
u32 status;
int ret;

if (!test_and_clear_bit(MT76_STATE_PM, &mphy->state))
goto out;

sdio_claim_host(func);

sdio_writel(func, WHLPCR_FW_OWN_REQ_CLR, MCR_WHLPCR, NULL);
Expand All @@ -76,13 +73,21 @@ static int mt7663s_mcu_drv_pmctrl(struct mt7615_dev *dev)
}

sdio_release_host(func);

out:
dev->pm.last_activity = jiffies;

return 0;
}

static int mt7663s_mcu_drv_pmctrl(struct mt7615_dev *dev)
{
struct mt76_phy *mphy = &dev->mt76.phy;

if (test_and_clear_bit(MT76_STATE_PM, &mphy->state))
return __mt7663s_mcu_drv_pmctrl(dev);

return 0;
}

static int mt7663s_mcu_fw_pmctrl(struct mt7615_dev *dev)
{
struct sdio_func *func = dev->mt76.sdio.func;
Expand Down Expand Up @@ -123,7 +128,7 @@ int mt7663s_mcu_init(struct mt7615_dev *dev)
struct mt7615_mcu_ops *mcu_ops;
int ret;

ret = mt7663s_mcu_drv_pmctrl(dev);
ret = __mt7663s_mcu_drv_pmctrl(dev);
if (ret)
return ret;

Expand Down
3 changes: 0 additions & 3 deletions drivers/net/wireless/mediatek/mt76/mt7615/usb_mcu.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ 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)) {
mt7615_mcu_restart(&dev->mt76);
if (!mt76_poll_msec(dev, MT_CONN_ON_MISC,
Expand Down

0 comments on commit 02de318

Please sign in to comment.