mirror of
https://github.com/outbackdingo/mt76.git
synced 2026-10-24 21:36:52 +00:00
Disabling tasklets on stopping rx/tx is wrong. If blocked tasklet
is scheduled and we remove device we will get 100% cpu usage:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
9 root 20 0 0 0 0 R 93.8 0.0 1:47.19 ksoftirqd/0
by infinite loop in tasklet_action_common() and eventuall crash on next
mt76usb module load:
[ 2068.591964] RIP: 0010:tasklet_action_common.isra.17+0x66/0x100
[ 2068.591966] Code: 41 89 f5 eb 25 f0 48 0f ba 33 00 0f 83 b1 00 00 00 48 8b 7a 20 48 8b 42 18 e8 56 a3 b5 00 f0 80 23 fd 48 89 ea 48 85 ed 74 53 <48> 8b 2a 48 8d 5a 08 f0 48 0f ba 6a 08 01 72 0b 8b 42 10 85 c0 74
[ 2068.591968] RSP: 0018:ffff98758c34be58 EFLAGS: 00010206
[ 2068.591969] RAX: ffff98758e6966d0 RBX: ffff98756e69aef8 RCX: 0000000000000006
[ 2068.591970] RDX: 01060a053d060305 RSI: 0000000000000006 RDI: ffff98758e6966d0
[ 2068.591971] RBP: 01060a053d060305 R08: 0000000000000000 R09: 00000000000203c0
[ 2068.591971] R10: 000003ff65b34f08 R11: 0000000000000001 R12: ffff98758e6966d0
[ 2068.591972] R13: 0000000000000006 R14: 0000000000000040 R15: 0000000000000006
[ 2068.591974] FS: 0000000000000000(0000) GS:ffff98758e680000(0000) knlGS:0000000000000000
[ 2068.591975] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 2068.591975] CR2: 00002c5f73a6cc20 CR3: 00000002f920a001 CR4: 00000000003606e0
[ 2068.591977] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 2068.591978] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[ 2068.591978] Call Trace:
[ 2068.591985] __do_softirq+0xe3/0x30a
[ 2068.591989] ? sort_range+0x20/0x20
[ 2068.591990] run_ksoftirqd+0x26/0x40
[ 2068.591992] smpboot_thread_fn+0xc5/0x160
[ 2068.591995] kthread+0x112/0x130
[ 2068.591997] ? kthread_create_on_node+0x40/0x40
[ 2068.591998] ret_from_fork+0x35/0x40
[ 2068.591999] Modules linked in: ccm arc4 fuse rfcomm cmac bnep sunrpc snd_hda_codec_hdmi snd_soc_skl snd_soc_core snd_soc_acpi_intel_match snd_hda_codec_realtek snd_soc_acpi snd_hda_codec_generic snd_soc_skl_ipc snd_soc_sst_ipc snd_soc_sst_dsp snd_hda_ext_core iTCO_wdt snd_hda_intel intel_rapl iTCO_vendor_support x86_pkg_temp_thermal intel_powerclamp btusb mei_wdt coretemp btrtl snd_hda_codec btbcm btintel intel_cstate snd_hwdep intel_uncore uvcvideo snd_hda_core videobuf2_vmalloc videobuf2_memops intel_rapl_perf wmi_bmof videobuf2_v4l2 intel_wmi_thunderbolt snd_seq bluetooth joydev videobuf2_common snd_seq_device snd_pcm videodev media i2c_i801 snd_timer idma64 ecdh_generic intel_lpss_pci intel_lpss mei_me mei ucsi_acpi typec_ucsi processor_thermal_device intel_soc_dts_iosf intel_pch_thermal typec thinkpad_acpi wmi snd soundcore rfkill int3403_thermal int340x_thermal_zone int3400_thermal acpi_thermal_rel acpi_pad pcc_cpufreq uas usb_storage crc32c_intel i915 i2c_algo_bit nvme serio_raw
[ 2068.592033] drm_kms_helper e1000e nvme_core drm video ipv6 [last unloaded: cfg80211]
Fortunate thing is that this not happen frequently, as scheduling
tasklet on blocked state is very exceptional, though might happen.
Due to different RX/TX tasklet processing fix is different for those.
For RX we have to assure rx_tasklet do fail to resubmit buffers
by poisoning urb's and kill the tasklet.
For TX we need to handle all stop cases properly (suspend, module
unload, device removal).
Signed-off-by: Stanislaw Gruszka <[email protected]>
156 lines
4.0 KiB
C
156 lines
4.0 KiB
C
/*
|
|
* Copyright (C) 2018 Lorenzo Bianconi <[email protected]>
|
|
*
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
* copyright notice and this permission notice appear in all copies.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/module.h>
|
|
|
|
#include "../mt76x02_usb.h"
|
|
#include "mt76x2u.h"
|
|
|
|
static const struct usb_device_id mt76x2u_device_table[] = {
|
|
{ USB_DEVICE(0x0b05, 0x1833) }, /* Asus USB-AC54 */
|
|
{ USB_DEVICE(0x0b05, 0x17eb) }, /* Asus USB-AC55 */
|
|
{ USB_DEVICE(0x0b05, 0x180b) }, /* Asus USB-N53 B1 */
|
|
{ USB_DEVICE(0x0e8d, 0x7612) }, /* Aukey USBAC1200 - Alfa AWUS036ACM */
|
|
{ USB_DEVICE(0x057c, 0x8503) }, /* Avm FRITZ!WLAN AC860 */
|
|
{ USB_DEVICE(0x7392, 0xb711) }, /* Edimax EW 7722 UAC */
|
|
{ USB_DEVICE(0x0846, 0x9053) }, /* Netgear A6210 */
|
|
{ USB_DEVICE(0x045e, 0x02e6) }, /* XBox One Wireless Adapter */
|
|
{ },
|
|
};
|
|
|
|
static int mt76x2u_probe(struct usb_interface *intf,
|
|
const struct usb_device_id *id)
|
|
{
|
|
static const struct mt76_driver_ops drv_ops = {
|
|
.tx_prepare_skb = mt76x02u_tx_prepare_skb,
|
|
.tx_complete_skb = mt76x02u_tx_complete_skb,
|
|
.tx_status_data = mt76x02_tx_status_data,
|
|
.rx_skb = mt76x02_queue_rx_skb,
|
|
.sta_ps = mt76x02_sta_ps,
|
|
.sta_add = mt76x02_sta_add,
|
|
.sta_remove = mt76x02_sta_remove,
|
|
};
|
|
struct usb_device *udev = interface_to_usbdev(intf);
|
|
struct mt76x02_dev *dev;
|
|
struct mt76_dev *mdev;
|
|
int err;
|
|
|
|
mdev = mt76_alloc_device(&udev->dev, sizeof(*dev), &mt76x2u_ops,
|
|
&drv_ops);
|
|
if (!mdev)
|
|
return -ENOMEM;
|
|
|
|
dev = container_of(mdev, struct mt76x02_dev, mt76);
|
|
|
|
udev = usb_get_dev(udev);
|
|
usb_reset_device(udev);
|
|
|
|
usb_set_intfdata(intf, dev);
|
|
|
|
mt76x02u_init_mcu(mdev);
|
|
err = mt76u_init(mdev, intf);
|
|
if (err < 0)
|
|
goto err;
|
|
|
|
mdev->rev = mt76_rr(dev, MT_ASIC_VERSION);
|
|
dev_info(mdev->dev, "ASIC revision: %08x\n", mdev->rev);
|
|
if (!is_mt76x2(dev)) {
|
|
err = -ENODEV;
|
|
goto err;
|
|
}
|
|
|
|
err = mt76x2u_register_device(dev);
|
|
if (err < 0)
|
|
goto err;
|
|
|
|
return 0;
|
|
|
|
err:
|
|
ieee80211_free_hw(mt76_hw(dev));
|
|
usb_set_intfdata(intf, NULL);
|
|
usb_put_dev(udev);
|
|
|
|
return err;
|
|
}
|
|
|
|
static void mt76x2u_disconnect(struct usb_interface *intf)
|
|
{
|
|
struct usb_device *udev = interface_to_usbdev(intf);
|
|
struct mt76x02_dev *dev = usb_get_intfdata(intf);
|
|
struct ieee80211_hw *hw = mt76_hw(dev);
|
|
|
|
set_bit(MT76_REMOVED, &dev->mt76.state);
|
|
ieee80211_unregister_hw(hw);
|
|
mt76x2u_cleanup(dev);
|
|
|
|
ieee80211_free_hw(hw);
|
|
usb_set_intfdata(intf, NULL);
|
|
usb_put_dev(udev);
|
|
}
|
|
|
|
static int __maybe_unused mt76x2u_suspend(struct usb_interface *intf,
|
|
pm_message_t state)
|
|
{
|
|
struct mt76x02_dev *dev = usb_get_intfdata(intf);
|
|
|
|
mt76u_stop_rx(&dev->mt76);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int __maybe_unused mt76x2u_resume(struct usb_interface *intf)
|
|
{
|
|
struct mt76x02_dev *dev = usb_get_intfdata(intf);
|
|
int err;
|
|
|
|
err = mt76u_resume_rx(&dev->mt76);
|
|
if (err < 0)
|
|
goto err;
|
|
|
|
err = mt76x2u_init_hardware(dev);
|
|
if (err < 0)
|
|
goto err;
|
|
|
|
return 0;
|
|
|
|
err:
|
|
mt76x2u_cleanup(dev);
|
|
return err;
|
|
}
|
|
|
|
MODULE_DEVICE_TABLE(usb, mt76x2u_device_table);
|
|
MODULE_FIRMWARE(MT7662_FIRMWARE);
|
|
MODULE_FIRMWARE(MT7662_ROM_PATCH);
|
|
|
|
static struct usb_driver mt76x2u_driver = {
|
|
.name = KBUILD_MODNAME,
|
|
.id_table = mt76x2u_device_table,
|
|
.probe = mt76x2u_probe,
|
|
.disconnect = mt76x2u_disconnect,
|
|
#ifdef CONFIG_PM
|
|
.suspend = mt76x2u_suspend,
|
|
.resume = mt76x2u_resume,
|
|
.reset_resume = mt76x2u_resume,
|
|
#endif /* CONFIG_PM */
|
|
.soft_unbind = 1,
|
|
.disable_hub_initiated_lpm = 1,
|
|
};
|
|
module_usb_driver(mt76x2u_driver);
|
|
|
|
MODULE_AUTHOR("Lorenzo Bianconi <[email protected]>");
|
|
MODULE_LICENSE("Dual BSD/GPL");
|