Jump to content

Patched AppleUSBXHCI from OS 10.8.2

USB 3 AppleUSBXHCI

  • Please log in to reply
128 replies to this topic

#21
Zenith432

Zenith432

    InsanelyMac Sage

  • Developers
  • 420 posts
  • Gender:Male

My lappy is an Asus G75VW-BH71-CB. Any ideas ?

The only thing that comes to mind it to try patch #3 alone to disable MSI interrupts. If that doesn't do it, it's something else I haven't discovered.

#22
slayer2333

slayer2333

    InsanelyMac Geek

  • Members
  • PipPipPipPip
  • 211 posts
  • Gender:Male
Thank you very much for your help. In fact the USB 3.0 worked nativelly without any modifications when i disabled Legacy USB at Bios and Enabled Pre-Boot XHCI. Good speeds and no freezes. Many thanks for your help.

#23
Zenith432

Zenith432

    InsanelyMac Sage

  • Developers
  • 420 posts
  • Gender:Male
Update

I figured out why the wake code is leaving the ports unusable. AppleUSBXHCI uses nonconforming wake code that violates the xhci spec. It restores the command-ring address register after performing chip-internal restore. The spec says to restore all CPU-accessible registers first. Evidently, on Intel Panther Point this doesn't make any difference.
Anyhow, the misordered code leaves the chip in an error state. It then goes into incomplete recovery code, which never clears the error condition. So the chip remains in an error state, and nothing else works on it until reset.
Unfortunately, fixing this requires reordering a few lines of source code. Doing it as a binary patch, while possible, is a lot of work. Since this work will be obsolete as soon as 10.8.3 comes out, and it's unreasonable to keep up such a patch - I'm dropping it.

Update [1/24/2013]: Upon further investigation, the reordered code is not the reason chip-internal restore is failing. Apparently, some xhci chips simply don't support internal-restore, and will fail if this feature is used. The driver is expected to restart the chip, but the incomplete recovery code in AppleUSBXHCI from an SRE (save-restore error) leaves the chip in an unusable state. In the linux driver, the recovery code from SRE is complete, so it works.

I've also figured out why MSI interrupts don't always work. Again, AppleUSBXHCI uses noncomforming code. The spec allows for multiple interrupters. If pin interrupts are used, all events are channeled to one vector (since PCI only allows one pin interrupt per function.) If MSI (or MSI-X) is used, multiple interrupt vectors are allowed. The xhci spec says to connect each interrupter to a distinct MSI vector. AppleUSBXHCI enables 2 interrupters on the chip. However, Apple's PCI messaged interrupt controller only allows one MSI vector per PCI device (this is hardwired!). This is unlike Windows or Linux that do allow multiple MSI vectors. So AppleUSBXHCI tries to connect 2 interrupters to one enabled MSI vector. This is non-conforming. Again, on Intel Panther Point it just happens to work. Evidently it channels both interrupters to the single vector.

Sorry I couldn't bring better news.

#24
SkyZ

SkyZ

    InsanelyMac Geek

  • Members
  • PipPipPip
  • 126 posts
Okay, Zenith432's 5th patched USBXHCI.kext worked perfectly on my MBP 2010 until I rebuild the system to use Fusion drive..... Now I got this error on startup and no drive can be recognize:


USBF: 43.130 AppleUSBHub[0xffffff803d0a9c00]::ConfigureHub(hub @ 0x7c000000) could not get hub descriptor (0xe00002c2)

USBF: 43.130 AppleUSBHub[0xffffff803d0a9c00]::ConfigureHubDriver Aborting startup for hub @ 0x7c000000, error 0xe00002c2 (invalid argument)

Any thought on this? Thank you guys :)

#25
bebop68

bebop68

    InsanelyMac Protégé

  • Members
  • Pip
  • 23 posts
Patch 3 for MSI does cut the cpu in half for whatever reason. I have an mbp 17" with expresscard, and tried with nec 720200, 720202a. Speed very similar, and faster than any of the third party kexts, but no sleep. No sleep is a deal breaker for me.

Also patched doesn't work on fresco fl1000, and unpatched doesn't either (native kext supposed to work with fl1100 and fl1009). System Info shows the high speed and super speed buses, and eventually shows usb 3 to sata bridges plugged in, but doesn't mount the drives?

Best solution I've found - allowanyxhci-true in info.plist of native kext, plus unlocked pxhcd 1.0.10. All three cards work with this combo, and it says they're running under pxhcd but they have the higher speeds of the patched apple kext, and sleep works.

#26
SkyZ

SkyZ

    InsanelyMac Geek

  • Members
  • PipPipPip
  • 126 posts

Patch 3 for MSI does cut the cpu in half for whatever reason. I have an mbp 17" with expresscard, and tried with nec 720200, 720202a. Speed very similar, and faster than any of the third party kexts, but no sleep. No sleep is a deal breaker for me.

Also patched doesn't work on fresco fl1000, and unpatched doesn't either (native kext supposed to work with fl1100 and fl1009). System Info shows the high speed and super speed buses, and eventually shows usb 3 to sata bridges plugged in, but doesn't mount the drives?

Best solution I've found - allowanyxhci-true in info.plist of native kext, plus unlocked pxhcd 1.0.10. All three cards work with this combo, and it says they're running under pxhcd but they have the higher speeds of the patched apple kext, and sleep works.


Thks bebop68, it works!! Just wondering why it used to work using

Zenith432's patched USBXHCI.kext and no need to use unlock PXHCD.kext until I rebuild the system using Fusion drive, should have nothing to do with it.....

Attached Files



#27
Zenith432

Zenith432

    InsanelyMac Sage

  • Developers
  • 420 posts
  • Gender:Male

Patch 3 for MSI does cut the cpu in half for whatever reason. I have an mbp 17" with expresscard, and tried with nec 720200, 720202a. Speed very similar, and faster than any of the third party kexts, but no sleep. No sleep is a deal breaker for me.

The reason it cuts the CPU in half is because AppleUSBXHCI uses a load-balancing technique where it shares the workload between two interrupters. The xhci spec says for two interrupters you must have MSI with two vectors. AppleUSBXHCI attempts to use two interrupters with one vector - which is either pin interrupt or MSI. Since this is non-conforming
  • On some controllers, using two interrupters will not work whether it uses pin interrupt or MSI.
  • On some controllers, using two interrupters will work with pin interrupt, but not MSI (hence my patch #3.)
  • On some controllers, using two interrupters will work with pin interrupt or single MSI. (This includes Intel Panther Point.)
PXHCD and CalDigit both use one interrupter, which will work with either pin interrupt or MSI. No load balancing.
PXHCD and CalDigit only implement High-Speed ports (USB 2.0) towards IOUSBFamily. The speed they achieve depends on the device, and what those kexts actually do at the ports. It may be that they fake a High-Speed port toward IOUSBFamily, but actually use super-speed at the port. This is somewhat problematic, since USB 2.0 ports have slightly different features, but it may be possible. I didn't actually check the code to see if they do this. Anyways, even if the port is operated at high-speed, some drives may be capable of achieving their best throughput that way.

I have some updates
  • I updated post #23 about the reason for sleep/wake not working.
  • I updated post #1 with a new patched kext.
  • Eliminated previous patch #4, since on further examination of the code, it wasn't needed.
  • I added a new patch #4 as a workaround for the sleep/wake problem. What it does is tell IOUSBFamily not to use the driver's sleep/wake code. Instead, IOUSBFamily will use the driver's controller-off/controller-on code. This code (unlike sleep) does work and restores the controller and ports to a working state after wake w/o need to reboot. However, any drives connected to the ports will disconnect during sleep. After wake you'll get a message saying the drive disconnected. The system will immediately reconnect the drive. Whether this may cause loss-of-data, I'm not sure. It may be that the drives are synced before sleep, so no data-loss results. If you manually sync the disks before sleep, it should be ok. This is not great, but it's the best I could find, and it's better than the ports going dead.


#28
bebop68

bebop68

    InsanelyMac Protégé

  • Members
  • Pip
  • 23 posts
Thanks, that all makes sense. Caldigit and PXHCD implementing usb 2 hubs explains the speed and reporting a 480mb/s connection. I'll give the new patch a try out of curiosity but I can't have sleep disconnecting drives. Caldigit doesn't sleep but pxhcd does (as does oyen's mxhcd.kext) - is it possible to port it's working sleep-restore code into the applexhci kext?

By cutting cpu in half I mean - not cpu usage on usb operations, but cpu performance in benchmarks. If that translates to a real world drop in performance it's untenable. Could you release a file without the MSI patch for people with MSI compatible cards?

Further information - using pxhcd with a native applexhci with allowanyxhci /true does not improve speed. I had been using oyen's mxhcd.kext with the iopcimatch string removed from its info.list. It performs better than pxhcd, is unlocked, and sleep works. MXHCD works on nec 720202a with latest firmware, and fl1000. Not working on nec 720200.

***PXHCD and MXHCD do not play nice with my iphone. When I plug the phone in it begins to sync, the usb 3 drives disconnect, and then the sync fails. Can't remember if Caldigit does this too. Even without an expresscard in the slot the itunes sync fails (and then keeps going somehow).*** UPDATE: still verifying this.

I have an asmedia 1042 card on the way, and caldigit drivers tailored for it. I also have another fl1000 card which may be the same or different or have different firmware, i will try all the permutations and post something here.

Thanks for all the work. It seems these chipsets are still immature and we may end up requiring differently tailored kexts for different chips. Roll on superspeed 1.0 certification.

#29
Zenith432

Zenith432

    InsanelyMac Sage

  • Developers
  • 420 posts
  • Gender:Male

Caldigit doesn't sleep but pxhcd does (as does oyen's mxhcd.kext) - is it possible to port it's working sleep-restore code into the applexhci kext?

PXHCD sleep/resume may work for you, but not for everyone. On my uPD720200, the drive is unusable after wake, with all attempts to access it hanging. The system hangs on shutdown after that and has to be reset.
Source code for AppleUSBXHCI is not publicly available. If it were, the preferred fix is to take the code from the linux driver.

Could you release a file without the MSI patch for people with MSI compatible cards?

Use a hex-editor to change the byte at offset 0x5701 in AppleUSBXHCI from 0xeb back to 0x74. That's what I posted the hex diff for.

It seems these chipsets are still immature and we may end up requiring differently tailored kexts for different chips.

The chips are fine. It's the drivers that are deficient. The linux driver handles them all, including vendor-specialized quirks.

#30
bebop68

bebop68

    InsanelyMac Protégé

  • Members
  • Pip
  • 23 posts
some people are't going to want to patch the binary themselves.

my 720200 wakes from sleep and yours doesnt but the chips are fine.

can the linux driver be ported?

#31
SkyZ

SkyZ

    InsanelyMac Geek

  • Members
  • PipPipPip
  • 126 posts
just tried Zenith432's 6th patch USBXHCI and removed PXHCD, same error again:

USBF: 34.210 AppleUSBHub[0xffffff803070f800]::ConfigureHub(hub @ 0x7c000000) could not get hub descriptor (0xe00002c2)
USBF: 34.210 AppleUSBHub[0xffffff803070f800]::ConfigureHubDriver Aborting startup for hub @ 0x7c000000, error 0xe00002c2 (invalid argument)

Guess I'll stick with bebop68 solution for now.

#32
bebop68

bebop68

    InsanelyMac Protégé

  • Members
  • Pip
  • 23 posts
I just tried the new file and it ran both the necs, but not the fl1000 or asm1042. I then tried it with the msi patch reversed and it loaded for the necs but wouldn't see or mount drives.

#33
Zenith432

Zenith432

    InsanelyMac Sage

  • Developers
  • 420 posts
  • Gender:Male
Good news.
I worked out a better solution for the interrupt problem.
I found all places in the code where it directs the xHC to use interrupter 1 (total 3.)
Changed it to always use interrupter 0.
Reenabled MSI.
Now I benchmark my USB 3.0 thumbstick at 70 MB/sec which is the same performance as Windows and Linux. :D

I also found why using the pin interrupt was degrading performance. Due to the way AppleUSBXHCI misuses interrupters, it doesn't properly clear the interrupt pending flags on the interrupters in pin-mode. So it was causing too many interrupts which is why it was showing increased CPU usage and degraded performance.

The new patches are in post #1 [1/28/2013].

The sleep problem is as before.

By the way, I benchmarked again with PXHCD, and I'm also getting 70 MB/sec. For some reason I was getting 4 MB/sec when I tried same test a couple months ago. Strange...

Edited by Zenith432, 28 January 2013 - 11:44 AM.


#34
TimeWalker75a

TimeWalker75a

    InsanelyMac Legend

  • Gurus
  • 1,037 posts
  • Gender:Male
Cool, thank you very much for this research!
The sleep patch at offset 10014 has cured the issue that has been plaguing my FL1009 controller on my Vostro 3450 laptop. Controller used to work absolutely fine, but refused to work after sleep. I use Jettison https://itunes.apple...son/id447430809 to unmount usb drives before sleep and remount afterwards. After applying the diff as a KextPatcher entry for Clover, it has successfully cured the problem and USB devices plugged into USB 3.0 ports now properly get remounted after sleep!

#35
dfrank970

dfrank970

    InsanelyMac Protégé

  • Members
  • Pip
  • 1 posts
Hallo guys,
I have installed a Mountain Lion Hackintosh on my new ACER ASPIRE 5755-9401 (8GB RAM, core i7, Intel HD3000 Graphics).
I installed the LAN kext, the audio Kext with Voodoo installer (It works well but not with HDMI out).
I installed the chameleon boot and edited it. Then I fixed the boot0 error with My Hack utility.
Now I have a laptop with ML and Win7 to choose at the boot and I'm very happy BUT...
I've not still found a kext for USB3 (renesas NEC uPD720200AF1) working on my laptop.
I've tried installing several kexts and afterwards to clean permissions and cache:

2786-IOath3kfrmwr.kext
2817-OSX-iNDO_USB3.0
AppleUSBXHCI.kext
LaCie-USB-3.0-Driver.1.0.11
modbin_patched_PXHCD.kext
PXHCD.kext


But every time the system freezes after pluggin in a USB3 external drive.

I removed all these kext and I installed your last kext "patched AppleUSBXHCI" BUT it's still not working.

These are the kext I used for the boot in System/Library/Extension:

AppleACPIPS2Nub
ApplePS2Controller
JMicron36xATA
NullCPUPowerManagement
IO80211Family
VoodooHDA
AppleACPIPlatform
AppleHDADisabler
AppleSmartBatteryManager


Thank you for your eventual help.

dfrank970

#36
sebus

sebus

    InsanelyMac Sage

  • Members
  • PipPipPipPipPip
  • 262 posts
  • Gender:Male
  • Location:UK
Gigabyte Z77N-Wi-fi (or rather without, as I REMOVED IT)

USB 3.0 ports - if I boot with USB 3.0 HD attached, drive is visible, but any access to it ie. NTFS drive, read only movie playback, shows after a moment "The drive was not ejected properly...."

But if I plug in the HD while ML 10.8.2 is running the device is not seen at all

And if it happens that it is seen (sometimes) same happens, not really usable

sebus

#37
Zenith432

Zenith432

    InsanelyMac Sage

  • Developers
  • 420 posts
  • Gender:Male

Gigabyte Z77N-Wi-fi

Intel Panther-Point needs some bios settings to make it work. See posts #20, #22. Also, you can use unpatched AppleUSBXHCI for it.

#38
sebus

sebus

    InsanelyMac Sage

  • Members
  • PipPipPipPipPip
  • 262 posts
  • Gender:Male
  • Location:UK
Thanks, perfect, working with no issues now

#39
Dr. Hurt

Dr. Hurt

    InsanelyMac Legend

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 1,485 posts
  • Gender:Male
  • Location:Cairo, Egypt and NYC, USA
  • Interests:Wandering around on the internet!! Politics, Sci/Tech, Medicine.
Working perfectly here on Dell n5110 with LaCie USB3.0

Finally I can USB USB3.0 without that dreadful PXHCD.kext :)

Thank you very much.

#40
Maniac10

Maniac10

    InsanelyMac Legend

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,078 posts
  • Gender:Not Telling
Works with the Etron EJ168 chip on my Z68AP-D3, though I don't have a USB3 device to test anything I plug works. Thanks a lot Zenith432.

Is it possible to do this with Clover's kext patcher?





Also tagged with one or more of these keywords: USB 3, AppleUSBXHCI


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

© 2014 InsanelyMac  |   News  |   Forum  |   Downloads  |   OSx86 Wiki  |   Mac Netbook  |   PHP hosting by CatN  |   Designed by Ed Gain  |   Logo by irfan  |   Privacy Policy