Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

nate922

macrumors newbie
Aug 2, 2010
16
1
Unfortunately in macOS it's not possible to run binaries that perform low level I/O directly, because they will run in the "user space" and not the "kernel space". The only way to run code in "kernel space" is in kexts.
But you can reload the kext by running the following commands on the terminal:

Mate that is awesome. the kext unload/load works and it instantly lowers the GPU to 0.

It's strange that sometimes the kext is not working on wake as the logs show that's it's running like it should:

2017-11-26 14:17:17.002457+0000 0x424dd Default 0x0 0 kernel: (AMDGPUWakeHandler) Waking up

2017-11-26 14:17:17.002459+0000 0x424dd Default 0x0 0 kernel: (AMDGPUWakeHandler) Disabling GPU
 

brainshutdown

macrumors regular
Original poster
Jul 16, 2012
124
110
Mate that is awesome. the kext unload/load works and it instantly lowers the GPU to 0.

It's strange that sometimes the kext is not working on wake as the logs show that's it's running like it should:

2017-11-26 14:17:17.002457+0000 0x424dd Default 0x0 0 kernel: (AMDGPUWakeHandler) Waking up

2017-11-26 14:17:17.002459+0000 0x424dd Default 0x0 0 kernel: (AMDGPUWakeHandler) Disabling GPU
In the linux source code for the "apple-gmux" they use the "gmux_index_write8" function for the retina models and the "gmux_pio_write8" for non retinas, and the index one is a bit more complex. They do some sort of waiting between outb instructions, and that's probably why it sometimes work, and sometimes won't. You can copy the waiting functions and give it a try.
 

nsgr

macrumors 6502
May 22, 2017
317
117
Yes, as mentioned in the guide, there are problems with High Sierra.
It seems to me that the GMUX is disabled in High Sierra when using the grub menu entry.
You can confirm this by running:

Code:
system_profiler SPDisplaysDataType | grep gMux

If nothing appears then its probably disabled.
I don't know if this works, but you can enable the GMUX interrupts by doing an "outb 0x714 0xFF" on the menuentry like this:

Code:
menuentry "macOS with outb" {
    outb 0x728 1
    outb 0x710 2
    outb 0x740 2
    outb 0x750 0
    outb 0x714 0xFF
    exit
}




Unfortunately in macOS it's not possible to run binaries that perform low level I/O directly, because they will run in the "user space" and not the "kernel space". The only way to run code in "kernel space" is in kexts.
But you can reload the kext by running the following commands on the terminal:

Code:
sudo kextunload /Library/Extensions/AMDGPUWakeHandler.kext
sudo kextload /Library/Extensions/AMDGPUWakeHandler.kext

The code that powers down the GPU is also executed when loading, so you don't need to put it to sleep.

HighSierra 10.13.1 - Macbook Pro 15" Early 2011

No, GMUX is enable. Even then I tried again with the addition of outb "0x714 0xFF" in GRUB but it did not work.

The problem is that AMD kexts are not loaded on boot (AMD6000Controller.kext, AMDLegacySupport.kext and AMDLegacyFrameBuffer.kext).



No GRUB on boot - AMD GPU and Intel GPU recognized:
Code:
system_profiler SPDisplaysDataType | grep gMux
      gMux Version: 1.9.23
      gMux Version: 1.9.23

With GRUB on boot - Only Intel GPU recognized:
Code:
system_profiler SPDisplaysDataType | grep gMux
      gMux Version: 1.9.23


Test 1 - Safe Mode (SHIFT key press at boot) with AMD Kexts in /System/Library/Extensions

1 - Primary GPU is Intel

2 - Mac OS recognizes the AMD GPU (device id 0x6741) and loads the respective AMD kexts (AMD6000Controller.kext, AMDLegacySupport.kext and AMDLegacyFrameBuffer.kext).

3 - Load three Backlight kexts.
Code:
kextstat | grep AMD
com.apple.kext.AMDLegacySupport (1.5.8)
com.apple.kext.AMD6000Controller (1.5.8)
com.apple.kext.AMDLegacyFramebuffer (1.5.8)

kextstat | grep -i backlight
com.apple.driver.AppleBacklightExpert (1.1.0)
com.apple.driver.AppleBacklight (170.10.1)
com.apple.driver.AGDCBacklightControl (3.16.19)

4 - System Preferences -> Displays -> Brightness slider and F1 and F2 keys works.


Test 2 - Safe Mode (SHIFT key press at boot) with AMD Kexts moved out /System/Library/Extensions

1 - Primary GPU is Intel

2 - Mac OS recognizes the AMD GPU (device id 0x6741) and not loads the respective AMD kexts (AMD6000Controller.kext, AMDLegacySupport.kext and AMDLegacyFrameBuffer.kext). The kexts AMD moved out /System/Library/Extensions.

3 - Load two Backlight kexts. Load manually the kext AppleBacklight.kext do not resolve the Brightness problem.
Code:
kextstat | grep -i backlight
com.apple.driver.AppleBacklightExpert (1.1.0)
com.apple.driver.AGDCBacklightControl (3.16.19)

4 - System Preferences -> Displays -> Brightness slider disapear and F1 and F2 keys do not work.

5 - Load kexts AMD manually (kextload -r : alternative kexts repository - loads dependent kexts)
Code:
sudo kextload -r /AMDExtensions/ /AMDExtensions/AMD6000Controller.kext
kextstat | grep AMD
com.apple.kext.AMDLegacySupport (1.5.8)
com.apple.kext.AMD6000Controller (1.5.8)

6 - System Preferences -> Displays -> Brightness slider disapear and F1 and F2 keys do not work.


Test 3: Boot normal (no press key at boot - no GRUB) with AMD Kexts moved out /System/Library/Extensions

1 - Primary GPU is Intel - because force Intel GPU power prefs with nvram.

2 - Mac OS recognizes the AMD GPU (device id 0x6741) and not loads the respective AMD kexts (AMD6000Controller.kext, AMDLegacySupport.kext and AMDLegacyFrameBuffer.kext). The kexts AMD moved out /System/Library/Extensions.

3 - Load two Backlight kexts. Load manually the kext AppleBacklight.kext do not resolve the Brightness problem.
Code:
kextstat | grep -i backlight
com.apple.driver.AppleBacklightExpert (1.1.0)
com.apple.driver.AGDCBacklightControl (3.16.19)

4 - System Preferences -> Displays -> Brightness slider disapear and F1 and F2 keys do not work.

5 - Load kexts AMD manually (kextload -r : alternative kexts repository - loads dependent kexts)
Code:
sudo kextload -r /AMDExtensions/ /AMDExtensions/AMD6000Controller.kext
kextstat | grep AMD
com.apple.kext.AMDLegacySupport (1.5.8)
com.apple.kext.AMD6000Controller (1.5.8)

6 - System Preferences -> Displays -> Brightness slider disapear and F1 and F2 keys do not work.


Conclusion: The Brightness problem is only solved (in my tests) when these kexts are loaded during boot on HighSierra 10.13.1 - MacBook Pro 15" Early 2011:

AMD6000Controller.kext
AMDLegacySupport.kext
AMDLegacyFrameBuffer.kext
 

Attachments

  • SystemPreferences-Displays-Safe-Mode-With-AMD-Kexts.png
    SystemPreferences-Displays-Safe-Mode-With-AMD-Kexts.png
    64.5 KB · Views: 485
  • SystemPreferences-Safe-Mode-No-Kexts-AMD.png
    SystemPreferences-Safe-Mode-No-Kexts-AMD.png
    61.3 KB · Views: 428
  • SystemPreferences-Displays-Boot-Normal-No-Grub-No-Kexts-AMD.png
    SystemPreferences-Displays-Boot-Normal-No-Grub-No-Kexts-AMD.png
    241.5 KB · Views: 731
Last edited:
  • Like
Reactions: lpuerto

brainshutdown

macrumors regular
Original poster
Jul 16, 2012
124
110
@nsgr On my MBP Early 2011(8,2) using Sierra:
Code:
> kextstat | grep -i backlight
com.apple.driver.AppleBacklightExpert (1.1.0)
> kextstat | grep -i mux
com.apple.driver.AppleMuxControl (3.14.49)

In macOS Sierra the AppleMuxControl is at /System/Library/Extensions/AppleGraphicsControl.kext/Contents/PlugIns/AppleMuxControl.kext

Hope it gives you some insights.
 
Last edited:

nsgr

macrumors 6502
May 22, 2017
317
117
@nsgr On my MBP Early 2011(8,2) using Sierra:
Code:
> kextstat | grep -i backlight
com.apple.driver.AppleBacklightExpert (1.1.0)
> kextstat | grep -i mux
com.apple.driver.AppleMuxControl (3.14.49)

In macOS Sierra the AppleMuxControl is at /System/Library/Extensions/AppleGraphicsControl.kext/Contents/PlugIns/AppleMuxControl.kext

Hope it gives you some insights.

Boot GRUB with out command (HighSierra 10.13.1 - MacBook Pro Early 2011 -
MacBookPro8,2):

Code:
kextstat | grep -i backlight
com.apple.driver.AppleBacklightExpert (1.1.0)
com.apple.driver.AppleBacklight (170.10.1)
com.apple.driver.AGDCBacklightControl (3.16.19)


After 5 minutes, the system unload automatically AppleBacklight.kext.

Code:
kextstat | grep -i backlight
com.apple.driver.AppleBacklightExpert (1.1.0)
com.apple.driver.AGDCBacklightControl

Code:
kextstat | grep -i mux
com.apple.driver.AppleMuxControl (3.16.19)

I think Apple has changed the way of using Brightness.

Even brightness.c does not work on HighSierra 10.13.1.

System brightness setting is not updated (macOS 10.13.1)
https://github.com/nriley/brightness/issues/21

I'm going to install Sierra 10.12 again. Let's see what happens when you delete Container disk1 (APFS Container) with system partition (Encrypted FileVault) and Recovery partition.
 

nsgr

macrumors 6502
May 22, 2017
317
117
Sierra 10.12.6 installed.

GRUB outb command + F1 and F2 key or System Preferences -> Displays -> Brightness slider show up and works correctly.
 
  • Like
Reactions: lpuerto

lpuerto

macrumors regular
Mar 4, 2014
144
37
Europe
Thanks you all for your work and your time so solve this problem. I'm on a macbook pro late 2011 with high sierra whose dGPU decided to say chao on Saturday night and thanks to this fix I'm back on business.

do you think there is anyway we can fix the issue of the brightness?

PS/ Is there any way we can load the kext just for a while to handle the brightness??
[doublepost=1512340051][/doublepost]Seems that there was problem with brightness even in betas.

https://forums.developer.apple.com/thread/80705
https://forums.developer.apple.com/thread/82500

I just updated like a month ago to high sierra, from El Capitan... It's not the first time this happened to me, the previous time I was covered by apple care and I have my logic board changed... 3 years ago.

Since I installed High Sierra I've noticed that on my MacBook Pro's console there was an error [ERROR] - Unknown CGXDisplayDevice: 0x41dc9d00 that didn't appeared before. (See the attached image). I've contacted Apple about the issue and they took some data from my computer, but they didn't reach me back...

I'm wondering if all of this is connected. And if High Sierra have triggered this behavior.
 

Attachments

  • Screen Shot 2017-12-04 at 00.23.58.png
    Screen Shot 2017-12-04 at 00.23.58.png
    198.9 KB · Views: 444
Last edited:

brainshutdown

macrumors regular
Original poster
Jul 16, 2012
124
110
@lpuerto Yes, the behaviour you describe is only present in High Sierra as far as I know. Everything works fine in Sierra and El Capitan and some even reported it working fine on Mavericks. The best solution for now is to "downgrade" to Sierra.
 

lpuerto

macrumors regular
Mar 4, 2014
144
37
Europe
@lpuerto Yes, the behaviour you describe is only present in High Sierra as far as I know. Everything works fine in Sierra and El Capitan and some even reported it working fine on Mavericks. The best solution for now is to "downgrade" to Sierra.

Hey!! first of all thank you all to work so hard in this solution. I just passed form to be in really bad mood last sunday to see the bright side after I fix my computer with this.

Downgrade to Sierra isn't a really a solution for me. I've already transformed all my photo libraries and so to the new formats, and the problems aren't that big. The brightness is just a problem if I try to work at night and without lights... and about hibernation is just fine.

Anyhow, it would be great to be able to fix those issues in the future.

I was talking with Apple about a possible solution to the problem and they are willing to help. Problem is, there is difficult to find spare parts for this computers. They are considered vintage. In other words, really old, and it's true, they have mor than 6 years and in technology it's a lot. Anyhow, they are really fine machines, and even if I buy an new machine in the near future I believe there is a lot of life in this machines. So, solutions are welcomed!
 

QiuChuck

macrumors newbie
Dec 22, 2017
9
7
Installing GRUB

Follow the steps described in this guide:
https://gist.github.com/blackgate/17ac402e35d2f7e0f1c9708db3dc7a44

Installing the attached kext to prevent the GPU from waking up from sleep (optional)

WARNING: This kext should only be used with the GRUB solution in place, otherwise it will kernel panic.

The attached kext is unsigned, if you have a kext signing certificate, you can build it yourself and sign it (don't forget to share :)). You can find the source code here.

Mavericks
Copy the kext to /System/Library/Extensions and then run the following commands from terminal:
Code:
sudo chmod -R 755 /System/Library/Extensions/AMDGPUWakeHandler.kext
sudo chown -R root:wheel /System/Library/Extensions/AMDGPUWakeHandler.kext
sudo touch /System/Library/Extensions

Yosemite
Copy the kext to /Library/Extensions and then run the following commands from terminal:
Code:
sudo nvram boot-args="kext-dev-mode=1"
sudo chmod -R 755 /Library/Extensions/AMDGPUWakeHandler.kext
sudo chown -R root:wheel /Library/Extensions/AMDGPUWakeHandler.kext
sudo touch /Library/Extensions

El Capitan and later
You need to have SIP disabled (view the guide to see how you can disable it).
Copy the kext to /Library/Extensions and then run the following commands from terminal:
Code:
sudo chmod -R 755 /Library/Extensions/AMDGPUWakeHandler.kext
sudo chown -R root:wheel /Library/Extensions/AMDGPUWakeHandler.kext
sudo touch /Library/Extensions

Thanks for all the work you did and for making my 2011 17" MBP work again.
I managed to get it working, but the even with the AMDGPUWakeHandler kext in place, the screen just does not come back after I close and open the lid (Puting it in sleep mode)
Any ideas why?
This is my only problem now.
I'm on HighSierra

EDIT: also it seems that now it hangs on shutdown and never actualy does it :(

EDIT2: Fixed the shutdown problem. I accidentally put the Wake kext in /System/Library/Extensions

Moved it to the correct location but the Sleep problem is still there. Screen stays black when waking the MBP
 
Last edited:

brainshutdown

macrumors regular
Original poster
Jul 16, 2012
124
110
@QiuChuck Your problem is this:
I'm on HighSierra
The best thing you can do is "downgrade" to Sierra.
[doublepost=1514066623][/doublepost]
I saw this post today on how to disable the ATI graphics by removing a single resistor on the motherboard

https://www.jeffgeerling.com/blog/2...o-booting-grey-screen-amd-radeon-video-glitch

I would think twice before removing the resistor. If the nvram gets reseted for some reason your MBP won't boot anymore.
 
Last edited:

mindwalkr

macrumors newbie
Dec 19, 2017
3
0
EDIT: also it seems that now it hangs on shutdown and never actualy does it :(

EDIT2: Fixed the shutdown problem. I accidentally put the Wake kext in /System/Library/Extensions

I have the same problem. My Macbook Pro 8.2 Late 2011 with an SSD instead of an HDD, also hangs on shutdown - I am left with a black screen and all I can do is to move the mouse pointer around. I checked if I made the same mistake as you, but alas I can't find the Wake kext mistakenly in that folder

If I boot without GRUB, then I am able to Shutdown correctly.

With GRUB, I am only able to shutdown before I login into the OS. If, however, when booting with GRUB, I remove the outb lines, then I am able to Shutdown correctly after logging into the OS

Has anyone else experienced this problem and got any pointers ?
 
Last edited:

nsgr

macrumors 6502
May 22, 2017
317
117
I have the same problem. My Macbook Pro 8.2 Late 2011 with an SSD instead of an HDD, also hangs on shutdown - I am left with a black screen and all I can do is to move the mouse pointer around. I checked if I made the same mistake as you, but alas I can't find the Wake kext mistakenly in that folder

If I boot without GRUB, then I am able to Shutdown correctly.

With GRUB, I am only able to shutdown before I login into the OS. If, however, when booting with GRUB, I remove the outb lines, then I am able to Shutdown correctly after logging into the OS

Has anyone else experienced this problem and got any pointers ?

The "Mantra" for restart or shutdown MacBook Pro:

Open Terminal:

Restart Macbook Pro:
Code:
sudo shutdown -r now

Halt / Shutdown MacBook Pro:
Code:
sudo shutdown -h now
 

QiuChuck

macrumors newbie
Dec 22, 2017
9
7
@QiuChuck Your problem is this:

The best thing you can do is "downgrade" to Sierra.

Yep, I downgraded to Sierra and everything works just fine now.
Even brightness is back up and working.
I can safely say that Sierra is the last OS that works well with this fix, for the Early 2011 17" MBP at least.
You can update to HighSierra but brightness WILL NOT work as well as SLEEP.
Thanks A TON for all the research and HELP!

Merry Christmas and a HAPPY NEW YEAR!

Cheers!
 

jackin6

macrumors newbie
Dec 29, 2017
4
0
WARNING: This kext should only be used with the GRUB solution in place, otherwise it will kernel panic.

Quick question in regards to this - if I implemented the EFI fix initially (change power prefs in NVRAM, remove AMD Kexts) and then decided to switch to GRUB fix (reset nvram, change power prefs in NVRAM, install custom GRUB bootloader), will I have trouble inserting these custom Kexts? Last thing I want is a kernel panic on boot after all the effort I've been through to get it working.
 

Schmye Bubbula

macrumors member
Jul 24, 2009
40
1
^ Are you able to run the kext with SIP enabled? Having a signed kext is a must because, e.g., if you're doing this for an unwary friend's computer, it is untenable to disable their security.
 

QiuChuck

macrumors newbie
Dec 22, 2017
9
7
Umm....I don’t think I’ve enabled SIP back :)
Should I?

After disabling and following the steps I just left it as is.
 

jackin6

macrumors newbie
Dec 29, 2017
4
0
Adding the AMDWakeHandler kext puts my mac into a Kernel panic :( that said, it boots just fine from a USB bootloader.
 

QiuChuck

macrumors newbie
Dec 22, 2017
9
7
Umm....I don’t think I’ve enabled SIP back :)
Should I?

After disabling and following the steps I just left it as is.

Lol ok, I read about it and now I see, that by disabling SIP is the only way AMDGPUWakeHandler can work. And a signed one is required to enable back SIP.

But Apple does not let anyone sign kext. I signed up for it and waiting for their reply. Tough I'm sure I know the answer already :)
 

jangoux

macrumors newbie
Jan 5, 2018
2
0
Dentro do estúdio
First, thanks for the solution! it made my Macbook workable again. But I have one issue with Grub. For some reason just the first menu item appears when I boot (I have two different OSX boot partitions + the Recovery one). Here is my grub.cfg:

Code:
if loadfont /boot/grub/font.pf2 ; then
    set gfxmode=auto
    insmod efi_gop
    insmod efi_uga
    insmod gfxterm
    terminal_output gfxterm
fi

set menu_color_normal=white/black
set menu_color_black/light-gray

set timeout=10

menuentry "macOS" {
    insmod hfsplus
    outb 0x728 1
    outb 0x710 2
    outb 0x740 2
    outb 0x750 0
    search --no-floppy --fs-uuid --set=root b296e8fd7fe7da5e
    chainloader /System/Library/CoreServices/boot.efi
}


menuentry "macOS new” {
    insmod hfsplus
    outb 0x728 1
    outb 0x710 2
    outb 0x740 2
    outb 0x750 0
    search --no-floppy --fs-uuid --set=root aa82986e041282fd
    chainloader /System/Library/CoreServices/boot.efi
}

menuentry “Recovery” {
    insmod hfsplus
    outb 0x728 1
    outb 0x710 2
    outb 0x740 2
    outb 0x750 0
    search --no-floppy --fs-uuid --set=root d5ca3db4a78f4dcf
    chainloader /System/Library/CoreServices/boot.efi
}

What's wrong with it ?
 

brainshutdown

macrumors regular
Original poster
Jul 16, 2012
124
110
First, thanks for the solution! it made my Macbook workable again. But I have one issue with Grub. For some reason just the first menu item appears when I boot (I have two different OSX boot partitions + the Recovery one). Here is my grub.cfg:

Code:
if loadfont /boot/grub/font.pf2 ; then
    set gfxmode=auto
    insmod efi_gop
    insmod efi_uga
    insmod gfxterm
    terminal_output gfxterm
fi

set menu_color_normal=white/black
set menu_color_black/light-gray

set timeout=10

menuentry "macOS" {
    insmod hfsplus
    outb 0x728 1
    outb 0x710 2
    outb 0x740 2
    outb 0x750 0
    search --no-floppy --fs-uuid --set=root b296e8fd7fe7da5e
    chainloader /System/Library/CoreServices/boot.efi
}


menuentry "macOS new” {
    insmod hfsplus
    outb 0x728 1
    outb 0x710 2
    outb 0x740 2
    outb 0x750 0
    search --no-floppy --fs-uuid --set=root aa82986e041282fd
    chainloader /System/Library/CoreServices/boot.efi
}

menuentry “Recovery” {
    insmod hfsplus
    outb 0x728 1
    outb 0x710 2
    outb 0x740 2
    outb 0x750 0
    search --no-floppy --fs-uuid --set=root d5ca3db4a78f4dcf
    chainloader /System/Library/CoreServices/boot.efi
}

What's wrong with it ?

I see two problems there.

If you look carefully the end quote character in "macOS new” and both in “Recovery” are the wrong ones. You should change them to "macOS new" and "Recovery" respectively.

Also the recovery partition won't boot that way. You should use one of the macOS partitions with the "-r" flag like this:
Code:
menuentry "Recovery" {
    insmod hfsplus
    outb 0x728 1
    outb 0x710 2
    outb 0x740 2
    outb 0x750 0
    search --no-floppy --fs-uuid --set=root aa82986e041282fd
    chainloader /System/Library/CoreServices/boot.efi -r
}
[doublepost=1515269776][/doublepost]
Quick question in regards to this - if I implemented the EFI fix initially (change power prefs in NVRAM, remove AMD Kexts) and then decided to switch to GRUB fix (reset nvram, change power prefs in NVRAM, install custom GRUB bootloader), will I have trouble inserting these custom Kexts? Last thing I want is a kernel panic on boot after all the effort I've been through to get it working.
Unless you have SIP enabled you won't have any trouble inserting the kext.
[doublepost=1515269944][/doublepost]
Adding the AMDWakeHandler kext puts my mac into a Kernel panic :( that said, it boots just fine from a USB bootloader.
Did the step 4 work without any error?
 

lastscenen

macrumors newbie
Jan 8, 2018
1
0
this method, can install windows ? how?
or just use bootcamp ?
if can install windows it will perfect.
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.