Jump to content

Patched AppleUSBXHCI from OS 10.8.2


Zenith432
 Share

146 posts in this topic

Recommended 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.....

post-24252-0-19632700-1358996154_thumb.jpg

Link to comment
Share on other sites

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

  1. I updated post #23 about the reason for sleep/wake not working.
     
  2. I updated post #1 with a new patched kext.
     
  3. Eliminated previous patch #4, since on further examination of the code, it wasn't needed.
     
  4. 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.

  • Like 3
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
  • Like 1
Link to comment
Share on other sites

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.com/app/jettison/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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 4 weeks later...

Hi Zenith 432,

First thanks for all your effort on this USb3 problem.

I have the same problem with the USB Drive showing that it is mounted under the High-Speed port when it is in fact the SuperSpeed port. The command you suggested in post #8 gives Built-in as the Card Type property.

Here is the output:

 

Last login: Thu Feb 28 17:54:15 on console

-bash-3.2$ ioreg -xrc AppleUSBXHCI

+-o AppleUSBXHCI <class AppleUSBXHCI, id 0x100000201, registered, matched, act$

| {

| "IOClass" = "AppleUSBXHCI"

| "CFBundleIdentifier" = "com.apple.driver.AppleUSBXHCI"

| "IOProviderClass" = "IOPCIDevice"

| "Card Type" = "Built-in"

| "IOPCIClassMatch" = "0x0c033000"

| "IOUserClientClass" = "IOUSBControllerUserClient"

| "IOPowerManagement" = {"ChildrenPowerState"=0x4,"DevicePowerState"=0x3,"C$

| "IOProbeScore" = 0x0

| "IOPCITunnelCompatible" = Yes

| "this" = 0xffffff80d6cd8000

| "IOMatchCategory" = "IODefaultMatchCategory"

| "ISTKeepAway" = 0x1

| }

|

+-o XHCI Root Hub SS Simulation@0 <class IOUSBRootHubDevice, id 0x100000203,$

| +-o AppleUSBHub <class AppleUSBHub, id 0x100000239, registered, matched, a$

| +-o IOUSBInterface@0 <class IOUSBInterface, id 0x10000023d, !registered, !$

+-o XHCI Root Hub USB 2.0 Simulation@0 <class IOUSBRootHubDevice, id 0x10000$

| +-o AppleUSBHub <class AppleUSBHub, id 0x100000254, registered, matched, a$

| +-o IOUSBInterface@0 <class IOUSBInterface, id 0x100000256, !registered, !$

+-o My Passport 0740@3c100000 <class IOUSBDevice, id 0x1000005e2, registered$

+-o IOUSBCompositeDriver <class IOUSBCompositeDriver, id 0x1000005e5, !reg$

+-o MSC Bulk-Only Transport@0 <class IOUSBInterface, id 0x1000005e6, regis$

+-o IOUSBMassStorageClass <class IOUSBMassStorageClass, id 0x1000005e8, $

+-o IOSCSILogicalUnitNub@0 <class IOSCSILogicalUnitNub, id 0x1000005ea$

| +-o IOSCSIPeripheralDeviceType00 <class IOSCSIPeripheralDeviceType00$

| +-o IOBlockStorageServices <class IOBlockStorageServices, id 0x100$

| +-o IOBlockStorageDriver <class IOBlockStorageDriver, id 0x10000$

| +-o WD My Passport 0740 Media <class IOMedia, id 0x1000005f4, $

| +-o IOMediaBSDClient <class IOMediaBSDClient, id 0x1000005f5$

| +-o IOGUIDPartitionScheme <class IOGUIDPartitionScheme, id 0$

| +-o EFI System Partition@1 <class IOMedia, id 0x1000005fa,$

| | +-o IOMediaBSDClient <class IOMediaBSDClient, id 0x10000$

| +-o TIMEMACHINE@2 <class IOMedia, id 0x1000005fb, register$

| +-o IOMediaBSDClient <class IOMediaBSDClient, id 0x10000$

+-o IOSCSILogicalUnitNub@1 <class IOSCSILogicalUnitNub, id 0x1000005f0$

+-o SCSITaskUserClientIniter <class SCSITaskUserClientIniter, id 0x1$

 

-bash-3.2$

 

Rather than use your patched kext, I used the kext edit function in Clover's config.plist as shown here:

 

 

<key>KernelAndKextPatches</key>

<dict>

<key>KextsToPatch</key>

<dict>

<key>0</key>

<dict>

<key>Find</key>

<data>

PQABDw==

</data>

<key>Name</key>

<string>AppleUSBXHCI</string>

<key>Replace</key>

<data>

PQAADw==

</data>

</dict>

<key>1</key>

<dict>

<key>Find</key>

<data>

dVtJiw==

</data>

<key>Name</key>

<string>AppleUSBXHCI</string>

<key>Replace</key>

<data>

61tJiw==

</data>

</dict>

<key>2</key>

<dict>

<key>Find</key>

<data>

PQABDw==

</data>

<key>Name</key>

<string>AppleUSBXHCI</string>

<key>Replace</key>

<data>

PQAADw==

</data>

</dict>

<key>3</key>

<dict>

<key>Find</key>

<data>

gUkIAABA

</data>

<key>Name</key>

<string>AppleUSBXHCI</string>

<key>Replace</key>

<data>

gUkIAAAA

</data>

</dict>

<key>4</key>

<dict>

<key>Find</key>

<data>

RCQIAABA

</data>

<key>Name</key>

<string>AppleUSBXHCI</string>

<key>Replace</key>

<data>

RCQIAAAA

</data>

</dict>

<key>5</key>

<dict>

<key>Find</key>

<data>

AEAAQYtG

</data>

<key>Name</key>

<string>AppleUSBXHCI</string>

<key>Replace</key>

<data>

AAAAQYtG

</data>

</dict>

<key>6</key>

<dict>

<key>Find</key>

<data>

AcaDfw==

</data>

<key>Name</key>

<string>AppleUSBXHCI</string>

<key>Replace</key>

<data>

AMaDfw==

</data>

</dict>

<key>7</key>

<dict>

<key>Find</key>

<data>

dSZIi7vo

</data>

<key>Name</key>

<string>AppleUSBXHCI</string>

<key>Replace</key>

<data>

6yZIi7vo

</data>

</dict>

</dict>

</dict>

 

Hope this helps you to figure out the problem.

Link to comment
Share on other sites

TimeWalker,

How did you make this patch using KextPatcher in Clover.

Could you paste the config.plist line here for me to try?

Thanks.

 

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!

Link to comment
Share on other sites

Hi Zenith 432,

First thanks for all your effort on this USb3 problem.

I have the same problem with the USB Drive showing that it is mounted under the High-Speed port when it is in fact the SuperSpeed port. The command you suggested in post #8 gives Built-in as the Card Type property.

 

I also have the same issue with Clover's patch (can't remember with the patched kext, I'll try later). The USB3 ports seems to be duplicated in System Info.

 

post-158318-0-14230400-1362067212_thumb.png

Link to comment
Share on other sites

I've resolved the Sleep issue on my system. Discovered that it was due to an error in the DSDT, not the xHC.

 

I've fixed the DSDT, eliminated the bottom two patches in the patch-list in post #1, and now sleep works, including being able to wake the system with a USB keyboard connected to the xHC (a.k.a. PME).

 

Hardware: Intel motherboard with H67 chipset, Renesas uPD720200F1 with most recent firmware (3.0.3.4).

  1. First, just to set the record straight, the uPD720200 does support chip-internal restore, contrary to what I said in post #23. This is a mandatory feature in the xHC spec.
     
  2. Topology-wise, Intel Panther-Point is integrated into the south-bridge (PCH), so it is connected directly to the PCIe host-bridge (root complex.) All other xHC chips, whether in a separate chip on the motherboard, or PCIe expansion card, are connected behind a PCIe root port (PCI2PCI bridge.) In other words, have one more-level of indirection in the data path to RAM/processor core.
     
  3. The board's DSDT has a method called IOKS that wrecks power-management. It attempts to access the PS/2 keyboard and mouse, and goes into an infinite loop, because H67 doesn't have a PS/2 controller (!).
     
  4. DSDT has a method call _PTS ("prepare to sleep") that is executed by AppleACPIPlatformExpert.kext before the system goes to sleep or shuts down.
     
  5. _PTS calls IOKS to do something with PS/2 keyboard/mouse, and hangs.
     
  6. AppleACPIPlatformExpert has a watchdog-timer on this ACPI method, and times out after 75 seconds, decides _PTS is in an infinite loop, aborts it, and proceeds to complete the sleep/shutdown sequence anyway.
     
  7. In _PTS, after the code that calls IOKS, there is code to prepare the PCIe root ports for PME.
     
  8. As a result of the abort of _PTS, the PCIe root ports are not properly prepared for sleep.
     
  9. Since PME is not enabled on the root port, the xHC chip connected to the port does not receive Aux power during sleep. This causes the chip to lose all context, and come back from sleep as if it was just turned on from a power-off state.

So the result of the problem with IOKS was

  • Sleep and shutdown process would take 75 seconds...
  • PCIe devices on root ports were completely shut down during sleep and could not recover any state existing before the sleep.

It took quite a bit of work to figure this out...

 

P.S. The resolution was to eliminate IOKS and all calls to IOKS in the DSDT. I also removed the nonexistent PS/2 devices, along with non-existent sleep-button, floppy controller and LPT port.

  • Like 7
Link to comment
Share on other sites

 Share

×
×
  • Create New...