Jump to content

USB sleep then wake "Device Removal" problem


pcb355
 Share

151 posts in this topic

Recommended Posts

I'm new to this forum, but I have been active in OSX86 development for some time. I'm trying to solve a problem with USB on an otherwise perfect OSX86 system. It involves sleep functionality on the EHCI USB bus. Upon wake from sleep, if a USB drive has been attached, the system displays the "Device Removal" warning dialog. I have tried everything on the internet available for this problem, including Slice's kexts, AnV's kexts, teh EHCISleepEnabler.kext, variois IOPCIFamily.kexts, BIOS settings, all to no avail. USB is working absolutly perfect except for this issue, as is the rest of the system. It seems to me that the problem (at least on this MB, and probably other ICH10R MBs) is related to how the USB drivers initialize the ports, and thus determine their power management (sleep) capabilities. On this system, the EHCI USB ports are seen as PCI devices, rather than as built-in devices. This means that the driver will turn off the port and turn it back on again instead of suspending and resuming the port like it should.

 

I've written device drivers before and done some XCode development, and I'm currently getting my build environment correct, and starting to test some simple changes in the sleep capability section of AppleUSBEHCI.

 

Am I heading in the right direction?

 

If so, any pointers or other suggestions?

 

Thanks for the feedback.

Link to comment
Share on other sites

I'm having the same problem on my GA EP45T DS3 board and Disableing or enabling the wake on usb and keyboard in bios does not have an affect I still get the Device removal error for my usb drives.. This does not happen like this on my mac book

I have been trying to fix this one for weeks looking for any hints on the web with out success. I can not belive only you and me are geting this error upon wake up my board is also ICH10 ,there must be more people getting this one

I think a possible fix might be through editing the usb wake parameters on the DSDT but I'm not quite sure how exactly that works we might have to compare a mac pro DSDT with our ones

Link to comment
Share on other sites

I would like to coordinate and maybe we can solve this together. I haven't yet gotten into the DSDT patching yet, but after doing some research, it seems that it's superior to the /Extra method for some devices, like audio. I have a few questions for you:

 

On your ethernet, you are using the DSDT patch instead of any replacement kext in the /Extra folder correct? If so, are you able to get full functionality, in other words, bonjour, AFP, DHCP reconnect after sleep, etc? I had to use the Psystar 1.8.1 extension inside of the IONetworkingFamily.kext in the /Extra folder for complete functionality.

 

On the audio, do you have full functionality, including front panel headphone switching and mic input working? I have full functionality using the legacy kexts (stickpin ALC889a Beta5) for HDA as well as the HDAEnabler.kext in the /Extra folder. One slight problem I have is that there are a couple of sound assertion errors in the system log on bootup, and there is an additional delay on bootup of about 10 seconds, and this is probably related. My legacy kexts are probably not quite right for my system. Would you mind sharing yours with me?

 

I've been using the older disabler.kext in the /Extra folder, and it has worked well so far. You are using a patch in the DSDT that doesn't require this. I just ran into another problem, as I'm using the G92 based video card, and there is a problem with AppleUpstreamUserClient.kext, which must be disabled, or use of iTunes results in a jerky system. There is a newer disabler which has just the CPUPM and this kext disabled, which solves this problem for me. So I would probably have to continue using some sort of disabler, at least for this, correct?

 

I'm also using AnV's AppleSMBIOS.kext, and Psystar's OpenHaltRestart.kext. I'm assuming that with a proper DSDT these aren't needed either?

 

Thanks so much for any and all feedback.

Link to comment
Share on other sites

On your ethernet, you are using the DSDT patch instead of any replacement kext in the /Extra folder correct? If so, are you able to get full functionality, in other words, bonjour, AFP, DHCP reconnect after sleep, etc? I had to use the Psystar 1.8.1 extension inside of the IONetworkingFamily.kext in the /Extra folder for complete functionality.

 

I have not included Ethernet on my DSDT yet. I am using EFI string for it. To be able to work bonjour and stuff I also had to use the Psystar realtek r1000 driver 1.8.1 , this only worked on 10.5.6 not 10.5.5

On the audio, do you have full functionality, including front panel headphone switching and mic input working? I have full functionality using the legacy kexts (stickpin ALC889a Beta5) for HDA as well as the HDAEnabler.kext in the /Extra folder. One slight problem I have is that there are a couple of sound assertion errors in the system log on bootup, and there is an additional delay on bootup of about 10 seconds, and this is probably related. My legacy kexts are probably not quite right for my system. Would you mind sharing yours with me?

I have fully working 7.1 Audio no errors using no front panel legacy kexts as my case does not have a front panel from this thread http://www.insanelymac.com/forum/index.php...st&p=998397

I've been using the older disabler.kext in the /Extra folder, and it has worked well so far. You are using a patch in the DSDT that doesn't require this. I just ran into another problem, as I'm using the G92 based video card, and there is a problem with AppleUpstreamUserClient.kext, which must be disabled, or use of iTunes results in a jerky system. There is a newer disabler which has just the CPUPM and this kext disabled, which solves this problem for me. So I would probably have to continue using some sort of disabler, at least for this, correct?

I'm also using AnV's AppleSMBIOS.kext, and Psystar's OpenHaltRestart.kext. I'm assuming that with a proper DSDT these aren't needed either?

There comes the advantages of using the DSDT patcher and the DSDT override method. Once you fix your DSDT you can actually run AppleIntelCPU.kext without Disabler problems also you can get HPET and sleep working too..

I personally use a mix of EFI strings DSDT override and Extra/Extensions.mkext methods to run a totally vanilla Sytem/Library/Extensions and aflexible upgrade hassle free system.

here are my Extra kexts :

AppleDecrypt.kext

 

SMBios from karaakeha1

AppleSMBIOS.kext

 

JmicronATA fix from CycloneFr

LegacyJMicronATA.kext

 

for ICH10 and Yellow drive icon fix from netkas

LegacyAppleAHCIPort.kext

LegacyAppleIntelPIIXATA.kext

LegacyIOAHCIBlockStorage.kext

 

for Audio from tmongkol

LegacyHDAController.kext

LegacyHDAPlatformDriver.kext

 

Extra_Extensions.zip

 

Note : the r1000 from psystar I had to put in S/L/E some how it did not work in the extra folder

how did you do yours?

 

 

 

Coming back to our real subject the notorious Device Removal error of USB drives upon wake up .......

 

I have noticed something in my logs

Mar  2 12:15:49 localhost kernel[0]: .534	AppleUSBOHCI[0xacf0000]::CheckSleepCapability - controller will be unloaded across sleep

 

This obviously addresses the issue we have as the controller unloadds across sleep

 

can we edit something in the AppleUSBOHCI kext?

 

what do you think

Link to comment
Share on other sites

I have the exact same problem (USB functions lost during sleep).

 

I recently switched from a P35 (ICH9R) based board to a P45 (ICH10R) based board. With the P35 board, using IOUSBFamily.kext patched by Slice (see thread), I was able to get full USB functionality, including wake from sleep using a USB keyboard. With the P45 board, USB functionality behaves exactly like the P35 board with the unpatched IOUSBFamily. Using the patched IOUSBFamily.kext from Slice with the P45 board made no difference.

 

Booting the P45 board with -v gives the following information (regardless of using vanilla or Slice-patched IOUF.kext):

 

USBF: 0.356 AppleUSBOHCI[0x8945000]::CheckSleepCapability - controller will be unloaded across sleep.

 

According to Slice in the above thread, he did not correct anything in the kext for ICH10, as it was "added by Apple".

 

Strangely though, weaksauce12 states that the EP45-UD3P board works OOB with regards to USB (wake from sleep using the keyboard; see thread).

 

I think we should beg Slice to take another look at the IOUSBFamily.kext with specific focus on the P45 (ICH10) chipset.

 

Coming back to our real subject the notorious Device Removal error of USB drives upon wake up .......

 

I have noticed something in my logs

Mar  2 12:15:49 localhost kernel[0]: .534	AppleUSBOHCI[0xacf0000]::CheckSleepCapability - controller will be unloaded across sleep

 

This obviously addresses the issue we have as the controller unloadds across sleep

 

can we edit something in the AppleUSBOHCI kext?

 

what do you think

 

I don't think the ICH10 chipset contains any USBOHCI controllers. I've installed the Apple Dev program USB Prober, which doesn't find any OHCI controllers. Probably a bug (mistyping?) in the IOUSBFamily.kext because AppleOHCIUSB.kext is not loaded (AppleEHCIUSB and AppleUHCIUSB both are loaded).

 

Lets beg Slice (see my other reply) to look at his patches for ICH10 once again.

Link to comment
Share on other sites

I'm having the same issue since upgrading to 10.5.6, I'll give the scripts a whirl and report back....or not as the case may be :D

 

I've also lost time machine functionality since the upgrade but that's a load of other threads for to trawl to see if there's a fix

Link to comment
Share on other sites

Sorry, but I don't think this is the solution we are looking for.

 

The problem seems to be that the USB driver in OS X (in this case the AppleUSBEHCI.kext plugin in the IOUSBFamily.kext) recognizes the ICH10 USB controller as not being sleep capable.

 

You can download the source code from Apple. If you look inside, you'll find that every USB controller (EHCI) that doesn't contain a specific Apple phrase (AAPL) will be treated as being located on an expansion slot (PCI) and therefore not sleep capable.

 

If you go to System Profiler/USB, you'll see that the "Host Controller Location" is "Expansion Slot". We need to have OS X recognize the location as being built in (Built In USB), which is the case for other USB busses listed in the System Profiler (under USB Bus).

 

Also, inside the AppleUSBEHCI.kext, where the distinction is being made between sleep capable and not sleep capable, there is a reference to USBOHCI (note the O) even though we are dealing with the EHCI controller driver.

 

We need to ask Slice to look at his patched kexts again or to find a way to make OS X recognize EHCI controllers as being built in and no located on a expansion slot.

Link to comment
Share on other sites

I agree. The root of the problem is the designation of PCI vs Built-in on the EHCI USB ports. There are two ways to deal with this, IMHO:

 

1. Work with the DSDT or other method to modify the IORegistry to indicate Built-in for the EHCI USB ports. This is the best method as it should work going forward with the standard Apple vanilla USB drivers.

 

2. Modify the source code for the EHCI driver to set the correct sleep capability. This is not as clean as it requires putting the entire modified IOUSBFamily.kext in the /Extra folder, which may cause problems with future updates.

 

On my system, USB is working perfectly, sleep and wake from sleep with KB and mouse, just the "Device Removal" problem on USB storage devices, so I would prefer a vanilla USB driver solution with this problem fixed. I will be working on a DSDT solution first, and I will report back on my progress.

Link to comment
Share on other sites

On the Psystar 1.8.1 driver, it has to be in the plug-ins folder of the IONetworkingFamily.kext, as it has dependencies there. I took the latest 10.5.6 version of this, added the Psystar kext to it, and then put this in the /Extra folder. It's not the most elegant solution, as a future update to IONetworkingFamily might break this, but it's the best solution I've found so far for full networking functionality on the Realtek 8111C ethernet chipset.

Link to comment
Share on other sites

Yes, I agree too. Vanilla kexts are preferred. If you are able to find a DSDT or perhaps a EFI string solution, that will be nice. Looking forward to hearing about your progress.

 

In the meantime I have asked Slice to take another look at his patches for IOUSBFamily.kexts. Let's hope he responds (always a good idea to ride two horses).

Link to comment
Share on other sites

Sorry, but I don't think this is the solution we are looking for.

 

If you go to System Profiler/USB, you'll see that the "Host Controller Location" is "Expansion Slot". We need to have OS X recognize the location as being built in (Built In USB), which is the case for other USB busses listed in the System Profiler (under USB Bus).

 

on my mac book I Don't have this problem and USB high speed bus' Host Controller reports as built in where as my GA EP45T DS3 reports it as expansion slot.

 

But on my GA EP45T DS3 when I insert my USB Drive to any other UHCI USB port which reports as built in still I get the "Device Removal" isn't that weird too.??

My expectation would be that the built in UHCI ports would work with out a problem which is not the case here...

Are we missing something ?

 

Here is a document about Intel EHCI USB for Developers.

May be we can understand better how EHCI works

INTEL EHCI USB

 

Yes I would also like to try to report my EHCI ports as Built in and see if we can nail it this way...

Link to comment
Share on other sites

This is the edit I made to the stock AppleUSBEHCI.kext:

 

        if (!_hasPCIPwrMgmt)
       {
//            USBError(1, "AppleUSBOHCI[%p]::CheckSleepCapability - controller will be unloaded across sleep",this);
//            _controllerCanSleep = false;
//            setProperty("Card Type","PCI");

           // My power management fix
           _controllerCanSleep = true;
           setProperty("Card Type","Built-in");
	}

 

This works on my system, a GA-EP45-Extreme.

 

I've attached the compiled AppleUSBEHCI.kext to test, which has only the change above from the current vanilla 10.5.6 driver.

AppleUSBEHCI.kext.zip

Link to comment
Share on other sites

Out of interest lads, what does your Host & PCi bridge show up as when you run LSPCI ?

As I'm wondering if this will work for GA-G31M-S2L boards as well, that shows up as the following

 

00:00.0 Host bridge [0600]: Intel Corporation 82G33/G31/P35/P31 Express DRAM Controller [8086:29c0] (rev 10)

00:01.0 PCI bridge [0604]: Intel Corporation 82G33/G31/P35/P31 Express PCI Express Root Port [8086:29c1] (rev 10)

00:1c.0 PCI bridge [0604]: Intel Corporation 82801G (ICH7 Family) PCI Express Port 1 [8086:27d0] (rev 01)

00:1c.1 PCI bridge [0604]: Intel Corporation 82801G (ICH7 Family) PCI Express Port 2 [8086:27d2] (rev 01)

00:1d.0 USB Controller [0c03]: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #1 [8086:27c8] (rev 01)

00:1d.1 USB Controller [0c03]: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #2 [8086:27c9] (rev 01)

00:1d.2 USB Controller [0c03]: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #3 [8086:27ca] (rev 01)

00:1d.3 USB Controller [0c03]: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #4 [8086:27cb] (rev 01)

00:1d.7 USB Controller [0c03]: Intel Corporation 82801G (ICH7 Family) USB2 EHCI Controller [8086:27cc] (rev 01)

00:1e.0 PCI bridge [0604]: Intel Corporation 82801 PCI Bridge [8086:244e] (rev e1)

00:1f.0 ISA bridge [0601]: Intel Corporation 82801GB/GR (ICH7 Family) LPC Interface Bridge [8086:27b8] (rev 01)

00:1f.1 IDE interface [0101]: Intel Corporation 82801G (ICH7 Family) IDE Controller [8086:27df] (rev 01)

00:1f.2 IDE interface [0101]: Intel Corporation 82801GB/GR/GH (ICH7 Family) SATA IDE Controller [8086:27c0] (rev 01)

00:1f.3 SMBus [0c05]: Intel Corporation 82801G (ICH7 Family) SMBus Controller [8086:27da] (rev 01)

Link to comment
Share on other sites

Thanks for the feedback.

 

Alas, I'm having an additional problem: After resume, the attached USB drive has slower read/write speeds until it's ejected and then reinserted. A very handy little utility for checking drive speed is "AJA System Test", google it it's a free download. Could you check to see whether you have this little problem as well?

 

Thanks so much.

Link to comment
Share on other sites

Out of interest lads, what does your Host & PCi bridge show up as when you run LSPCI ?

As I'm wondering if this will work for GA-G31M-S2L boards as well, that shows up as the following

 

00:00.0 Host bridge [0600]: Intel Corporation 82G33/G31/P35/P31 Express DRAM Controller [8086:29c0] (rev 10)

00:01.0 PCI bridge [0604]: Intel Corporation 82G33/G31/P35/P31 Express PCI Express Root Port [8086:29c1] (rev 10)

00:1c.0 PCI bridge [0604]: Intel Corporation 82801G (ICH7 Family) PCI Express Port 1 [8086:27d0] (rev 01)

00:1c.1 PCI bridge [0604]: Intel Corporation 82801G (ICH7 Family) PCI Express Port 2 [8086:27d2] (rev 01)

00:1d.0 USB Controller [0c03]: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #1 [8086:27c8] (rev 01)

00:1d.1 USB Controller [0c03]: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #2 [8086:27c9] (rev 01)

00:1d.2 USB Controller [0c03]: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #3 [8086:27ca] (rev 01)

00:1d.3 USB Controller [0c03]: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #4 [8086:27cb] (rev 01)

00:1d.7 USB Controller [0c03]: Intel Corporation 82801G (ICH7 Family) USB2 EHCI Controller [8086:27cc] (rev 01)

00:1e.0 PCI bridge [0604]: Intel Corporation 82801 PCI Bridge [8086:244e] (rev e1)

00:1f.0 ISA bridge [0601]: Intel Corporation 82801GB/GR (ICH7 Family) LPC Interface Bridge [8086:27b8] (rev 01)

00:1f.1 IDE interface [0101]: Intel Corporation 82801G (ICH7 Family) IDE Controller [8086:27df] (rev 01)

00:1f.2 IDE interface [0101]: Intel Corporation 82801GB/GR/GH (ICH7 Family) SATA IDE Controller [8086:27c0] (rev 01)

00:1f.3 SMBus [0c05]: Intel Corporation 82801G (ICH7 Family) SMBus Controller [8086:27da] (rev 01)

 

Well, try it out. Do you get the "... controller will be unloaded across sleep" message during boot? If so, it should work. ICH7 support was added by Slice in his patches IOUSBFamily.kext (see thread).

Link to comment
Share on other sites

Well, try it out. Do you get the "... controller will be unloaded across sleep" message during boot? If so, it should work. ICH7 support was added by Slice in his patches IOUSBFamily.kext (see thread).

 

Yes I do, I'll give it a try later (when the wife goes out and I can get away from the decorating :rolleyes: )

Link to comment
Share on other sites

  • 2 weeks later...

Don't panic, I didn't break it.....just spent the best part of the week on the beer :D

 

I'd forgotten to do the "sudo rm -r -v /System/Library/Extensions/PCGenUSB*

sudo rm -r -v /System/Library/Extensions/IOUSBFamily.kext/Contents/PlugIns/PCGenUSB*" bit

 

Sleep is all working fine and dandy now ;)

Link to comment
Share on other sites

  • 3 weeks later...

Hi there,

I just read this. Can't say that I ever had that problem, but maybe you'd be interested in a possible dsdt fix. (I copied the AAPL part from a Mac Pro dsdt) - system profiler reports ehci location as built-in:

 

			Device (USB7)
		{
			Name (_ADR, 0x001D0007)
			OperationRegion (U7CS, PCI_Config, 0x54, 0x04)
			Field (U7CS, DWordAcc, NoLock, Preserve)
			{
					,   15, 
				PMES,   1
			}

			Device (HUB7)
			{
				Name (_ADR, 0x00)
				Device (PRT1)
				{
					Name (_ADR, 0x01)
				}

				Device (PRT2)
				{
					Name (_ADR, 0x02)
				}

				Device (PRT3)
				{
					Name (_ADR, 0x03)
				}

				Device (PRT4)
				{
					Name (_ADR, 0x04)
				}

				Device (PRT5)
				{
					Name (_ADR, 0x05)
				}

				Device (PRT6)
				{
					Name (_ADR, 0x06)
				}

				Device (PRT7)
				{
					Name (_ADR, 0x07)
				}

				Device (PRT8)
				{
					Name (_ADR, 0x08)
				}
			}

			Name (_PRW, Package (0x02)
			{
				0x0D, 
				0x03
			})
			Method (_S3D, 0, NotSerialized)
			{
				Return (0x03)
			}

			Method (_S4D, 0, NotSerialized)
			{
				Return (0x03)
			}

			Method (_DSM, 4, NotSerialized)
			{
				Store (Package (0x07)
					{
						"AAPL,current-available", 
						0x05DC, 
						"AAPL,current-extra", 
						0x03E8, 
						"AAPL,current-in-sleep", 
						0x0BB8, 
						Buffer (0x01)
						{
							0x00
						}
					}, Local0)
				DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
				Return (Local0)
			}
		}

 

Maybe this fixes your problems (by having those AAPL entries) :(

Link to comment
Share on other sites

Thanks for the reply and possible direction for a fix. I have just gotten into the DSDT compiling, and dabbled a little in it. On my system, other than this particular fix (if it works) DSDT patching doesn't result in a better system, as I still need kexts that provide more functionality than what DSDT can do. That being said, I would love to fix this USB problem with a DSDT solution, as it would be much cleaner than patched USB kexts.

 

As I'm very new to the DSDT and ACPI language, I don't know how this Mac Pro USB info would be added to the current DSDT that I have. In hopes that some other more knowledgeable person can help, I've attached the current stock DSDT dsl file for this motherboard, the Gigabyte EP45-Extreme. If anyone can suggest an edit, I'll be more than happy to give it a try.

ex45f8DSDTdsl.zip

Link to comment
Share on other sites

Hi,

 

I just want to report that I observe this problem exactly as you have described on my system (see below) and I am lucky that i finally found this thread. In addition to the "device removal error" with USB storage devices I lose my sound output via iMic after sleep.

Apr  8 22:46:24 u2c kernel[0]: System Wake
Apr  8 22:46:24 u2c kernel[0]: USB (UHCI):Port 2 on bus 0x5d connected or disconnected
Apr  8 22:46:24 u2c kernel[0]: USB (UHCI):Port 1 on bus 0x1a connected or disconnected
Apr  8 22:46:24 u2c kernel[0]: USB (UHCI):Port 1 on bus 0x3a connected or disconnected

USB Bus:

 Host Controller Location:    Built In USB
 Host Controller Driver:    AppleUSBUHCI
 PCI Device ID:    0x3a37
 PCI Revision ID:    0x0000
 PCI Vendor ID:    0x8086
 Bus Number:    0x1a

iMic USB audio system:

 Product ID:    0x07af
 Vendor ID:    0x077d
 Version:    0.05
 Speed:    Up to 12 Mb/sec
 Manufacturer:    Griffin Technology, Inc
 Location ID:    0x1a100000
 Current Available (mA):    500
 Current Required (mA):    100

 

 

(I use an iMic because I could not get onboard sound work reliable. The legacy extensions make the sound work but there are hundreds of assertion errors in the system log, which I think is just too much.)

 

I did not try pcb355's patched kext yet, because I am not sure how to install this. Does "Kext Helper.app" do this reliable?

 

My approach until now was to avoid messing with S/L/E directly and except for this USB sleep problem it's working well.

Link to comment
Share on other sites

This is the edit I made to the stock AppleUSBEHCI.kext:

 

I tried your kext in S/L/E and as you said it fixed the device removal errors for storage devices and the iMic. So far so great! Big thanks for that.

 

I did some measurements on throughput before and after sleep and can confirm that there still is a problem.

 

After fresh reboot: read :35 MB/s write 34,5 MB/s

sleep and wake: read 12 MB/s write 12 MB/s

 

I believe something with USB is still messed up. Unfortunately I never did anything with dsdt until now and after reading a dsdt primer for Linux I think that's pretty strange stuff, but it could be the way to a real solution. I don't like patched kexts in S/L/E.

Link to comment
Share on other sites

i wanted to download the AJA System test tool. It seems, they have removed the direct download it from the age website.

 

but i found out a way to get it:

i simply downloaded the first driver i found from the aja website (AJA KONA 2 Software 6.0.3.mpkg).

i displayed the package contend.

i dragged Archive.pax.gz to the desktop and clicked on it to unpack it.

in the resulted folder "Archive" you can find the utility in /Applications/AJA Utilities/

Link to comment
Share on other sites

 Share

×
×
  • Create New...