# Hardware failure or bug in ehci?



## Orum (Oct 27, 2012)

I recently plugged in a new KVM (Monoprice KCF-181S) to my FreeBSD machines (the machine in question a Jetway NF9A-Q67), and found a high interrupt rate when using top.  The usb and KVM appear like so in dmesg:

```
ehci0: <EHCI (generic) USB 2.0 controller> mem 0xfe523000-0xfe5233ff irq 16 at device 26.0 on pci0
usbus0: EHCI version 1.0
usbus0 on ehci0
...
ehci1: <EHCI (generic) USB 2.0 controller> mem 0xfe522000-0xfe5223ff irq 23 at device 29.0 on pci0
usbus1: EHCI version 1.0
usbus1 on ehci1
...
usbus0: 480Mbps High Speed USB v2.0
usbus1: 480Mbps High Speed USB v2.0
ugen0.1: <Intel> at usbus0
uhub0: <Intel EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus0
ugen1.1: <Intel> at usbus1
uhub1: <Intel EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus1
...
ugen0.2: <vendor 0x8087> at usbus0
uhub2: <vendor 0x8087 product 0x0024, class 9/0, rev 2.00/0.00, addr 2> on usbus0
ugen1.2: <vendor 0x8087> at usbus1
uhub3: <vendor 0x8087 product 0x0024, class 9/0, rev 2.00/0.00, addr 2> on usbus1
...
uhub2: 6 ports with 6 removable, self powered
uhub3: 8 ports with 8 removable, self powered
...
ugen0.3: <vendor 0x0b39> at usbus0
ukbd0: <vendor 0x0b39 product 0x1001, class 0/0, rev 1.10/1.00, addr 3> on usbus0
kbd2 at ukbd0
ums0: <vendor 0x0b39 product 0x1001, class 0/0, rev 1.10/1.00, addr 3> on usbus0
ums0: 5 buttons and [XYZ] coordinates ID=1
```

Investigating further, I found this:

```
% uname -a
FreeBSD pyrite 9.1-RC2 FreeBSD 9.1-RC2 #0 r241608: Tue Oct 16 18:18:23 UTC 2012     root@pyrite:/usr/obj/usr/src/sys/PYRITE  amd64

% vmstat -i
interrupt                          total       rate
irq1: atkbd0                          29          0
irq4: uart0                          395          0
irq16: ehci0                 14852890008      61807
irq23: ehci1                      626348          2
cpu0:timer                     267891392       1114
irq264: em0                        66802          0
irq265: em1:rx 0                  844347          3
irq266: em1:tx 0                  292193          1
irq267: em1:link                       9          0
irq268: ahci0                     221681          0
cpu1:timer                     221101117        920
cpu3:timer                       1504868          6
cpu2:timer                       1336765          5
Total                        15346775954      63862

# usbconfig
ugen0.1: <EHCI root HUB Intel> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE
ugen1.1: <EHCI root HUB Intel> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE
ugen0.2: <product 0x0024 vendor 0x8087> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE
ugen1.2: <product 0x0024 vendor 0x8087> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE
ugen0.3: <Combo Free KVM 816 V2.00 OCT> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON
```
Nearly 62K interrupts/second on ehci0!  After much testing, I've found that this is an intermittent problem.  I'll summarize:

Even in identical hardware configurations (i.e. everything plugged into the same port), sometimes I see the high interrupt rate, and sometimes I don't.
Once I see the high interrupt rate, there is no way to make it stop without rebooting.  *Even if I unplug the KVM* I will continue to see the interrupt rate climb until I reboot.
The easiest way to reproduce the issue is to unplug everything KVM related (the VGA, the PS/2 keyboard port, and the USB), and plug it all back in (VGA first, followed by PS/2 keyboard, followed by USB--though I'm unsure if order matters).  Often, though not always, unplugging and replugging the USB alone is not enough to cause the high interrupt rate.
Perhaps the strangest of all, the high interrupt rate *always appears on ehci0 even if I only plugged the KVM into a usbus1 (and therefore ehci1) port!*
I can't reproduce the issue on any other machines the KVM is plugged into (all also running FreeBSD 9.1-RC2/amd64), but they all feature uhci in addition to ehci, and use a different ehci controller.  However, on the problematic machine, it appears to be able to happen regardless of the port/cable of the KVM I use (despite those ports working fine with my other machines).

So, my questions are:

Most importantly, where do you think the problem lies?  The KVM itself, the FreeBSD machine's hardware, or a bug in the kernel/driver?
Why would it appear as a high interrupt rate on ehci0 when it's only plugged into usbus1 which is on ehci1?
Why doesn't the issue appear on any of the other machines I have plugged into the KVM?  Simply because they use different controllers, or does the presence of uhci (which shares an interrupt with ehci0 on those machines) potentially have something to do with it?

I know the last question may be unanswerable. :\


----------



## wblock@ (Oct 27, 2012)

This question should definitely be asked on the freebsd-usb mailing list.


----------

