AppleGraphicsPowerManagement.sh

I wrote a new helper (bash) script called AppleGraphicsPowerManagement.sh One that I like to share with folks who use the IGPU for their desktop setup with HD graphics, and don’t see it stepping down to the lowest possible frequency. Which in my case is 200 MHz but it never reached a lower frequency than 750 MHz (0,75 GHz). Not without first running AppleGraphicsPowerManagement.sh

Ok. Let’s start by explaining why I said “helper (bash) script“. Yes indeed. This helper script is made for folks like me who use AppleHDA8Series.sh to create AppleHDA892.kext (example for my ALC 892) and want to use the Info.plist to inject AGPM data from it. Done the easy way…

Note: I also have other plug-ins in AppleHDA892.kext/Contents/PlugIns but that will be discussed in one of my next blog articles.

Next. Here is a screenshot of the Intel Power Gadget (v3.0.1) running on my Haswell setup.

Intel Power Gadget

Ignore the fact that it fails to show the estimated power usage (MSR 0x611 is Zero) and the temperature (next to a heater). Just look at the IGPU frequency (GT: 0,20 GHz) which was 0,75 before I ran my script. And this is what my script injects into the Info.plist:

<key>AGPM</key>
<dict>
    <key>CFBundleIdentifier</key>
    <string>com.apple.driver.AGPM</string>
    <key>IOClass</key>
    <string>AGPMController</string>
    <key>IONameMatch</key>
    <string>AGPMEnabler</string>
    <key>IOProviderClass</key>
    <string>IOPlatformPluginDevice</string>
    <key>Machines</key>
    <dict>
        <key>Mac-F60DEB81FF30ACF6</key>
        <dict>
            <key>IGPU</key>
            <dict>
                <key>Heuristic</key>
                <dict>
                    <key>EnableOverride</key>
                    <integer>0</integer>
                    <key>ID</key>
                    <integer>2</integer>
                </dict>
                <key>control-id</key>
                <integer>16</integer>
            </dict>
        </dict>
    </dict>
</dict>

Please note that the Mac-F60DEB81FF30ACF6 you see here will of course be different when you are using a different board-id. No worries. This will be checked by AppleGraphicsPowerManagement.sh Currently at version 0.6 but I will change/update it when required. Oh sure. I will add it to my Github repository, but at a later date.

Edit: Done! Now available from my Github repository.

p.s. Folks in need of different data could use this script after they modified it.

Have fun with it!

24 thoughts on “AppleGraphicsPowerManagement.sh

  1. Pingback: Xnu CPU Power Management | Pike's Universum

    • Yes. I think so, but what model identifier and board-id are you using? Here are your options:

      MacBookPro11,1 / Mac-189A3D4F975D5FFC – GT3Floor:11 (11 * 50 MHz = 550 MHz)
      MacBookPro11,2 / Mac-3CBD00234E554E41 – GT3Floor:15 (15 * 50 MHz = 750 MHz)
      MacBookPro11,3 / Mac-2BD1B31983FE1663 – GT3Floor:15 (15 * 50 MHz = 750 MHz)

      MacBookAir6,1 Mac-35C1E88140C3E6CF – GT3Floor:7 (7 * 50 MHz = 350 MHz)
      MacBookAir6,2 Mac-7DF21CB3ED6977E5 – GT3Floor:7 (7 * 50 MHz = 350 MHz)

      Note the GT3Floor settings. I need to set it to 4 (4 * 50 MHz = 200 MHz) for my i5-4670K when I use any of the above model identifiers/board-id’s

      • MacBookAir6,2 Mac-7DF21CB3ED6977E5
        Im using MacbookAir6,2…

        MacBookPro11,2 / Mac-3CBD00234E554E41
        Would be better, because with 11,2 i get with my i7-4558U CPU better speed steps.

        I get with 11,2 x8, x16x x28, x29, x30, x31, x32, (x33 rarely)
        And with 6,2 i get x8, x28, x29, x30, x31, x32 (no x16 and x33)

        But the reason i use MBA6,2 is because, for 11,2 i need anything greater as 10.9.1(13B42)
        or edited S/L/C/SupportedModels.plist…
        With anything greater as (13B42), for example (13B3116, or any 10.9.2) i loose sleep…
        Sleep is only working with 10.9.1 (13B42)… (Because on anything greater, i get a reboot on wake)

        Apple Changed something in the Kexts…

        But i don’t understand what is GT3Floor or what it is dependent from.
        Cheers 🙂

      • Ok. The MacBookPro11,1 is available with the CPU you have so open:

        /System/Library/Extensions/AppleGraphicsPowerManagement.kext/Contents/Info.plist

        Look for Mac-189A3D4F975D5FFC and change the value of GT3Floor from 11 to 4 (200 MHz) being the lowest possible frequency aka GBF (Graphics Base Frequency) for the IGPU. Al,so. Make sure the ACPI device name is “IGPU” in your DSDT or it won’t even match.

      • Thank you 🙂

        I’ve changed PlatformSupport.plist and added MBP11,1 Entrys…
        I get the same P-States as with MBA6,2 (x8, x28, x29, x30, x31, x32)
        Dunno why i get “x16” with MBP11,2 smbios…

        In my DSDT it is already IGPU, I’ve changed to smbios to MBP11,1 and changed to GT3Floor = 4.
        (It was 7 before and not 11… Maybe it’s 11 on any newer kext)
        My AppleGraphicsPowerManagement.kext is v.100.14.11 (77)

        Okay, after i changed to GT3Floor from 7 to 4, nothing is changed^^
        i’ve maked a Picture:

        Under “Frequency”, IA: Minimum is 0,80GHz, and GT: Minimum is 1,10 GHz

        Do you have any idea? Maybe it’s wrong, because FakeSMC have a bug or something?

        —————-
        PS: Thank you very much! 🙂

  2. The Output is:

    “Machine” = {“MacBookPro11,1″={“IGPU”={“GT3Capped”=1,”SliceControl”=1,”control-id”=16,”max-power-state”=13,”Heuristic”={“ThresholdsForRingOverrideTable2″=(10,100),”ThresholdsForRingOverrideTable1″=(5,15),”ThresholdsForRingOverrideTable0″=(0,10),”EvaluateUpInterval”=31250,”DownStep”=1,”GT3Floor”=7,”StartingPstateForRingTableOverride”=11,”NumOfRingTableOverride”=23,”RingOverrideTable2″=(8,8,8,9,10,11,13,14,15,16,18,19,20,21,23,24,25,26,28,29,30,31,33),”IOBusynessSamplingInterval”=1,”EnableOverride”=1,”UpStep”=2,”RingOverrideTable1″=(8,8,8,9,10,11,13,14,15,16,16,16,16,16,16,16,16,16,16,16,16,16,16),”BusyUpThresholdPercent”=70,”GT2Floor”=8,”NumOfThresholdsForRingTables”=2,”BusyDownThresholdPercent”=50,”ID”=2,”RingOverrideTable0″=(8,8,8,8,8,9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10),”NumOfRingTables”=3,”EvaluateDownInterval”=31250,”EnableRingTableOverride”=1}}}}

    Thank you 🙂

    • In the output stays: GT3Floor is 7, but i changed it definitive to 4!
      /System/Library/Extensions/AppleGraphicsPowerManagement.kext/Contents/Info.plist
      (IOkitPersonalities -> AGPM -> Machines -> (Mac-…) -> IGPU -> Heuristic -> GT3Floor)

      Maybe it comes from, that i ways before on MacBook Air board id, and didn’t reinstalled system after switched to MBP11,1 SMbios… i’ve edited now MBA6,2 GT3Floor too.

      Will report later 🙂

      • Okay, changed the GT3Floor of MBA6,2 Entry… and it changed the GT3Floor… i don’t know why i need to change entry of MBA6,2 if i use SMBIOS from MBP11,1…
        I just installed the system with MBA6,2 Smbios…
        Anyway:
        “Machine” = {“MacBookPro11,1″={“IGPU”={“GT3Capped”=1,”SliceControl”=1,”control-id”=16,”max-power-state”=13,”Heuristic”={“ThresholdsForRingOverrideTable2″=(10,100),”ThresholdsForRingOverrideTable1″=(5,15),”ThresholdsForRingOverrideTable0″=(0,10),”EvaluateUpInterval”=31250,”DownStep”=1,”GT3Floor”=4,”StartingPstateForRingTableOverride”=11,”NumOfRingTableOverride”=23,”RingOverrideTable2″=(8,8,8,9,10,11,13,14,15,16,18,19,20,21,23,24,25,26,28,29,30,31,33),”IOBusynessSamplingInterval”=1,”EnableOverride”=1,”UpStep”=2,”RingOverrideTable1″=(8,8,8,9,10,11,13,14,15,16,16,16,16,16,16,16,16,16,16,16,16,16,16),”BusyUpThresholdPercent”=70,”GT2Floor”=8,”NumOfThresholdsForRingTables”=2,”BusyDownThresholdPercent”=50,”ID”=2,”RingOverrideTable0″=(8,8,8,8,8,9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10),”NumOfRingTables”=3,”EvaluateDownInterval”=31250,”EnableRingTableOverride”=1}}}}

        ———————-

        GT goes now down to 1,06, but not below that… it doesn’t changed very much…
        Thats really strange… Maybe it have todo something that my internal screen is connected with DisplayPort instead of LVDS or anything todo with dual link? i don’t know^^

        Thank you very much 🙂

  3. Hello Pike
    I tried to run on HD 4600, cpu 4770K and audio ALC 1150
    I get an error, where error
    thank you

    Last login: Wed Jan 29 18:26:58 on ttys000
    iMac-di-Fabio:~ fabio$ cd Downloads/AppleGraphicsPowerManagement.sh-master
    iMac-di-Fabio:AppleGraphicsPowerManagement.sh-master fabio$
    ./AppleGraphicsPowerManagement.sh
    This script must be run as root!
    Password:
    AppleGraphicsPowerManagement.sh v0.8 Copyright (c) 2014 by Pike R. Alpha
    ————————————————————————
    ALC 900 found
    Error: File Not Found! Aborting …
    Done.
    iMac-di-Fabio:AppleGraphicsPowerManagement.sh-master fabio$

  4. Run the script:
    AppleGraphicsPowerManagement.sh v0.9 Copyright (c) 2014 by Pike R. Alpha
    ————————————————————————
    ALC 1150 found
    Command[ 0] Delete :IOKitPersonalities:AGPM dict
    Command[ 0] Add :IOKitPersonalities:AGPM dict
    Command[ 0] Add :IOKitPersonalities:AGPM:CFBundleIdentifier string com.apple.driver.AGPM
    Command[ 0] Add :IOKitPersonalities:AGPM:IOClass string AGPMController
    Command[ 0] Add :IOKitPersonalities:AGPM:IONameMatch string AGPMEnabler
    Command[ 0] Add :IOKitPersonalities:AGPM:IOProviderClass string IOPlatformPluginDevice
    Command[ 0] Add :IOKitPersonalities:AGPM:Machines dict
    Command[ 0] Add :IOKitPersonalities:AGPM:Machines:Mac-27ADBB7B4CEE8E61 dict
    Command[ 0] Add :IOKitPersonalities:AGPM:Machines:Mac-27ADBB7B4CEE8E61:IGPU dict
    Command[ 0] Add :IOKitPersonalities:AGPM:Machines:Mac-27ADBB7B4CEE8E61:IGPU:Heuristic dict
    Command[ 0] Add :IOKitPersonalities:AGPM:Machines:Mac-27ADBB7B4CEE8E61:IGPU:Heuristic:EnableOverride integer 0
    Command[ 0] Add :IOKitPersonalities:AGPM:Machines:Mac-27ADBB7B4CEE8E61:IGPU:Heuristic:ID integer 2
    Command[ 0] Add :IOKitPersonalities:AGPM:Machines:Mac-27ADBB7B4CEE8E61:IGPU:control-id integer 16
    Do you want to open the Info.plist? (y/n) y
    Target file: /System/Library/Extensions/AppleHDA1150.kext/Contents/Info.plist
    Triggering a kernelcache refresh …
    Do you want to reboot now? (y/n)

    GT: 0,20 GHz —-> orange line : the graph remains fixed
    IA: 0,80 GHz —–> blu line : in the graph moves
    Okay, how to use model iMac 14.2
    Thanks

  5. Pike?
    Thank you!
    It didn’t worked before, because i missed some keys in FakeSMC…

    This ones:
    ALI0 {ali 06000600
    ALRV ui16 0001
    ALV0 {alv 010110080334004EB600
    ALV1 {alv 00010000000000000000
    MSLD ui8 00

    I don’t know what they have todo with Graphics Power Management….
    But after i added them, it have worked… Now It’s at 0,20 GHz…

    Strange 🙂

    Thank you Pike!!! 🙂

    • The first four are related to the Ambient Light Sensors (ALS). Not that I understand why they would be required, but the last one,
      MSLD returns the current lid switch state. This one may be important for people using a MacBookPro* model identifier.

      Thanks!

  6. Hi Pike, i know this thread is very old, but it matches my question…
    Hope you read this^^

    I have a problem after hibernate, AGPM sits after hibernate in the wrong frame buffer…

    Before hibernate, AGPM stays under Framebuffer0 (LVDS Port 0) where boot-display is
    After hibernate, AGPM stays under Framebuffer1 (HDMI Port 5)

    With sleep this doesn’t happen, just with hibernate…
    I have no external Monitor connected…

    The problem is, that after hibernate the display stays under max Brightness, and i can’t adjust brightness…
    With sleep, everything is perfect…

    ig-platform-id: 08 00 0a 2e (intel iris 5100, i7-4558U)

    Dunno who else i can ask, i think you are the only one guy here, that know how AGPM works…

    Thank you pike!
    Cheers 🙂

    • Okay, forget it, brightness after hibernate seems not to be related to AGPM…

      I just have a strange thing…
      After normal boot = working brightness changing…
      After Sleep = working brightness changing…
      After hibernate = brocken brightness changing…

      And i try to find the bug 😦

      However, thanks Pike 🙂

    • I may be something in the ACPI tables. Don’t know, but if you don’t use the HDMI connector. I mean at all, then remove it from the frame buffer. That will also speed up the boot process a bit. Don’t forget to change this as well:


      -0800 2e0a 0103 0303
      +0800 2e0a 0101 0101

      Hope this helps.
      Example for one frame buffer!

      • Cool, nice Trick, thanks for this tip 🙂

        Have only one frame buffer now, but seems my bug is not related to that 🙂
        I need to digging little bit, maybe i find a solution 🙂

  7. I’m on 10.13 dp8 now, and I inject this patch from fakesmc. GT3Floor is working but it can’t get more than 0.2Ghz. That’s wierd. In 10.12, I can get 0.5Ghz when playing hearthstone. HD4600 GT3 Mobile seems to be 0.2G to 1.2G, but I’ve never made it to 1.2G. Is there something could be done about this?

Leave a reply to Rama Cancel reply