mirror of https://gitee.com/openkylin/linux.git
mt76x0: move mt76x0_init_hardware in mt76x0_register_device
Move mt76x0_init_hardware routine in mt76x0_register_device during hw probe. This is a preliminary patch to avoid {tx/rx} buffer allocation during resume/suspend Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
parent
b680d7fbfb
commit
e30a655ef1
|
@ -382,27 +382,21 @@ int mt76x0_init_hardware(struct mt76x0_dev *dev)
|
||||||
|
|
||||||
mt76x0_chip_onoff(dev, true, true);
|
mt76x0_chip_onoff(dev, true, true);
|
||||||
|
|
||||||
if (!mt76x02_wait_for_mac(&dev->mt76)) {
|
if (!mt76x02_wait_for_mac(&dev->mt76))
|
||||||
ret = -ETIMEDOUT;
|
return -ETIMEDOUT;
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = mt76x0_mcu_init(dev);
|
ret = mt76x0_mcu_init(dev);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err;
|
return ret;
|
||||||
|
|
||||||
if (!mt76_poll_msec(dev, MT_WPDMA_GLO_CFG,
|
if (!mt76_poll_msec(dev, MT_WPDMA_GLO_CFG,
|
||||||
MT_WPDMA_GLO_CFG_TX_DMA_BUSY |
|
MT_WPDMA_GLO_CFG_TX_DMA_BUSY |
|
||||||
MT_WPDMA_GLO_CFG_RX_DMA_BUSY, 0, 100)) {
|
MT_WPDMA_GLO_CFG_RX_DMA_BUSY, 0, 100))
|
||||||
ret = -EIO;
|
return -EIO;
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Wait for ASIC ready after FW load. */
|
/* Wait for ASIC ready after FW load. */
|
||||||
if (!mt76x02_wait_for_mac(&dev->mt76)) {
|
if (!mt76x02_wait_for_mac(&dev->mt76))
|
||||||
ret = -ETIMEDOUT;
|
return -ETIMEDOUT;
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
mt76x0_reset_csr_bbp(dev);
|
mt76x0_reset_csr_bbp(dev);
|
||||||
mt76x0_init_usb_dma(dev);
|
mt76x0_init_usb_dma(dev);
|
||||||
|
@ -412,33 +406,33 @@ int mt76x0_init_hardware(struct mt76x0_dev *dev)
|
||||||
|
|
||||||
ret = mt76x0_mcu_cmd_init(dev);
|
ret = mt76x0_mcu_cmd_init(dev);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err;
|
return ret;
|
||||||
|
|
||||||
ret = mt76u_alloc_queues(&dev->mt76);
|
ret = mt76u_alloc_queues(&dev->mt76);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto err_mcu;
|
return ret;
|
||||||
|
|
||||||
mt76x0_init_mac_registers(dev);
|
mt76x0_init_mac_registers(dev);
|
||||||
|
|
||||||
if (!mt76_poll_msec(dev, MT_MAC_STATUS,
|
if (!mt76_poll_msec(dev, MT_MAC_STATUS,
|
||||||
MT_MAC_STATUS_TX | MT_MAC_STATUS_RX, 0, 1000)) {
|
MT_MAC_STATUS_TX | MT_MAC_STATUS_RX, 0, 1000))
|
||||||
ret = -EIO;
|
return -EIO;
|
||||||
goto err_rx;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = mt76x0_init_bbp(dev);
|
ret = mt76x0_init_bbp(dev);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_rx;
|
return ret;
|
||||||
|
|
||||||
ret = mt76x0_init_wcid_mem(dev);
|
ret = mt76x0_init_wcid_mem(dev);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_rx;
|
return ret;
|
||||||
|
|
||||||
ret = mt76x0_init_key_mem(dev);
|
ret = mt76x0_init_key_mem(dev);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_rx;
|
return ret;
|
||||||
|
|
||||||
ret = mt76x0_init_wcid_attr_mem(dev);
|
ret = mt76x0_init_wcid_attr_mem(dev);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_rx;
|
return ret;
|
||||||
|
|
||||||
mt76_clear(dev, MT_BEACON_TIME_CFG, (MT_BEACON_TIME_CFG_TIMER_EN |
|
mt76_clear(dev, MT_BEACON_TIME_CFG, (MT_BEACON_TIME_CFG_TIMER_EN |
|
||||||
MT_BEACON_TIME_CFG_SYNC_MODE |
|
MT_BEACON_TIME_CFG_SYNC_MODE |
|
||||||
|
@ -455,18 +449,11 @@ int mt76x0_init_hardware(struct mt76x0_dev *dev)
|
||||||
|
|
||||||
ret = mt76x0_eeprom_init(dev);
|
ret = mt76x0_eeprom_init(dev);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_rx;
|
return ret;
|
||||||
|
|
||||||
mt76x0_phy_init(dev);
|
mt76x0_phy_init(dev);
|
||||||
return 0;
|
|
||||||
|
|
||||||
err_rx:
|
return 0;
|
||||||
mt76u_queues_deinit(&dev->mt76);
|
|
||||||
err_mcu:
|
|
||||||
mt76u_mcu_deinit(&dev->mt76);
|
|
||||||
err:
|
|
||||||
mt76x0_chip_onoff(dev, false, false);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mt76x0_cleanup(struct mt76x0_dev *dev)
|
void mt76x0_cleanup(struct mt76x0_dev *dev)
|
||||||
|
@ -627,6 +614,10 @@ int mt76x0_register_device(struct mt76x0_dev *dev)
|
||||||
struct wiphy *wiphy = hw->wiphy;
|
struct wiphy *wiphy = hw->wiphy;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
ret = mt76x0_init_hardware(dev);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
/* Reserve WCID 0 for mcast - thanks to this APs WCID will go to
|
/* Reserve WCID 0 for mcast - thanks to this APs WCID will go to
|
||||||
* entry no. 1 like it does in the vendor driver.
|
* entry no. 1 like it does in the vendor driver.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -90,10 +90,6 @@ static int mt76x0_probe(struct usb_interface *usb_intf,
|
||||||
if (!(mt76_rr(dev, MT_EFUSE_CTRL) & MT_EFUSE_CTRL_SEL))
|
if (!(mt76_rr(dev, MT_EFUSE_CTRL) & MT_EFUSE_CTRL_SEL))
|
||||||
dev_warn(dev->mt76.dev, "Warning: eFUSE not present\n");
|
dev_warn(dev->mt76.dev, "Warning: eFUSE not present\n");
|
||||||
|
|
||||||
ret = mt76x0_init_hardware(dev);
|
|
||||||
if (ret)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
ret = mt76x0_register_device(dev);
|
ret = mt76x0_register_device(dev);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_hw;
|
goto err_hw;
|
||||||
|
@ -143,8 +139,10 @@ static int mt76x0_resume(struct usb_interface *usb_intf)
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = mt76x0_init_hardware(dev);
|
ret = mt76x0_init_hardware(dev);
|
||||||
if (ret)
|
if (ret) {
|
||||||
|
mt76x0_cleanup(dev);
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
set_bit(MT76_STATE_INITIALIZED, &dev->mt76.state);
|
set_bit(MT76_STATE_INITIALIZED, &dev->mt76.state);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue