Can I somehow speed up Windows's USB Plug n play function (on a USB Hub/switch)?

4

1

I'm using a KVM-switch like setup to share my keyboard and mouse between a Windows machine and a Linux machine.

I have a Logitech Mouse and Corsair (K95-RGB) Keyboard (ironically both devices made and optimized for windows with only windows-side official driver support...) and the problem is that when I switch the devices from Windows (or offline) to Linux, Linux picks up that the devices are plugged in and activates them immediately, I can use the devices within 1 second no matter how recently I last switched or which state the devices were in previously.

When I switch from Linux (or offline) to Windows, Windows can take an awful amount of time to first detect the devices, and another awful lot of time to actually enable them...

According to my Windows clock (I counted), roughly 38 seconds for device detection (powering on), and another 17 seconds (update: on a re-test later on I found the mouse activating in ~15s and keyboard 5 secs later, or in ~20s) for device activation (e.g. for the driver to kick in properly, so from the time I switch to windows I waited 55 seconds before I could use the devices) this time was the same for both my Keyboard and Mouse despite using separate driver software and being completely different devices.

So what takes Linux effectively around 1 second to do, windows takes up to 1 minute to do, usually in the range of 40-60 seconds based on my experience over roughly half a month.

To further clarify things. The first 35-40 seconds that Windows takes to power on/detect the devices only happens if the devices were recently disconnected. Basically what is happening is that when I disconnect the devices (switch away from Windows) windows takes 35-40 seconds to acknowledge that the devices have been disconnected (making the device disconnected sound). If I switch back to windows after this point, the devices are detected/powered on immediately, but still take a good 15-20 seconds to be usable (for the drivers to work).

Question #1 is whether I can somehow hasten the driver enablement for the devices after they have been detected and powered on? (Maybe somehow prevent the drivers from being unloaded completely in the first place? Or offload them to a RAMDisk for faster load? Something else?)

Question #2. Can I somehow reduce the time(out?) before Windows disconnects the devices after they have been unplugged (switched to another computer)? I'd prefer this to be as close to instant as possible.

Extra Info:

My setup is as follows (from computer to devices)

  1. USB 2.0 Port
  2. USB 1.X USB Switch
  3. USB 2.0, 4 Port Manhattan Powered USB Hub
    1. Corsair K95-RGB Keyboard (uses 2 USB Ports, one for extra power)
    2. Logitech G402 Hyperion Fury Mouse
    3. Wacom CTH-680 Tablet.

Tests:

I tested the same switch/hub setup on Linux and in the UEFI BIOS, none of the issues on Windows were observed (except that the keyboard and keyboard alone takes a few seconds to be re-detected by the ckb driver, what this means is that macro/extra keys don't work until after a few seconds on Linux for the keyboard. Otherwise everything works perfectly in <1s)

I decided to test plugging my mouse alone directly in since it's the easiest and on the first connect it exhibited a similar behavior of a roughly ~50 second wait before the mouse was usable (much of this time was again waiting for it to be detected and powered in the first place). If I repeated this test afterwards by unplugging the mouse and plugging it back in, it was instantly activated/usable, and similarly if I unplugged it then and plugged it into the already active USB hub, it was again instantly activated. But if I used the switch to turn the devices off/on it reverts to the same pattern as before. (Plug and play works best if you are not disconnecting/reconnecting an entire hub with several devices connected)

I tried switching the usb switch off of windows, waiting for Windows to disconnect the devices (~40s) and playing the device disconnect sound, at which point I switched back to windows, device detection was instant but driver load still took 15-20 seconds. (Wacom untested) mouse and keyboard become usable at the exact same time despite the keyboard driver being seemingly more complex and should probably be taking longer to load than the mouse (it's kind of like no device can work until all the devices connected to the hub have had their drivers loaded, may just be coincidence though).

I tried booting in safe mode (generic drivers only), in here the device disconnect still took ~40s but the driver activation after detection took <1s for the mouse and <5s for the keyboard (much faster than the ~17s for both; but in light of this I decided to re-test the activation time after detection for both devices after booting out of safe mode, and true enough, this time the keyboard took around 5 seconds longer than the mouse to load the drivers (mouse ~15s, keyboard ~20s).

I ran another test after uninstalling the Corsair Utility Engine (keyboard drivers) the keyboard did not initialize any faster (still took ~20s). After a restart, the keyboard would activate almost as fast as it did in safe mode. I then re-installed the Corsair Utility Engine and tried again, and with the corsair drivers active it was fast again. I rebooted, and things went back to the way they were before. I uninstalled the corsair utility engine again, and despite it being uninstalled, the keyboard does not initialize fast anymore. Further testing lead me to conclude that I can uninstall the corsair specific keyboard drivers and use the generic ones instead (with the corsair utility engine still running and activating the leds) and this gives me enough speed boost so that driver enablement takes 5s (mouse) and ~10s (keyboard), however this solution is not an option for me since it means my keyboard would not function correctly.

Cestarian

Posted 2016-04-13T17:22:01.543

Reputation: 1 418

If you plug them directly into the PC, into the same ports the KVM is plugged into, does this behavior still exhibit itself? – Ramhound – 2016-04-13T17:23:34.170

@Ramhound I should probably clarify my setup, I have a USB (1.0) switch which I connected to a USB (2.0, 4 port, powered) hub which my devices (USB 2.0) are connected to. I decided to test plugging my mouse alone directly in since it's the easiest (keyboard uses 2 ports) and it exhibited a similar behavior of a roughly 40 second wait before the mouse was usable. I wouldn't be surprised if the duration this is taking windows is partly because it may be trying to first detect and activate the USB Hub before it goes on activating the HIDs I've got plugged into it (extending the time by like 20s) – Cestarian – 2016-04-13T17:30:14.580

Your keyboard uses 2 USB ports? Once you did this initial test, did you repeat the test, Windows is suppose to create a catalog of USB devices based on the port. – Ramhound – 2016-04-13T17:33:50.840

@Ramhound yes, I have a Corsair K95-RGB keyboard, it needs one port for power, one port for HID, the plugs are interchangeable (e.g. either one can act as input and power or just power based on the order in which they are plugged in) I did not repeat the test, but let me do so now... Yes, I plugged the mouse (this time into another port) and it was activated almost instantly this time (<2s).

Funny thing, afterwards I plug it back into the hub, and it is again activated almost instantly, we might be on to a solution... Or on the right path anyways. – Cestarian – 2016-04-13T17:40:00.603

@Ramhound I tried again switching the USB on and off via the switch, after plugging the mouse back in, but this time the mouse took just as long to activate as before (just as long as the keyboard). I notice that for the largest part of this duration though (e.g. the 38 seconds in my first post) the devices aren't even powered on, which must be the duration Windows is taking to detect and activate the Hub before it proceeds to the devices which are activating faster. – Cestarian – 2016-04-13T17:43:05.463

3I suspect the problem is the Switch itself not the keyboard and mouse. The delay is to be expected, but it sounds like, the switch is behaving like an entirely new device each time you switch between the connected PCs Alternative is very the problem with just the mouse, I suspect the keyboard, is causing the problems with relation to mouse taking 60 seconds to internalize. – Ramhound – 2016-04-13T17:47:11.340

@Ramhound this may be, but it sounds like a problem that could potentially be worked around somehow. I don't mind having a delay, just... preferably under 10 seconds. (Linux never gives me any delay, so it's not like it's impossible) – Cestarian – 2016-04-13T17:50:05.607

@Ramhound wait I actually noticed something just now. As I said earlier, more than half the time I wait the devices are powered off.This happens if I switch the devices off, then back on. However if I switch off, and wait for Windows to detect the device disconnect (i.e. make that "disconnect" sound notification) then turn back on, the devices power on (e.g. get detected) instantly leaving only the much more tolerable (but still kinda slow) 15-20 seconds for the driver to activate. Is there any way I can optimize this? (Make Windows detect USB disconnection faster?) – Cestarian – 2016-04-13T18:16:02.680

If you take this fancy keyboard with a processor out of the equation. Does anything change. I have concerns its either the switch itself or (now that I looked it up) the keyboard is causing the delay. If the mouse does not have a delay, with the switch, then you have confirmed the problem. – Ramhound – 2016-04-13T18:42:58.980

@Ramhound with the keyboard unplugged, the same test as above (i.e. quick off/on switch with the USB switch) took just upwards of 30 seconds with the mouse (and also a wacom tablet which is connected to the hubs 4th port, I have not tested it's detections speeds, it may be faster than the others) plugged keyboard back in, got a speed of roughly the same 55s as earlier, it seems that windows takes longer to detect the disconnect of the corsair keyboard which in turn adds a seemingly 20-25 second delay in this test scenario (minimal delay if the device disconnect already detected) 30s is 2 slow. – Cestarian – 2016-04-13T19:27:46.217

Try booting Windows in Safe mode, to see if this is caused by a third-party driver. – harrymc – 2016-04-16T12:51:00.160

@harrymc tried this, got very nice results for driver load time on the generic drivers (<1s for mouse <5s for keyboard, within a very acceptable range for me) but the device disconnect took just as long (~40s). Since the uefi bios only has generic drivers, that's probably why it has no problems, and I think Linux loads generic keyboard driver first for the keyboard before offloading it to my userspace driver (or the userspace driver interfaces with the generic keyboard driver) which would be why it activates so fast there as well. – Cestarian – 2016-04-16T16:40:52.757

Have a look at which drivers are installed for these devices. However, this can also be caused by some other installed third-party driver that is not connected to the KVM. – harrymc – 2016-04-16T17:17:48.407

@harrymc look how? The keyboard has the official drivers installed, mouse using generic drivers, wacom has no drivers installed yet. I have other HIDs plugged in though (always in) that is a logitech mx master and a razer blackwidow, they have drivers of their own. – Cestarian – 2016-04-16T18:14:55.090

You can see the driver of the problematic device(s) in Device Manager. If the performance in Safe mode is acceptable, this means that the device uses a third-party driver. Delete the driver from the computer to force using the Microsoft generic one. – harrymc – 2016-04-16T19:09:59.703

@harrymc that's tough... I have many HIDs plugged in, and all except for one (an unrelated one at that) have generic names in the device manager... – Cestarian – 2016-04-16T19:16:04.807

You do that only for the one or two problematic devices, not all the connected devices. See the article Using Device Manager to Uninstall Devices and Driver Packages where you want "Deleting a Driver Package from the Driver Store". Ensure you have the media for re-installing the 3rd-party driver in case of problems with the generic one.

– harrymc – 2016-04-16T19:24:11.510

@harrymc It seems that only my keyboard has a specific driver, Mouse is using generic driver. I deleted it's driver successfully, the devices are initializing noticably faster (mouse less than 5s, keyboard 10s) but not as fast as in safe mode. I tried reinstalling driver after that, and (without reboot) it remains faster. – Cestarian – 2016-04-16T20:00:15.613

@harrymc It seems that only my keyboard has a specific driver, Mouse is using generic driver. I deleted it's driver successfully, the devices are initializing noticably faster (mouse less than 5s, keyboard 10s) but not as fast as in safe mode. I tried reinstalling driver after that, and (without reboot) it remains faster; however still uses generic drivers (as such keyboard extra keys do not work). So from this I think we can easily gather that my corsair keyboard drivers are taking a while to initialize and holding up the mouse while doing it. – Cestarian – 2016-04-16T20:08:33.397

Are you using the latest Corsair Utility Engine from March 2016? (Does this "engine" contain a driver?) You may also ask the Corsair’s Customer Service.

– harrymc – 2016-04-17T08:03:05.267

@harrymc yes I am, yes it does and yeah I'll ask them (doubt I'll get much out of it though, this could just be bad code) – Cestarian – 2016-04-17T10:10:43.083

Until then, you could use the generic driver. For the special keys, you could use programs such as SharpKeys and/or AutoHotkey to map them to useful functions.

– harrymc – 2016-04-17T11:03:16.263

@harrymc Corsair support was a bust, they said this "Please connect the keyboard directly to the computer as it is meant to." Not gonna buy products from those assholes again, I at the very least expect a more polite refusal of service than this... – Cestarian – 2016-04-18T23:40:09.693

Have you tried Disabling Searching Windows Update for Device Drivers? The option is in the Hardware tab of the System Properties window.

– Atoadaso – 2016-04-22T11:42:17.447

@Atoadaso was already off. – Cestarian – 2016-04-22T18:35:14.257

Answers

0

Summary of the above comments :

  • The problematic devices are namely the mouse and the keyboard.
  • Deleting their drivers and resorting to the Windows generic drivers has much improved the switch time.
  • The remaining problem is that the keyboard generic driver cannot handle special keys, for which I have counseled the use of SharpKeys and/or AutoHotkey to map them to useful functions.
  • Keep an eye on the Corsair downloads page for newer updates
  • Trying to get in touch with Corsair’s Customer Service may (or may not) help.

harrymc

Posted 2016-04-13T17:22:01.543

Reputation: 306 093

Well, you're forgetting one part of the question. Reducing (or removing) the timeout between device physical disconnects and the time windows registers the disconnect. – Cestarian – 2016-04-18T23:33:10.480

also I (very) highly doubt that sharpkeys or autohotkey can be used to map G keys. Normally on keyboards like these, the G keys either do not register keystrokes at all, or register a pre-determined keystroke (like F1-F12) but not unique ones. They can't substitute for a real driver, the driver needs to stand the hardware code given from each individual keypress, and generic drivers do not understand "G1-G18" or "MR, M1, M2 and M3". They would if the manufacturer mapped them to different keys (like say F13-F24..) but they generally don't do this. – Cestarian – 2016-04-18T23:45:00.900

Switching lag-time: To reduce you need to change the KVM. There exists a technology called DDM (Dynamic Device Mapping) which is supposed to reduce the lag, but they are usually costly (example). I have no experience with it and don't know how well it works.

– harrymc – 2016-04-19T06:47:07.397

Keys mapping : That depends on the keyboard. The usual case is for the keyboard to generate a scan-code that is interpreted by the third-party driver. I don't know your keyboard, but I believe it would require the cooperation of Microsoft to integrate so deeply into Windows as to totally handle the keyboard. A scan-code is much simpler to handle in software. – harrymc – 2016-04-19T06:55:46.513

It's a driver problem - I believe that Linux drivers are more generic . A more evolved KVM will fake the continuing presence of the devices so there is zero lag. I can delete this answer if you don't see it as helpful. – harrymc – 2016-04-19T11:32:07.393

No it definitely belongs. – Cestarian – 2016-04-23T20:52:18.837

0

There are reports of a reduced reconnect time if you shut off the Allow computer to turn off this device to save power under Device Manager - Properties - Power of the two USB devices.

It's worth a try, but Windows just likes to take its sweet time.

emk2203

Posted 2016-04-13T17:22:01.543

Reputation: 594

I already tried this, the only devices where I could toggle this option was for the USB Hubs, not the devices themselves. It seemed to have no effect. I'm trying it again to confirm, but not expecting much. (I turned it off for all usb hubs) Update: Yeah, no effect whatsoever. – Cestarian – 2016-04-21T19:46:52.103

As the devices don't sleep, but rather disappear, this setting should not apply. – harrymc – 2016-04-22T05:45:03.650

0

I've just found out that Windows 10 does not have this issue, it typically switches over instantly for me. My issue was mostly in relation to Windows 7 though so this is not a complete answer but I guess I'll just have to use Windows 10 for a while until I can dump Windows completely... just one more driver that needs fixing...

But yeah there's that. If you're on Windows 7 and facing the same issue, know that downgrading to Windows 10 could potentially solve it.

Cestarian

Posted 2016-04-13T17:22:01.543

Reputation: 1 418