I've been working on an open source USB 3.0 driver for OS X for a while, and decided it's stable enough to be published.
Implements USB SuperSpeed and HighSpeed root hubs, and accepts SS, HS, FS, LS devices. I've benchmarked a SS drive at the highest speed it's capable of with it.
If you benchmark drives, use block sizes of 128Kbyte or higher power of two - as those are optimal.
I've fixed the issue with interrupters. MSI is used on all chips except FL1000, which is known to have problems with it. Uses pin interrupt on FL1000.
Sleep Issue - Attempts to enable PME on all chips. If PME is supported, uses XHCI suspend/resume. If resume fails, resets the xHC and lets IOUSBFamily reenumerate devices (this causes disconnection messages.) If PME is not supported, reverts to shutdown/reset which will always reenumerate.
If PME is not supported, there'll be a message in syslog "xHC will be unloaded across sleep".
In case of restore error during wakeup, there'll be a message in syslog "xHC Restore Error".
Limitations: Isochronous endpoints are not supported yet. This includes anything having to do with audio or video (webcams too.) If you try to connect devices with isoch endpoints, and OS X has an upper layer driver for the device, it'll fail to configure the device and you'll probably see some messages about it from IOUSBFamily in syslog.
Some kernel flags
- "-gux_nosleep" forces Sleep to always use the shudown/reset method.
- "-gux_nomsi" forces use of pin interrupt instead of msi.
- For Intel Series 7 chipset only (Panther Point.)
"-gux_defer_usb2" causes the xHC to defer the management of USB2 ports and their devices to one of the EHC controllers on the PCH (south-bridge). This option can usually also be configured in the BIOS for Intel Series 7 chipsets.
"-gux_no_idle" disables some feature for idle-mode on Intel's chip. I couldn't test this, so I added an option to disable it.
There is a debugging tool called "xhcdump" that prints various aspects of xHC internal state. Run without options for a list things it can dump.
Note 1: If system doesn't wake from sleep, try the power button before reporting. USB keyboards don't always work during sleep.
Note 2: For Intel Series 7 - if you'd like USB 2.0 ports 1 - 4 to be managed by xhci, it's recommended you configure the bios setting to route these ports to xhci. This ensures devices don't get enumerated on ehci before being switched to xhci.
Note 3: Some Intel Series 7 motherboards have a hardware issue that causes instant-wakeup when put to sleep. Use '-gux_defer_usb2' to resolve this.
If you would like to contribute in the development, particularly to add code for a chipset that you have and can test - feel welcome to do so.
- build for OSes 10.7.5, 10.8.x. [Earlier OSes not supported.]
- xhcdump utility..
- Overhauled error-handling of non-isoch transfers. Fixed a couple of bugs with KP potential related to transfers.
- Optimized handling of transfer timeouts.
- Added kext version to 'xhcdump caps' + a couple of diagnostic counters to 'xhcdump running'
Edit [June 5 2013]: Release 1.2.3
- Improved handling of bios semaphore for legacy USB - eliminates a problem that causes some bioses to crash during sleep.
- Made sequence for entering sleep mode more robust and safer.
- Eliminated potential memory corruption if xhci commands time out.
- Eliminated some potential memory leaks, fixed some minor bugs, made some minor optimizations and added a bit more logging.
Edit [June 2 2013]: Release 1.2.2
- Fixed extra-current errors mentioned in posts #85, #90.
- Fixed minor issue with 32-bit build.
- Fixed issue with chips that stop clocks for power reduction.
- Added some logging to help debugging.
Edit [May 20 2013]: Release 1.2.1
- Fixed alignment bug that made 32-bit build for OS 10.7.5 fail.
Edit [May 19 2013]: Release 1.2.0
- Implemented support for Isochronous Endpoints. Should now support webcams, etc... (real-time audio/video streaming).
- Updated UIM interface changes in OS 10.8.3.
- Added workaround for Intel Series 7 chipset that causes instant-wakeup-on-sleep on some motherboards.
Edit [May 19 2013]: Release 1.1.6.
- Fixed two critical bugs and seven minor bugs.
Edit [May 12 2013]: Release 1.1.5.
- Fixed one critical bug and two minor bugs.
Edit [March 23 2013]: Release 1.1.4.
- Reverted change that caused regression discussed in post #41. Turns out 11 msec means 11 msec and not a msec less.
- Packaged common binary for 10.7.5 + 10.8.x, as suggested in post #39.
Edit [March 22 2013]: Release 1.1.3.
- Prevent instant-wakeup and spontaneous reboot on ASM1042.
- Eliminated some race conditions on power-state and port-status changes that may cause KPs.
Edit [March 19 2013]: Release 1.1.
- Made suspend/resume code safer from KPs.
- Fixed an issue with use of shared pin interrupt.
- Added diagnostic counters for some errors. These are printed by 'xhcdump running' if non-zero.
Edit [March 17 2013]: Uploaded 1.1a4 with
- Fix for xHC that lack 64-bit physical-addressing (ASM1042)
- Prints some more information in xhcdump caps/running
- Added kernel flag '-gux_nomsi' to force use of pin interrupt
- 'xhcdump options' shows kernel flags supported by kext
Edit [March 11 2013]: Uploaded 1.1a3 with
- Added code to discard spurious events that are a likely cause of stalls described in post #10.
- Made error handling of events more robust and fixed some minor bugs in processing of transfers.
Edit [March 8 2013]: Uploaded 1.1a2 with code added to take ownership of xHC from bios.