Commit 6f15ed16 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt76x0: do not free/alloc buffers during suspend/resume

Do not free/alloc {tx,rx} buffers during suspend/resume phases
but use the ones previously allocated during hw probe.
Move {tx,rx}/mcu buffers allocation from mt76x0_init_hardware routine
to mt76x0_register_device
Signed-off-by: default avatarLorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: default avatarStanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent e30a655e
......@@ -408,10 +408,6 @@ int mt76x0_init_hardware(struct mt76x0_dev *dev)
if (ret)
return ret;
ret = mt76u_alloc_queues(&dev->mt76);
if (ret < 0)
return ret;
mt76x0_init_mac_registers(dev);
if (!mt76_poll_msec(dev, MT_MAC_STATUS,
......@@ -614,6 +610,14 @@ int mt76x0_register_device(struct mt76x0_dev *dev)
struct wiphy *wiphy = hw->wiphy;
int ret;
ret = mt76u_mcu_init_rx(mdev);
if (ret < 0)
return ret;
ret = mt76u_alloc_queues(mdev);
if (ret < 0)
return ret;
ret = mt76x0_init_hardware(dev);
if (ret)
return ret;
......
......@@ -387,11 +387,5 @@ int mt76x0_mcu_init(struct mt76x0_dev *dev)
int mt76x0_mcu_cmd_init(struct mt76x0_dev *dev)
{
int ret;
ret = mt76u_mcu_init_rx(&dev->mt76);
if (ret)
return ret;
return mt76x0_mcu_function_select(dev, Q_SELECT, 1);
}
......@@ -124,29 +124,49 @@ static void mt76x0_disconnect(struct usb_interface *usb_intf)
ieee80211_free_hw(dev->mt76.hw);
}
static int mt76x0_suspend(struct usb_interface *usb_intf, pm_message_t state)
static int __maybe_unused mt76x0_suspend(struct usb_interface *usb_intf,
pm_message_t state)
{
struct mt76x0_dev *dev = usb_get_intfdata(usb_intf);
struct mt76_usb *usb = &dev->mt76.usb;
mt76x0_cleanup(dev);
mt76u_stop_queues(&dev->mt76);
mt76x0_mac_stop(dev);
usb_kill_urb(usb->mcu.res.urb);
return 0;
}
static int mt76x0_resume(struct usb_interface *usb_intf)
static int __maybe_unused mt76x0_resume(struct usb_interface *usb_intf)
{
struct mt76x0_dev *dev = usb_get_intfdata(usb_intf);
struct mt76_usb *usb = &dev->mt76.usb;
int ret;
ret = mt76x0_init_hardware(dev);
if (ret) {
mt76x0_cleanup(dev);
return ret;
}
reinit_completion(&usb->mcu.cmpl);
ret = mt76u_submit_buf(&dev->mt76, USB_DIR_IN,
MT_EP_IN_CMD_RESP,
&usb->mcu.res, GFP_KERNEL,
mt76u_mcu_complete_urb,
&usb->mcu.cmpl);
if (ret < 0)
goto err;
set_bit(MT76_STATE_INITIALIZED, &dev->mt76.state);
ret = mt76u_submit_rx_buffers(&dev->mt76);
if (ret < 0)
goto err;
tasklet_enable(&usb->rx_tasklet);
tasklet_enable(&usb->tx_tasklet);
ret = mt76x0_init_hardware(dev);
if (ret)
goto err;
return 0;
err:
mt76x0_cleanup(dev);
return ret;
}
MODULE_DEVICE_TABLE(usb, mt76x0_device_table);
......
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