Angel Pons has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/42547 )
Change subject: cpu/intel/model_206ax: Add overclocking support ......................................................................
cpu/intel/model_206ax: Add overclocking support
Add a Kconfig option to force Turbo Ratio values to the maximum possible value, which is the maximum non-turbo ratio plus the number of OC bins.
Tested on Asus P8Z77-V LX2 with an i5-3330, CPU now runs at 3.4 GHz.
Change-Id: I60bef32bfdde3c32a11f07afff64fc83d65fd3f1 Signed-off-by: Angel Pons th3fanbus@gmail.com --- M src/cpu/intel/model_206ax/Kconfig M src/cpu/intel/model_206ax/model_206ax.h M src/cpu/intel/model_206ax/model_206ax_init.c 3 files changed, 55 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/47/42547/1
diff --git a/src/cpu/intel/model_206ax/Kconfig b/src/cpu/intel/model_206ax/Kconfig index c6a5020..df78524 100644 --- a/src/cpu/intel/model_206ax/Kconfig +++ b/src/cpu/intel/model_206ax/Kconfig @@ -38,4 +38,13 @@ int default 8
+config FORCE_MAX_TURBO_RATIO + bool "Force turbo ratios to the maximum possible value" + default n + help + By selecting this, all core turbo ratios will be set to the maximum possible value, + which is the maximum non-turbo ratio of the CPU plus the number of overclocking bins + by which the CPU can be overclocked. This is an overclocking option and therefore is + dangerous to enable, especially on mobile platforms with a limited cooling solution! + endif diff --git a/src/cpu/intel/model_206ax/model_206ax.h b/src/cpu/intel/model_206ax/model_206ax.h index e24993c..7ac3ec9 100644 --- a/src/cpu/intel/model_206ax/model_206ax.h +++ b/src/cpu/intel/model_206ax/model_206ax.h @@ -18,6 +18,7 @@ #define MSR_PIC_MSG_CONTROL 0x2e #define MSR_PLATFORM_INFO 0xce #define PLATFORM_INFO_SET_TDP (1 << 29) +#define PLATFORM_INFO_RATIO_LIMIT (1 << 28)
#define MSR_MISC_PWR_MGMT 0x1aa #define MISC_PWR_MGMT_EIST_HW_DIS (1 << 0) diff --git a/src/cpu/intel/model_206ax/model_206ax_init.c b/src/cpu/intel/model_206ax/model_206ax_init.c index e69d4fa..de4392d 100644 --- a/src/cpu/intel/model_206ax/model_206ax_init.c +++ b/src/cpu/intel/model_206ax/model_206ax_init.c @@ -14,6 +14,7 @@ #include <cpu/intel/turbo.h> #include <cpu/x86/cache.h> #include <cpu/x86/name.h> +#include <stdint.h> #include "model_206ax.h" #include "chip.h" #include <cpu/intel/smm_reloc.h> @@ -439,6 +440,47 @@ printk(BIOS_INFO, "CPU: VT %ssupported\n", mode[vt]); }
+static void xe_init(void) +{ + msr_t msr; + + /* If not enabled, do not touch anything */ + if (!CONFIG(FORCE_MAX_TURBO_RATIO)) { + printk(BIOS_DEBUG, "XE: not overriding Turbo Ratio limits\n"); + return; + } + + /* Get the number of OC bins */ + msr = rdmsr(MSR_FLEX_RATIO); + const uint8_t oc_bins = (msr.lo >> 17) & 0x7; + + /* Ensure that the preconditions for XE are true */ + msr = rdmsr(MSR_PLATFORM_INFO); + if (!(cpuid_eax(1) >= 0x206a3 && (msr.lo & PLATFORM_INFO_RATIO_LIMIT) && oc_bins)) { + + printk(BIOS_WARNING, "XE: Cannot configure XE on a non-XE processor\n"); + return; + } + + /* Obtain maximum non-turbo ratio from MSR_PLATFORM_INFO */ + const uint8_t max_non_turbo = (msr.lo >> 8) & 0xff; + + /* Now do the deed */ + msr = rdmsr(MSR_TURBO_RATIO_LIMIT); + + msr.lo = 0; + msr.lo |= (max_non_turbo + oc_bins) << 0; + msr.lo |= (max_non_turbo + oc_bins) << 8; + msr.lo |= (max_non_turbo + oc_bins) << 16; + msr.lo |= (max_non_turbo + oc_bins) << 24; + + printk(BIOS_NOTICE, "XE: Setting Turbo Ratio to %d... ", max_non_turbo + oc_bins); + + wrmsr(MSR_TURBO_RATIO_LIMIT, msr); + + printk(BIOS_NOTICE, "done.\n"); +} + static void model_206ax_init(struct device *cpu) {
@@ -481,6 +523,9 @@
/* Enable Turbo */ enable_turbo(); + + /* Crank up the turbo ratio, if possible and desired */ + xe_init(); }
/* MP initialization support. */
Patrick Rudolph has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/42547 )
Change subject: cpu/intel/model_206ax: Add overclocking support ......................................................................
Patch Set 1: Code-Review+1
(3 comments)
https://review.coreboot.org/c/coreboot/+/42547/1/src/cpu/intel/model_206ax/m... File src/cpu/intel/model_206ax/model_206ax_init.c:
https://review.coreboot.org/c/coreboot/+/42547/1/src/cpu/intel/model_206ax/m... PS1, Line 443: xe_init what's XE? Extreme?
https://review.coreboot.org/c/coreboot/+/42547/1/src/cpu/intel/model_206ax/m... PS1, Line 449: printk(BIOS_DEBUG, "XE: not overriding Turbo Ratio limits\n"); since the default is disabled, only print this text when it has been enabled in Kconfig?
https://review.coreboot.org/c/coreboot/+/42547/1/src/cpu/intel/model_206ax/m... PS1, Line 459: 0x206a3 huh, that cpuid isn't in the cpu_table list?
Paul Menzel has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/42547 )
Change subject: cpu/intel/model_206ax: Add overclocking support ......................................................................
Patch Set 1:
(2 comments)
Very cool!
https://review.coreboot.org/c/coreboot/+/42547/1//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/42547/1//COMMIT_MSG@12 PS1, Line 12: Tested on Asus P8Z77-V LX2 with an i5-3330, CPU now runs at 3.4 GHz. How did you check that? coreboot output? Linux output?
Could you please add what (max.) frequency did it run before? The internet says 3.2 GHz.
https://review.coreboot.org/c/coreboot/+/42547/1//COMMIT_MSG@13 PS1, Line 13: It’d be awesome, if you added a reference to some datasheet, so people can look up, what “overclocking bins” are for example.
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/42547 )
Change subject: cpu/intel/model_206ax: Add overclocking support ......................................................................
Patch Set 1:
(5 comments)
https://review.coreboot.org/c/coreboot/+/42547/1//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/42547/1//COMMIT_MSG@12 PS1, Line 12: Tested on Asus P8Z77-V LX2 with an i5-3330, CPU now runs at 3.4 GHz.
How did you check that? coreboot output? Linux output? […]
I checked the speed using /proc/cpuinfo while loading all CPU cores. Before, the frequency under the same conditions would be 3.0 GHz (the non-turbo frequency) with coreboot (Asus stock firmware allows one to set the multiplier ratios).
Normally, Turbo Boost uses higher ratios when less CPU cores are active. With this, one can force the maximum turbo ratio for any number of active CPU cores. That 3.2 GHz is most likely the turbo frequency with only one active core.
The maximum non-turbo frequency of 3.0 GHz, which they call `processor base frequency` is on ARK. Intel just uses the larger `max turbo frequency` in the title, because it looks better 😄
https://ark.intel.com/content/www/us/en/ark/products/65509/intel-core-i5-333...
https://review.coreboot.org/c/coreboot/+/42547/1//COMMIT_MSG@13 PS1, Line 13:
It’d be awesome, if you added a reference to some datasheet, so people can look up, what “overclocki […]
Having `n` overclocking bins means that the max turbo ratio is equal to the non-turbo ratio plus `n`. On the i5-3330 I have, `n` is 4, so I can get an extra 0.4 GHz for free 😄
Unfortunately, the relevant MSRs aren't in datasheets, only on non-public material 😞
IIRC there's a comment in finalize.c which mentions the BIOS Writer's Guide, so I could mention this document as well. Even if most people don't have access to the BWG, it would be better than nothing.
https://review.coreboot.org/c/coreboot/+/42547/1/src/cpu/intel/model_206ax/m... File src/cpu/intel/model_206ax/model_206ax_init.c:
https://review.coreboot.org/c/coreboot/+/42547/1/src/cpu/intel/model_206ax/m... PS1, Line 443: xe_init
what's XE? Extreme?
IIRC, it means eXtreme Edition. Apparently, this procedure is called "XE initialization", hence the function name. Shall I put a comment on the function?
https://review.coreboot.org/c/coreboot/+/42547/1/src/cpu/intel/model_206ax/m... PS1, Line 449: printk(BIOS_DEBUG, "XE: not overriding Turbo Ratio limits\n");
since the default is disabled, only print this text when it has been enabled in Kconfig?
The idea is that this function always prints one line when executed. This allows one to know which path was taken when this function has run. However, note that each printk has a different loglevel. This is intentional, as each path has a different severity.
Taking this path is expected, so this message is just for debugging.
The error path is more important, because this option was enabled but it could not do what one expected it to do. Still, it does not prevent a successful boot, so it's only a warning.
The last message is split in two because writing to the MSR could raise a GP# fault. In most circumstances, it should not happen, but splitting it in two allows one to know which value was being programmed, and that the fault happened right there. Furthermore, its loglevel is BIOS_NOTICE because it means the CPU is now overclocked, which might effect stability and is thus important to know when debugging.
https://review.coreboot.org/c/coreboot/+/42547/1/src/cpu/intel/model_206ax/m... PS1, Line 459: 0x206a3
huh, that cpuid isn't in the cpu_table list?
0x206a0 is on the cpu_table list, and the oc_bins value for it would not be valid. Looks like 0x206a3 is a valid CPUID, albeit only used in engineering samples.
http://www.cpu-world.com/cgi-bin/CPUID.pl?CPUID=12861
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/42547 )
Change subject: cpu/intel/model_206ax: Add overclocking support ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/c/coreboot/+/42547/1/src/cpu/intel/model_206ax/m... File src/cpu/intel/model_206ax/model_206ax_init.c:
https://review.coreboot.org/c/coreboot/+/42547/1/src/cpu/intel/model_206ax/m... PS1, Line 481: printk(BIOS_NOTICE, "done.\n"); Uh, this should only run once, but it runs for all CPU cores...
https://paste.flashrom.org/view.php?id=3329
Hello build bot (Jenkins), Patrick Rudolph, Patrick Rudolph,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/42547
to look at the new patch set (#2).
Change subject: cpu/intel/model_206ax: Add overclocking support ......................................................................
cpu/intel/model_206ax: Add overclocking support
Add a Kconfig option to force Turbo Ratio values to the maximum possible value, which is the maximum non-turbo ratio plus the number of OC bins. The OC bins value comes from the FLEX_RATIO MSR bits 19..17 and is the maximum allowed difference between the max turbo and non-turbo ratios. The relevant MSRs are documented in the non-public BIOS Writer's Guide.
If the number of OC bins is seven, it indicates that the CPU is unlocked and can use even higher multiplier ratios. Due to lack of hardware, this was not implemented. Plus, it would require a recovery mechanism should the requested multiplier render the computer unable to boot correctly. So, unlocked CPUs are treated like limited overclocking-capable parts.
Normally, Turbo Boost uses higher ratios when less CPU cores are active. With this option, one can force the CPU to use the maximum turbo ratio for any number of active CPU cores, effectively running the CPU faster. Please make sure your thermal solution can handle the extra heat output!
Tested on Asus P8Z77-V LX2 with an i7-2600 and an i5-3330, by checking the output of `cat /proc/cpuinfo` with all CPU threads under load:
- i7-2600: 34 max non-turbo ratio + 4 OC bins = 38 max turbo ratio. - i5-3330: 30 max non-turbo ratio + 4 OC bins = 34 max turbo ratio.
Change-Id: I60bef32bfdde3c32a11f07afff64fc83d65fd3f1 Signed-off-by: Angel Pons th3fanbus@gmail.com --- M src/cpu/intel/model_206ax/Kconfig M src/cpu/intel/model_206ax/model_206ax.h M src/cpu/intel/model_206ax/model_206ax_init.c 3 files changed, 67 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/47/42547/2
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/42547 )
Change subject: cpu/intel/model_206ax: Add overclocking support ......................................................................
Patch Set 2:
(5 comments)
https://review.coreboot.org/c/coreboot/+/42547/1//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/42547/1//COMMIT_MSG@12 PS1, Line 12: Tested on Asus P8Z77-V LX2 with an i5-3330, CPU now runs at 3.4 GHz.
I checked the speed using /proc/cpuinfo while loading all CPU cores. […]
Expanded the commit message, also tested a Sandy Bridge i7-2600
https://review.coreboot.org/c/coreboot/+/42547/1//COMMIT_MSG@13 PS1, Line 13:
Having `n` overclocking bins means that the max turbo ratio is equal to the non-turbo ratio plus `n` […]
Mentioned the BWG in the commit message, and referenced it on a comment in the code
https://review.coreboot.org/c/coreboot/+/42547/1/src/cpu/intel/model_206ax/m... File src/cpu/intel/model_206ax/model_206ax_init.c:
https://review.coreboot.org/c/coreboot/+/42547/1/src/cpu/intel/model_206ax/m... PS1, Line 443: xe_init
IIRC, it means eXtreme Edition. […]
Added a comment explaining what this function is about.
https://review.coreboot.org/c/coreboot/+/42547/1/src/cpu/intel/model_206ax/m... PS1, Line 449: printk(BIOS_DEBUG, "XE: not overriding Turbo Ratio limits\n");
The idea is that this function always prints one line when executed. […]
I updated the comment above it, but left the printk as-is for now while waiting for updates.
https://review.coreboot.org/c/coreboot/+/42547/1/src/cpu/intel/model_206ax/m... PS1, Line 481: printk(BIOS_NOTICE, "done.\n");
Uh, this should only run once, but it runs for all CPU cores... […]
Removed the printk after wrmsr.
Paul Menzel has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/42547 )
Change subject: cpu/intel/model_206ax: Add overclocking support ......................................................................
Patch Set 2: Code-Review+1
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/42547 )
Change subject: cpu/intel/model_206ax: Add overclocking support ......................................................................
Patch Set 2:
(1 comment)
https://review.coreboot.org/c/coreboot/+/42547/1/src/cpu/intel/model_206ax/m... File src/cpu/intel/model_206ax/model_206ax_init.c:
https://review.coreboot.org/c/coreboot/+/42547/1/src/cpu/intel/model_206ax/m... PS1, Line 449: printk(BIOS_DEBUG, "XE: not overriding Turbo Ratio limits\n");
I updated the comment above it, but left the printk as-is for now while waiting for updates.
Ack
Attention is currently required from: AreYouLoco?, Angel Pons. Arthur Heymans has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/42547 )
Change subject: cpu/intel/model_206ax: Add overclocking support ......................................................................
Patch Set 3:
(1 comment)
File src/cpu/intel/model_206ax/model_206ax_init.c:
https://review.coreboot.org/c/coreboot/+/42547/comment/e3015883_5b3a2f29 PS3, Line 473: 0x206a3 This is not in the cpuid table. What are you trying to do? Should this apply to all IVB (0x306ax) and SNB stepping > 3? If so I think it would nice to make this explicit (maybe using get_fms).
Attention is currently required from: AreYouLoco?, Arthur Heymans. Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/42547 )
Change subject: cpu/intel/model_206ax: Add overclocking support ......................................................................
Patch Set 3:
(2 comments)
File src/cpu/intel/model_206ax/model_206ax_init.c:
https://review.coreboot.org/c/coreboot/+/42547/comment/988c323b_2152c563 PS3, Line 473: 0x206a3
This is not in the cpuid table. What are you trying to do? […]
I don't remember what I was trying to do, it's probably what reference code does. I guess I can drop the CPUID check.
https://review.coreboot.org/c/coreboot/+/42547/comment/d22cac02_4b716992 PS3, Line 491: %d use `%u` you doofus