Piker-Alpha / ssdtPRGen.sh

Script to generate a SSDT for Power Management
713 stars 156 forks source link

SSDT does not enable P-States with Broadwell CPU #243

Open llamafilm opened 8 years ago

llamafilm commented 8 years ago

I'm running OS 10.10.5 on a Gigabyte GA-X99-Designare with i7-6950x (Broadwell-E). To make this system boot, I use fakecpuid=0x0306F2. This script seemed to detect my CPU information correctly, but after installing the SSDT, I still have only one P-State. Clover debug log shows:

Unsupported CPU (0x6): P-States not generated !!!
GeneratePStates failed: Status=Not Found
Piker-Alpha commented 8 years ago

What P-State is that? Also. Please remember that the Intel® Turbo Boost Max Technology 3.0 is a Windows only feature and thus we have to specify the maximum turbo frequency like so:

./ssdtPRGen.sh -turbo 4000

llamafilm commented 8 years ago

I re-ran the latest version of the script with the turbo 4000 option. Intel Power Gadget shows a flatline always at 4.2GHz. (overclocked in the BIOS.) And DPCI Manager agrees, showing only one p-state (42). Your AppleIntelInfo kext actually shows CPU P-States [ 38 41 (42) ], but I'm not sure that's true.

Piker-Alpha commented 8 years ago

These are Clover messages:

Unsupported CPU (0x6): P-States not generated !!!
GeneratePStates failed: Status=Not Found

Please disabled P-State generation in Clover. Remember. One SSDT for power management is enough. Either the one from Clover, when that works again, or the one from my script.

Edit: Have you checked the processor scopes in the generated SSDT? You should see this: _SB.SCK0.CP00 instead of _PR.CP00 The latter will not work.

Please attach your DSDT/APIC.aml if ssdtPRGen.sh failed to detect the correct scopes and I'll fix the script. Thanks!

llamafilm commented 8 years ago

Okay, I've disabled p-state and c-state generation in Clover. The scopes in the SSDT appear to be correct, as you say, beginning with _SB.SCK0.CP00.

ssdt.aml.zip

llamafilm commented 8 years ago

Here is the result and my SSDT.

AppleIntelInfo.kext v1.5 Copyright © 2012-2016 Pike R. Alpha. All rights reserved

Settings:
------------------------------------
logMSRs............................: 1
logIGPU............................: 0
logCStates.........................: 1
logIPGStyle........................: 1
InitialTSC.........................: 0x162f636228bd
MWAIT C-States.....................: 8480

Model Specific Registers
-----------------------------------
MSR_CORE_THREAD_COUNT......(0x35)  : 0xA0014
MSR_PLATFORM_INFO..........(0xCE)  : 0x20080C3BF3811E00
MSR_PMG_CST_CONFIG_CONTROL.(0xE2)  : 0x3
MSR_PMG_IO_CAPTURE_BASE....(0xE4)  : 0x0
IA32_MPERF.................(0xE7)  : 0x13DE26E0282C
IA32_APERF.................(0xE8)  : 0x1A7CB1C1AA8D
MSR_FLEX_RATIO.............(0x194) : 0xE0000
MSR_IA32_PERF_STATUS.......(0x198) : 0x28CD00002800
MSR_IA32_PERF_CONTROL......(0x199) : 0x2800
IA32_CLOCK_MODULATION......(0x19A) : 0x0
IA32_THERM_STATUS..........(0x19C) : 0x881F0000
IA32_MISC_ENABLES..........(0x1A0) : 0x810089
MSR_MISC_PWR_MGMT..........(0x1AA) : 0x402000
MSR_TURBO_RATIO_LIMIT......(0x1AD) : 0x2828282828282828
IA32_ENERGY_PERF_BIAS......(0x1B0) : 0x0
MSR_POWER_CTL..............(0x1FC) : 0x2104005B
MSR_RAPL_POWER_UNIT........(0x606) : 0xA0E03
MSR_PKG_POWER_LIMIT........(0x610) : 0x7FFD00014EA82
MSR_PKG_ENERGY_STATUS......(0x611) : 0x5A29C685
MSR_PKG_POWER_INFO.........(0x614) : 0x1800460
MSR_PP0_POWER_LIMIT........(0x638) : 0x14FFD0
MSR_PP0_ENERGY_STATUS......(0x639) : 0x0
MSR_PKGC6_IRTL.............(0x60b) : 0x0
MSR_PKG_C2_RESIDENCY.......(0x60d) : 0x0
MSR_PKG_C6_RESIDENCY.......(0x3f9) : 0x0
IA32_TSC_DEADLINE..........(0x6E0) : 0x162F6685982E

CPU Ratio Info:
------------------------------------
CPU Low Frequency Mode.............: 1200 MHz
CPU Maximum non-Turbo Frequency....: 3000 MHz
CPU Maximum Turbo Frequency........: 4000 MHz
CPU P-States [ (40) ]

ssdt.aml.zip

llamafilm commented 8 years ago

That last output I posted was with BIOS CPU frequency set to 40. Does that setting effectively disable SpeedStep? When I set it to auto, your kext shows three p-states [ 35 39 (40) ], but according to Intel Power Gadget, it runs at 4.00GHz all the time. And DPCI Manager shows only 40.

Another interesting thing — when BIOS CPU frequency is auto, Intel Power Gadget shows much higher power consumption, around 134W at idle. When I set it to 40 in the BIOS, my GeekBench score is the same, but the power consumption is around 65W at idle.

Piker-Alpha commented 8 years ago

Look here:

IA32_MISC_ENABLES..........(0x1A0) : 0x810089

Here you see that bit-16 (0x10000) is set and thus EIST is enabled. If EIST was disabled then this value would have been, for example 0x800089 or 0x840089 (when MONITOR/MWAIT is enabled, and SSE3 is supported by the processor).

But yes. I agree. Auto settings in the BIOS can be problematic. One reason could be that most BIOS developers have one OS target in mind, being MS Windows. My advise is to set it to the value that you expect. Better safe than sorry.

I cannot really comment on the Intel Power Gadget or DPCI but I do trust AppleIntelInfo.kext and I won't use anything else, because I know that it is right. It won't make up anything. I mean. If you see a value in the log file, then the frequency/p-state was used. Period.

What I can say is that AppleIntelInfo.kext is very aggressive (tiny interval) and the others may not.

One other thing. The 0x1A0 MSR is reprogrammed by XCPM, and that enables EIST, but you may use a patch to stop it from doing this. Are you?

llamafilm commented 8 years ago

I don't think I'm using any patches to disable EIST. The only Clover patch I'm using is Brumbaer's patch for IPCIFamily.

Here's the real problem: When set BIOS frequency to 40, the system is nice and fast (Geekbench 48000). But Clover detects bus frequency as 75MHz, because it's dividing the calibrated 3000MHz by 40. Therefore my system clock runs slow (75% speed), all video apps (like QuickTime) play at 75% speed, and audio sounds completely garbled.

According to Slice, the BIOS frequency must be set to 30. Indeed, that does fix the clock problems, but then my system runs slow (Geekbench 28000). With this setting and your SSDT, I have three p-states [ 27 29 (30) ]. How can I enable 40 to utilize the full power of this CPU?

Piker-Alpha commented 8 years ago

1.) Do you see a plugin-type property with a value of 1 on CPU0 in IORegistryExplorer? 2.) Is X86PlatformPlugin loaded. Check the first ACPI processor name? 3) What is the value of IOResources / intel_cpupm_matching? 4.) Wait. When you say "frequency" are you taking about the clock frequency and not the maximum turbo frequency? In that case Slice is correct. What you should do is set the clock multiplier to 30 and the turbo frequencies to 40. Why doesn't that work for you?

llamafilm commented 8 years ago
  1. Yes, under AppleACPIPlatformExpert : CP00@0 : plugin-type = 0x1
  2. Yes, it is loaded. Not sure how to answer your other question.
$ kextstat | grep X86PlatformPlugin
   73    1 0xffffff7f81c20000 0x17000    0x17000    com.apple.driver.X86PlatformPlugin (1.0.0) <72 71 44 11 7 6 5 4 3 1>
  1. The settings I've been changing is CPU Clock Ratio. Turbo is on auto, which looks like 40. This is what the BIOS looks like, and the second picture is Advanced CPU Core Settings. With these settings, my CPU never goes above 30. img_2538 cpu settings
Piker-Alpha commented 8 years ago

I first need to know the answer of Q3 so please enter:

ioreg -lw0|grep intel_cpupm_matching

Is that 0 or 3?

llamafilm commented 8 years ago

Sorry, I forgot to answer that one. That value is 0.

Piker-Alpha commented 8 years ago

Ah ok. You are now using the AppleIntelCPUPowerManagement.kext and have the plugin-type property set. That is not good – a limitation of the script that I need to fix. For now. Enter this in a terminal window:

./ssdtPRGen.sh -turbo 3000 -target 1 -w 1

That will give you a SSDT with a Method (_DSM) {..} in it, which you need to comment out yourself. Then you recompile the SSDT with /usr/local/bin/iasl. Or where you planning on using XCPM?

llamafilm commented 8 years ago

Why are you suggesting -turbo 3000 Shouldn't it be 4000?. Anyway, I tried just as you said, deleting the _DSM method, and here is the result using CPU Clock Ratio 30:

AppleIntelInfo.kext v1.5 Copyright © 2012-2016 Pike R. Alpha. All rights reserved

Settings:
------------------------------------
logMSRs............................: 1
logIGPU............................: 0
logCStates.........................: 1
logIPGStyle........................: 1
InitialTSC.........................: 0x2d822900aa8
MWAIT C-States.....................: 8480

Model Specific Registers
-----------------------------------
MSR_CORE_THREAD_COUNT......(0x35)  : 0xA0014
MSR_PLATFORM_INFO..........(0xCE)  : 0x20080C3BF3811E00
MSR_PMG_CST_CONFIG_CONTROL.(0xE2)  : 0x3
MSR_PMG_IO_CAPTURE_BASE....(0xE4)  : 0x0
IA32_MPERF.................(0xE7)  : 0x3421A03BC6
IA32_APERF.................(0xE8)  : 0x33A5C7C6BA
MSR_FLEX_RATIO.............(0x194) : 0xE0000
MSR_IA32_PERF_STATUS.......(0x198) : 0x1F4000001E00
MSR_IA32_PERF_CONTROL......(0x199) : 0x1E00
IA32_CLOCK_MODULATION......(0x19A) : 0x0
IA32_THERM_STATUS..........(0x19C) : 0x88360000
IA32_MISC_ENABLES..........(0x1A0) : 0x810089
MSR_MISC_PWR_MGMT..........(0x1AA) : 0x402000
MSR_TURBO_RATIO_LIMIT......(0x1AD) : 0x1E1E1E1E1E1E1E1E
IA32_ENERGY_PERF_BIAS......(0x1B0) : 0x0
MSR_POWER_CTL..............(0x1FC) : 0x2104005B
MSR_RAPL_POWER_UNIT........(0x606) : 0xA0E03
MSR_PKG_POWER_LIMIT........(0x610) : 0x7FFD00014EA82
MSR_PKG_ENERGY_STATUS......(0x611) : 0x4EF822C
MSR_PKG_POWER_INFO.........(0x614) : 0x1800460
MSR_PP0_POWER_LIMIT........(0x638) : 0x14FFD0
MSR_PP0_ENERGY_STATUS......(0x639) : 0x0
MSR_PKGC6_IRTL.............(0x60b) : 0x0
MSR_PKG_C2_RESIDENCY.......(0x60d) : 0x0
MSR_PKG_C6_RESIDENCY.......(0x3f9) : 0x0
IA32_TSC_DEADLINE..........(0x6E0) : 0x2D8252316AB

CPU Ratio Info:
------------------------------------
CPU Low Frequency Mode.............: 1200 MHz
CPU Maximum non-Turbo Frequency....: 3000 MHz
CPU Maximum Turbo Frequency........: 3000 MHz
CPU P-States [ 29 (30) ]
CPU P-States [ 28 29 (30) ]

This is with CPU Clock Ratio 40. I'm still confused which setting is correct.

AppleIntelInfo.kext v1.5 Copyright © 2012-2016 Pike R. Alpha. All rights reserved

Settings:
------------------------------------
logMSRs............................: 1
logIGPU............................: 0
logCStates.........................: 1
logIPGStyle........................: 1
InitialTSC.........................: 0x41719f95f3
MWAIT C-States.....................: 8480

Model Specific Registers
-----------------------------------
MSR_CORE_THREAD_COUNT......(0x35)  : 0xA0014
MSR_PLATFORM_INFO..........(0xCE)  : 0x20080C3BF3811E00
MSR_PMG_CST_CONFIG_CONTROL.(0xE2)  : 0x3
MSR_PMG_IO_CAPTURE_BASE....(0xE4)  : 0x0
IA32_MPERF.................(0xE7)  : 0x278B392C8F
IA32_APERF.................(0xE8)  : 0x33DE5D0973
MSR_FLEX_RATIO.............(0x194) : 0xE0000
MSR_IA32_PERF_STATUS.......(0x198) : 0x28FE00002800
MSR_IA32_PERF_CONTROL......(0x199) : 0x2800
IA32_CLOCK_MODULATION......(0x19A) : 0x0
IA32_THERM_STATUS..........(0x19C) : 0x88250000
IA32_MISC_ENABLES..........(0x1A0) : 0x810089
MSR_MISC_PWR_MGMT..........(0x1AA) : 0x402000
MSR_TURBO_RATIO_LIMIT......(0x1AD) : 0x2828282828282828
IA32_ENERGY_PERF_BIAS......(0x1B0) : 0x0
MSR_POWER_CTL..............(0x1FC) : 0x2104005B
MSR_RAPL_POWER_UNIT........(0x606) : 0xA0E03
MSR_PKG_POWER_LIMIT........(0x610) : 0x7FFD00014EA82
MSR_PKG_ENERGY_STATUS......(0x611) : 0x343521F
MSR_PKG_POWER_INFO.........(0x614) : 0x1800460
MSR_PP0_POWER_LIMIT........(0x638) : 0x14FFD0
MSR_PP0_ENERGY_STATUS......(0x639) : 0x0
MSR_PKGC6_IRTL.............(0x60b) : 0x0
MSR_PKG_C2_RESIDENCY.......(0x60d) : 0x0
MSR_PKG_C6_RESIDENCY.......(0x3f9) : 0x0
IA32_TSC_DEADLINE..........(0x6E0) : 0x4174BB8D31

CPU Ratio Info:
------------------------------------
CPU Low Frequency Mode.............: 1200 MHz
CPU Maximum non-Turbo Frequency....: 3000 MHz
CPU Maximum Turbo Frequency........: 4000 MHz
CPU P-States [ 39 (40) ]
CPU P-States [ 36 39 (40) ]

From reading your blog, I think XCPM is a better solution, but I haven't done anything with that yet, because I'm waiting on someone with more programming skills to port that to Yosemite.

Piker-Alpha commented 8 years ago

Yes. This is to get the script to output what you need for your setup. And it works, but I don't know what you are doing with your BIOS settings because, seriously, look at this:

MSR_TURBO_RATIO_LIMIT......(0x1AD) : 0x1E1E1E1E1E1E1E1E

This is why you see this:

CPU Maximum Turbo Frequency........: 3000 MHz

The BIOS set all cores to 3GHz (limiting performance) and that is definitely not what you want. Please fix that until you see:

CPU Maximum Turbo Frequency........: 4000 MHz

llamafilm commented 8 years ago

I appreciate your help, but I kinda feel like we're talking in circles. The "fix" for that is to set CPU Clock Ratio to 40, instead of auto or 30. The second kext output in my post above shows: CPU Maximum Turbo Frequency: 4000 MHz. But in that case, I have the clock drift issue. The BIOS screenshot shows Turbo Ratio is already set to 40, but that is apparently ignored, and my CPU runs all the time in the frequency I set in CPU Clock Ratio.

llamafilm commented 8 years ago

Update: Clover rev 3727 fixed the frequency detection bug, so I no longer have the clock drift issue. But still, the only way I can get p-state 40 is to set CPU Clock Ratio to 40. And now with the new Clover update, my Geekbench score is 75% slower.

Piker-Alpha commented 8 years ago

Fine that they fixed the Clover detection for you, and yes I know that your Geekbench score is lower, because you have told me that before, but I can also tell you that it will not change without you listening to me;

1.) The clock multiplier should be set to 30. 2.) The bus speed must be set to 100. 3.) The turbo ratios must be set correctly, and not fixed to 30 or any other insane value.

Number three here is important, but instead of listening to me, you went back and thought that the change in Clover was the fix for your problem. Well. It's not. You know that now. All it really does, and it does nothing more for you, is to masquerade the problem that we here are trying to solve, and that workaround is not the fix that you are looking for.

Listen. If you don't want my help, then please don't waste my time and energy, close this issue.

Thanks!

llamafilm commented 8 years ago

I think the problem was that I had set CPU Clock Ratio to 30. Apparently that locks it to 30 maximum, as verified in Windows. With that set to auto, OS X does see p-state 40 now. In the BIOS, I have bus speed set to 100MHz (auto), but Clover detects FSB frequency as 133MHz; is that a problem? I've never messed with Turbo Ratios, that has always been set to auto, which is 40 for 1 and 2 cores, and 34 for more cores, as shown in the BIOS photo above. This was the default, and I assume it has to throttle the speed in multi-core operations for heat.

AppleIntelInfo.kext v1.5 Copyright © 2012-2016 Pike R. Alpha. All rights reserved

Settings:
------------------------------------
logMSRs............................: 1
logIGPU............................: 0
logCStates.........................: 1
logIPGStyle........................: 1
InitialTSC.........................: 0x13d9f32553d
MWAIT C-States.....................: 8480

Model Specific Registers
-----------------------------------
MSR_CORE_THREAD_COUNT......(0x35)  : 0xA0014
MSR_PLATFORM_INFO..........(0xCE)  : 0x20080C3BF3811E00
MSR_PMG_CST_CONFIG_CONTROL.(0xE2)  : 0x3
MSR_PMG_IO_CAPTURE_BASE....(0xE4)  : 0x0
IA32_MPERF.................(0xE7)  : 0x3D60ABCB6D
IA32_APERF.................(0xE8)  : 0x50FE6DFE67
MSR_FLEX_RATIO.............(0x194) : 0xE0000
MSR_IA32_PERF_STATUS.......(0x198) : 0x289000002800
MSR_IA32_PERF_CONTROL......(0x199) : 0x1E00
IA32_CLOCK_MODULATION......(0x19A) : 0x0
IA32_THERM_STATUS..........(0x19C) : 0x88270000
IA32_MISC_ENABLES..........(0x1A0) : 0x810089
MSR_MISC_PWR_MGMT..........(0x1AA) : 0x402000
MSR_TURBO_RATIO_LIMIT......(0x1AD) : 0x2828282828282828
IA32_ENERGY_PERF_BIAS......(0x1B0) : 0x0
MSR_POWER_CTL..............(0x1FC) : 0x2104005B
MSR_RAPL_POWER_UNIT........(0x606) : 0xA0E03
MSR_PKG_POWER_LIMIT........(0x610) : 0x7FFD00014EA82
MSR_PKG_ENERGY_STATUS......(0x611) : 0xA203E47
MSR_PKG_POWER_INFO.........(0x614) : 0x1800460
MSR_PP0_POWER_LIMIT........(0x638) : 0x14FFD0
MSR_PP0_ENERGY_STATUS......(0x639) : 0x0
MSR_PKGC6_IRTL.............(0x60b) : 0x0
MSR_PKG_C2_RESIDENCY.......(0x60d) : 0x0
MSR_PKG_C6_RESIDENCY.......(0x3f9) : 0x0
IA32_TSC_DEADLINE..........(0x6E0) : 0x13DA1BFCEA8

CPU Ratio Info:
------------------------------------
CPU Low Frequency Mode.............: 1200 MHz
CPU Maximum non-Turbo Frequency....: 3000 MHz
CPU Maximum Turbo Frequency........: 4000 MHz
CPU P-States [ 38 (40) ]
CPU P-States [ 38 39 (40) ]

Clover boot.log

Piker-Alpha commented 8 years ago

A quick note. Is FakeCPUID still set to 0x0306F2? If yes try 0x04067s

Note: s= stepping like 0, 1, 2, or 4 for example.

The reason I ask this is that IA32_ENERGY_PERF_BIAS is not programmed – not set to 1, 5 or 15 – and thus I don't know if the MSR are programmed. Doesn't loo like it is, and that is a problem that we need to address first.

llamafilm commented 8 years ago

Yes, so far 0306F2 is the only thing I've found that works. I tried 04067s just now with 0,1,2,3,4, and every time it reboots after the row of plusses.

Piker-Alpha commented 8 years ago

I basically used 0x47 for the XCPM patches that I used for the Intel i7-6800K, i7-6850K and the i7-6900 and that worked just fine. I now also have confirmations from people with Xeons based on the Broadwelll processor series, and I think that you should use it too.

The only problem that I see, for you, is that you are still using Yosemite. I'm using Sierra, and while I also checked El Capitan, and the patches are confirmed to work as well, I have no intention to do this for Yosemite.

The patching can be done, and all you need to do is to read this blog article and patch the MSR's that I listed here.

The good news is that MSR(0xE2) isn't locked in your BIOS so that is one worry less. You can skip this one.

If all this patching is too much for you, then you should figure out what I did for the reboot patch, with Hopper, or e-mail me the kernel so that I can do it for you – though In this case I am going to ask you for a donation of at least 10 Euro (boot.efi.el.capitan@gmail.com) which I will use for the next giveaway, and your name will then also be mentioned.

llamafilm commented 8 years ago

Are you suggesting that I give up on traditional SpeedStep for 10.10, and use XCPM instead? I can't use El Cap right now, but I will upgrade to Sierra when it's official. I read your blog, but I have no idea how to patch MSRs. I'll be happy to donate, but I'm not sure how important this is actually. I'm running at full turbo all the time, so I guess the only downside is increased power consumption / greenhouse gas emissions. I'll think about it.