* Question regarding error handling in usbhid
@ 2026-03-24 9:57 Oliver Neukum
2026-03-24 13:40 ` Alan Stern
0 siblings, 1 reply; 2+ messages in thread
From: Oliver Neukum @ 2026-03-24 9:57 UTC (permalink / raw)
To: Alan Stern; +Cc: USB list, linux-input@vger.kernel.org
Hi,
hid_io_error(), in case it decides that a reset is necessary,
schedules reset_work(). reset_work() in turn calls usb_queue_reset_device().
Why? Is there a reason usb_queue_reset_device() is not used directly
in hid_io_error()?
Regards
Oliver
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Question regarding error handling in usbhid
2026-03-24 9:57 Question regarding error handling in usbhid Oliver Neukum
@ 2026-03-24 13:40 ` Alan Stern
0 siblings, 0 replies; 2+ messages in thread
From: Alan Stern @ 2026-03-24 13:40 UTC (permalink / raw)
To: Oliver Neukum; +Cc: USB list, linux-input@vger.kernel.org
On Tue, Mar 24, 2026 at 10:57:16AM +0100, Oliver Neukum wrote:
> Hi,
>
> hid_io_error(), in case it decides that a reset is necessary,
> schedules reset_work(). reset_work() in turn calls usb_queue_reset_device().
> Why? Is there a reason usb_queue_reset_device() is not used directly
> in hid_io_error()?
This is partly explained in the changelog for commit 8f507ef522d5 ("HID:
usbhid: improve handling of Clear-Halt and reset"):
The way resets are carried out is also changed. Now the driver will
call usb_queue_reset_device() instead of calling usb_reset_device()
directly. This avoids a deadlock that would arise when a device is
unplugged: The hid_reset() routine runs as a workqueue item, a reset
attempt after the device has been unplugged will fail, failure will
cause usbhid to be unbound, and the disconnect routine will try to do
cancel_work_sync(). The usb_queue_reset_device() implementation is
carefully written to handle scenarios like this one properly.
The other part of the explanation is that the reset code was added to
hid_io_error() before usb_queue_reset_device() existed (2006 vs 2008).
Alan Stern
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-24 13:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-24 9:57 Question regarding error handling in usbhid Oliver Neukum
2026-03-24 13:40 ` Alan Stern
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox