Jump to content

USB sleep then wake "Device Removal" problem


  • Please log in to reply
150 replies to this topic

#121
ApexDE

ApexDE

    InsanelyMac Geek

  • Members
  • PipPipPipPip
  • 217 posts
I have a Alu Keyboard too. Wake doesn't work with it. Funny thing is that keypresses ARE recognised while sleeping, but they don't result in the System waking up. After sleeping i have the following log entries:

16.09.09 22:29:13	kernel	Wake reason = UHC6
16.09.09 22:29:13	kernel	System Wake
16.09.09 22:29:13	kernel	Previous Sleep Cause: 0
16.09.09 22:29:13	kernel	USB (EHCI):Port 5 on bus 0xfa has remote wakeup from some device
16.09.09 22:29:13	kernel	USB (UHCI):Port 2 on bus 0x5a has remote wakeup from some device

So, pressing Keys on the Keyboard was recognised (EHCI Port 5 on bus 0xfa) and SHOULD have resulted in wakeup, but the System DID wake when pressing the Mouse (UHCI Port 2 on bus 0x5a).

Strange, huh? Maybe someone gets a idea :). I guess it's a bug in the Gigabyte BIOS.

#122
zoltankr

zoltankr

    zoliky

  • Members
  • PipPipPipPipPipPip
  • 427 posts
  • Gender:Male

I have a Alu Keyboard too. Wake doesn't work with it. Funny thing is that keypresses ARE recognised while sleeping, but they don't result in the System waking up. After sleeping i have the following log entries:

16.09.09 22:29:13	kernel	Wake reason = UHC6
16.09.09 22:29:13	kernel	System Wake
16.09.09 22:29:13	kernel	Previous Sleep Cause: 0
16.09.09 22:29:13	kernel	USB (EHCI):Port 5 on bus 0xfa has remote wakeup from some device
16.09.09 22:29:13	kernel	USB (UHCI):Port 2 on bus 0x5a has remote wakeup from some device

So, pressing Keys on the Keyboard was recognised (EHCI Port 5 on bus 0xfa) and SHOULD have resulted in wakeup, but the System DID wake when pressing the Mouse (UHCI Port 2 on bus 0x5a).

Strange, huh? Maybe someone gets a idea :). I guess it's a bug in the Gigabyte BIOS.

Yes, the problem happens only on 'EHCI' ports.

#123
Niatross

Niatross

    InsanelyMac Protégé

  • Members
  • Pip
  • 8 posts

Apex,

Added the fix to my blog, http://stellarola.tumblr.com/

Thanks a lot for this, it's sure to help out a lot of folks. :)

-Stell


Stell,

My DSDT.aml only has USB0, USB1, USB2 and USB3 (these are all UHCI). I have no EHCI ports in my DSDT.aml. What do I need to do?

#124
enb14

enb14

    InsanelyMac Legend

  • Members
  • PipPipPipPipPipPipPip
  • 615 posts
  • Gender:Male
  • Location:Central America
Guys I would like to know what's the Store (Package (0x0X) that I should use?

Some guys use Store (Package (0x04) some Store (Package (0x06) so what should be mine?

Here is my EUSB

Device (EUSB)
{
Name (_ADR, 0x001D0007)
Name (_S4D, 0x02)
Name (_S3D, 0x02)
Name (_S2D, 0x02)
Name (_S1D, 0x02)
Method (_PRW, 0, NotSerialized)
{
Return (GPRW (0x0D, 0x03))
}

Method (_DSM, 4, NotSerialized)
{
Store (Package (0x04)
{
"AAPL,clock-id",
Buffer (0x01)
{
0x01
},

"device_type",
Buffer (0x05)
{
"EHCI"
}
}, Local0)

DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
Return (Local0)
}
}

Attached Files



#125
mitch_de

mitch_de

    InsanelyMacaholic

  • Local Moderators
  • 2,879 posts
  • Gender:Male
  • Location:Stuttgart / Germany
04 , not 06 because you have 4 items you want to inject:
"AAPL,clock-id",
0x01
"device_type",
"EHCI"

that 0x number always must fit with count of injected items !

#126
enb14

enb14

    InsanelyMac Legend

  • Members
  • PipPipPipPipPipPipPip
  • 615 posts
  • Gender:Male
  • Location:Central America
Ok thanks for that mitch_de.

Now I just need to wonder why my USB still has the error EHCI can handle control from BIOS, in the system profiler shows as Built-in (USB Bus and USB High-Speed Bus) any clues?

#127
goodbye losers

goodbye losers

    InsanelyMac Sage

  • Members
  • PipPipPipPipPip
  • 260 posts
@ ApexDE

ich denke mal das DE in deinem Namen bedeutet Deutschland...ich hab das problem das wenn ich die datei wieder in aml umwandeln will, lauter errors kommen. kannst du mir freundlicher weise meine dsdt bearbeiten wegen des usb problems!? mein usb funktioniert nach dem aufwecken vom sleep nicht (tastatur und maus). wäre dir sehr dankbar. ich bekomme das nicht hin, hab beim recompilieren immer errors...bei mir steht beim booten 2x appleusbohci -- CheckSleepCapability - controller will be unloaded across sleep....ich kann mit tastatur aufwecken, tastatur und maus funtionieren danach nicht mehr

gruß aus berlin, thomas

Attached Files



#128
ApexDE

ApexDE

    InsanelyMac Geek

  • Members
  • PipPipPipPip
  • 217 posts
which errors do you get when you try to recompile?
how does your decompiled (dsl) dsdt look like?

#129
Shortland

Shortland

    InsanelyMac Protégé

  • Members
  • Pip
  • 8 posts
Dalton, which error message were you getting? device removal error or "this disk was improperly ejected" (I know, 6 of one, half a dozen of the other...) looking for a U100 fix too :s

#130
cmise

cmise

    InsanelyMac Protégé

  • Just Joined
  • Pip
  • 2 posts

OK guys, i managed to patch my DSDT to get the EHCI USB Ports sleeping.

Unloading the Controller during Sleep results in USB Drives being removed by force without unmounting, which might result in data-loss:

kernel	USBF:	0.392	AppleUSBEHCI[0x6838800]::CheckSleepCapability - controller will be unloaded across sleep

The Apple USB Drivers search for a device property "AAPL,clock-id", if it is found the ports are flagged built-in, if not, they will be unloaded during sleep. I renamed my EHCI Devices to EHC1 and EHC2. This is just cosmetical, search for your EHCI Devices by the adresses (e.g 0x001D0007 , 0x001A0007 for Gigabyte)


Here is my EHCI DSDT Part:


Device (EHC1)
			{
				Name (_ADR, 0x001D0007)
				Method (_S3D, 0, NotSerialized)
				{
					If (LEqual (OSFL, 0x02))
					{
						Return (0x02)
					}

					Return (0x03)
				}

				Name (_PRW, Package (0x02)
				{
					0x0D, 
					0x03
				})
						Method (_DSM, 4, NotSerialized)
						{
						   Store (Package (0x04)
							   {
								 "AAPL,clock-id",
								 Buffer (0x01)
								 {
									 0x01
								 },
								 "device_type",
								 Buffer (0x05)
								 {
									"EHCI"
								 }
								}, Local0)
							DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
							Return (Local0)
						}
			

			}

			Device (EHC2)
			{
				Name (_ADR, 0x001A0007)
				Method (_S3D, 0, NotSerialized)
				{
					If (LEqual (OSFL, 0x02))
					{
						Return (0x02)
					}

					Return (0x03)
				}

				Name (_PRW, Package (0x02)
				{
					0x0D, 
					0x03
				})
						Method (_DSM, 4, NotSerialized)
						{
						   Store (Package (0x04)
							   {
								 "AAPL,clock-id",
								 Buffer (0x01)
								 {
									 0x02
								 },
								 "device_type",
								 Buffer (0x05)
								 {
									"EHCI"
								 }
								}, Local0)
							DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
							Return (Local0)
						}

			}


Thanks ApexDE

After patch this, my EHCI device is build-in. and sleep is ok.

#131
phile

phile

    InsanelyMac Protégé

  • Members
  • Pip
  • 15 posts
Any Fix for this Problem?

Inserting a USB mass storage device(a small flash or thumb drive will do) after one or more sleep cycles causes a KP or system freeze, which can either take the form of a restart message or a USB mouse pointer freeze, depending on how your DSDT has been edited, forcing a hard restart of the computer.

Others have alluded to this problem(see Post #42 in this thread) and in other threads, but no one has discussed it or come up with a solution as far as I can tell.

Otherwise Sleep/Restart/Shutdown works fine on my i7 GA-EX58-UD3R system. I can insert a USB Flash drive if I have not previously used Sleep and it comes up as expected on the desktop and can be ejected. With the USB Flash drive/Mass Storage Device still mounted, I can sleep the computer and wake it up again - the USB drive remounts nicely with no device removal errors. And I can eject it too, no problem. But if I reinsert the USB drive after one or more sleep cycles, the freeze takes place once again, forcing a hard restart.

All my USB ports are coming up as "Built-in USB" ports. The keyboard/mouse and any mass storage devices plugged into any of the USB ports are properly recognized. I have tried various DSDT edits in Device USB0-USB5 and USBE and USE2 as well as the DSM non-serialized Method entry near the top of the DSDT script. These edits fixed the Device Removal Error problem, of course, and improved USB KB and mouse usage, but they do not fix this specific problem.

Most of my testing has been with 10.5.8, but the problem also occurs with 10.6.2 as well. Firewire devices mount and unmount(external hard drives and audio interfaces) with no problem after sleep. It's just with USB mass storage devices after one or more sleep cycles where this problem occurs. Older rigs(10.5.4 + BadAxe Mobo(XBX2) with an ICH7 chipset have no problem. Does this happen with your install? Any ideas? Thanks.

#132
phile

phile

    InsanelyMac Protégé

  • Members
  • Pip
  • 15 posts
Well I may have found a fix to my previous post about inserting a USB mass storage device after a sleep cycle which might be useful to someone. Add AppleUSBEHCI/OHCI and UHCI kexts to S/L/E - they can be downloaded from kexts.com in the drivers section, the title of the download being Intel USB2 EHCI Controller. Be sure, though, that Pystar's OHR(OpenHaltRestart) kext is also in S/L/E(I used the earlier version) or this fix won't work. You can also put the three USB extensions, along with OHR, in E/E and repack the extensions.mkext file too. Either method works, the latter at least having the virtue of keeping foreign kexts out of S/L/E. I was hoping to find a DSDT solution to this problem, but no luck with this one unless someone out there knows how to take care of this problem in DSDT.

#133
thepiecesfit

thepiecesfit

    InsanelyMac Protégé

  • Members
  • PipPip
  • 67 posts
Not working. GA-P35-DS3L rev 2 SL 10.6.4. Got the dsdt to compile without errors , like the first post , added the code to USBE etc etc. Sleep no longer works after this patch.

Went back to original dsdt. Still get ejection error when using sleep. Not working with this mobo for me :\

#134
oSxFr33k

oSxFr33k

    InsanelyMac Legend

  • Members
  • PipPipPipPipPipPipPip
  • 787 posts
  • Gender:Male
  • Interests:Sound and Graphic Design. Electronics in general.
ApexDE,

I have combined a bit of Both Slice's Dell D830/D630 and Brett's M1330 Laptops EHCI scripts and still have the USB warning after wake.

The EHCI say Built in from IoRegistry Explorer.

Could you have a quick look at the EHC sections? Its seems like there is more Methods and PRW's scripting in those sections so when I try to modify the script with OSFL etc I get a ton of errors since the object does not exist.

Is my current script seem to be complete or am I missing something to make this error on USB FLash drive on _wak go away?

DSDT as AML attached

#135
aikidoka25

aikidoka25

    InsanelyMac Sage

  • Members
  • PipPipPipPipPip
  • 356 posts
ApexDE,

I have a HP Mini 311 with SL 10.6.4, the problem with this unit, when on battery and going to sleep with a USB Storage attached will cause an sleep-wake loop, only can be stopped if the USB is removed.

I applied your patch and it seems better, on battery the unit can enter sleep mode with USB flash attached, there is no loop. However, upon wake, there is a message saying the device is not ejected properly.

System Profiler reported the USBs as Built-in.

Any advise?

Error message
Attached File  USB_disconnect_error.tiff   30.77KB   8 downloads

Kernel log upon wake
Attached File  kernel.log.txt   1.08KB   8 downloads

USB section with modifications
Attached File  USB_after.dsl.txt   14.98KB   9 downloads

#136
BugsB

BugsB

    InsanelyMac Deity

  • Members
  • PipPipPipPipPipPipPipPipPipPip
  • 1,513 posts
  • Gender:Male
  • Location:Kauai, Hawai'i
I do NOT want OS X to wake up from sleep on mouse move or keyboard stroke on an Asus board (not the Laptop in the sig). Right now it does. I only want it to wake up via power button.

Is there a USB kext or DSDT hack for this? There is no function for this in the BIOS.

DSDT attached, if you wanna have a look.

Thanks,
Bugs

Attached Files

  • Attached File  dsdt.zip   16.97KB   24 downloads


#137
kizwan

kizwan

    InsanelyMac Legend

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 1,422 posts

I do NOT want OS X to wake up from sleep on mouse move or keyboard stroke on an Asus board (not the Laptop in the sig). Right now it does. I only want it to wake up via power button.

Is there a USB kext or DSDT hack for this? There is no function for this in the BIOS.

Thanks,
Bugs

You can try manipulate the _PSW function.

Refer to arguments for _PSW:

Arguments: (1)
Arg0 – An Integer containing a wake capability control
0 – Disable the device’s wake capabilities
1 – Enable the device’s wake capabilities



#138
BugsB

BugsB

    InsanelyMac Deity

  • Members
  • PipPipPipPipPipPipPipPipPipPip
  • 1,513 posts
  • Gender:Male
  • Location:Kauai, Hawai'i
hey Kizwan, great :)

I attached my DSDT above [link]. As you see the only refs to _PSW are in PS2 methods, PS2K and PS2M, nothing in USB related methods. Do you think it is still worth it to mod
Method (PS2K._PSW, 1, NotSerialized)
to
Method (PS2K._PSW, 0, NotSerialized)
+ the same with PS2M? Or is this DSDT too far off the beaten track?

[edit]: I just attached a PS2 mouse before reboot which works via VoodooPS2, and that one does NOT wake the Asus from sleep when I click or move it ..

[edit2]: with Method (PS2x._PSW, 0, NotSerialized) I now get two compile errors "Method argument Arg0 is not initialized". Shall I delete the entire Methods, or leave the methods themselves untouched and change Arg0 to 0 in both instances?

#139
kizwan

kizwan

    InsanelyMac Legend

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 1,422 posts
Hi BugsB,

You can add _PSW control method in USB device entry if it doesn't exist yet. You need to change the value inside the _PSW control method. I do like this:-
Device (USB4)
					{
						Name (_ADR, 0x001D0003)
						OperationRegion (U4CS, PCI_Config, 0xC4, 0x04)
						Field (U4CS, DWordAcc, NoLock, Preserve)
						{
							U4EN,   2
						}
		 
						Name (_PRW, Package (0x02)
						{
							0x0E, 
							0x03
						})
	  
						Method (_PSW, 1, NotSerialized)
						{
							If (Arg0)
							{
								// Store (0x03, U4EN)
								// Disable USB4 capability to wake a sleeping system
								Store (0x00, U4EN)
							}
							Else
							{
								Store (0x00, U4EN)
							}
						}
On my Aspire 9420, the internal bluetooth which connected to USB4 keep waking up my computer whenever it tried to sleep.

Arguments: (1)
Arg0 – An Integer containing a wake capability control
0 – Disable the device’s wake capabilities
1 – Enable the device’s wake capabilities

I change both condition to execute the same thing. So that it always execute the same "Store" operation as if it is Arg0=0.

:(

#140
BugsB

BugsB

    InsanelyMac Deity

  • Members
  • PipPipPipPipPipPipPipPipPipPip
  • 1,513 posts
  • Gender:Male
  • Location:Kauai, Hawai'i
wow thanks! I just compared the original from my DSDT
Device (USB4)
			{
				Name (_ADR, 0x001D0003)
				Method (_PRW, 0, NotSerialized)
				{
					Return (GPRW (0x0E, 0x04))
				}
			}
with your code. Therefore in your section
Name (_PRW, Package (0x02)
						{
							0x0E,
							0x03
						})
the 0x03 does not make sense to me. How do you know that 3 is the right number here?

I understand the general logic behind it now thanks to you, but for me to understand the pattern would you please be so kind and post the mod for another USB device. I think then I can go ahead with the remaining two and expand them myself. Let's say this one:
Device (USB1)
			{
				Name (_ADR, 0x001D0000)
				Method (_PRW, 0, NotSerialized)
				{
					Return (GPRW (0x03, 0x04))
				}
			}

Thanks for teaching :( !





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