On 6/8/2019 4:37 AM, Sean Young wrote: > Hi, > >>> I think you can call usb_lock_device_for_reset() to prevent that problem. >> >> Deadlock still occurs in test: >> mceusb_deferred_kevent() >> ->usb_reset_device() >> ->mceusb_dev_disconnect() >> ->cancel_work_sync() >> where cancel_work_sync() blocks because mceusb_deferred_kevent() is active. > > I understand. The usb_reset_device() does not need to happen synchronously > in mceusb_deferred_kevent(). Possibly another delayed workqueue. > > Actually there is also a function usb_queue_reset_device() which might do > what you want here. > Thanks! Usb_queue_reset_device() appears to be exactly what I'm looking for. With the help of your tip, I found Alan Stern ran into a virtually identical problem (clear halt error and reset deadlock) with drivers/hid/usbhid/hid-core.c https://linux-usb.vger.kernel.narkive.com/fc7Lng6q/patch-usbhid-improve-handling-of-clear-halt-and-reset So patch for mceusb may be able to use the same techniques. >> >>> It would be nice to see this implemented too. >>> >> >> Any additional tips to implement would help! >> How to validate and test a rare condition with a larger audience? > > This is hard. Do you know the model of the mceusb and host hardware? > Host is Raspberry Pi 3B+ raspbian 4.14.xx version of mid year 2018. mceusb Pinnacle Systems PCTV Remote USB with mce emulator interface version 1 device 2304:0225 produced the sequence: [59388.696941] mceusb 1-1.1.2:1.0: Error: urb status = -32 (RX HALT) [59388.698838] mceusb 1-1.1.2:1.0: rx clear halt error -32 RX permanently stops after the error. All the work I'm doing for mceusb is with the above. The other case (https://ubuntuforums.org/showthread.php?t=2406882) I heard about is: Host ubuntu, mceusb unknown, possibly SMK eHome Infrared Transceiver with mce emulator interface version 1 Flooding of: mceusb 2-1.4:1.0: Error: urb status = -32 (RX HALT) >> Hence, the moved line. > > That's in a future patch. Please only change error strings in this patch. > ok, I'll post a v2 version of this patch with only the error strings changes. The instructions the error strings say (USB reset device manually) will be my patch resolution for the mceusb stuck halt bug for some time. In the meantime, I'll try and test (harder part) use of usb_queue_reset_device for a future patch to automate the USB reset procedure. Thanks again, ..A Sun