Bug 33140

Summary: evdev USB input devices which get briefly disconnected become unusable in kdrive/Xephyr
Product: xorg Reporter: Andrew Miller <andrew>
Component: Server/DDX/XephyrAssignee: Matthew Allum <mallum>
Status: RESOLVED FIXED QA Contact: Xorg Project Team <xorg-team>
Severity: enhancement    
Priority: medium CC: peter.hutterer
Version: unspecified   
Hardware: All   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
Patch (as described in comment 0), against xorg-server-1.9.3 none

Description Andrew Miller 2011-01-14 20:54:59 UTC
Created attachment 42068 [details] [review]
Patch (as described in comment 0), against xorg-server-1.9.3

kdrive / Xephyr adds all the evdev devices to the server at the beginning. If a device disappears, the kernel returns ENODEV, and the evdev driver removes the device permanently.

Brief disappearances are quite common for USB devices - I have a problem where devices on a particular USB hub will disappear for less than a second and reappear once every few hours. People also sometimes unplug USB devices to re-route the cable. In both cases, it would be good if the originally configured device would come back up when it is reconnected.

The solution is fairly simple: rather than deleting devices which fail, set their evdev fd to -1, and deregister and close the original fd. Periodically check all devices with -1 fds to see if they can be re-opened, and if this succeeds, start processing events from the device again.

I've made a simple patch which achieves this; I've tested the patch to confirm that unplugging USB devices and then plugging them back in means the devices are usable again.
Comment 1 Peter Hutterer 2011-01-18 18:38:29 UTC
wouldn't it be better to add hotplugging support to Xephyr instead of adding essentially the same thing with a hack like the timer function?
Comment 2 LaƩrcio de Sousa 2016-03-01 16:23:13 UTC
Evdev input hot-plugging support in kdrive/Xephyr was introduced in commit 0cf3d72be6bd99cd2c66b7885339322c7e5bf73d.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct.