Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x86_64 Overclocking #67

Closed
cyring opened this issue Jul 26, 2018 · 9 comments
Closed

x86_64 Overclocking #67

cyring opened this issue Jul 26, 2018 · 9 comments
Assignees

Comments

@cyring
Copy link
Owner

cyring commented Jul 26, 2018

In the specifications of MSR_PLATFORM_INFO for architecture signature 06_3AH the bit 28 has the following definition:

Programmable Ratio Limit for Turbo Mode (R/O)
When set to 1, indicates that Programmable Ratio Limit for Turbo mode is enabled. When set to 0,
indicates Programmable Ratio Limit for Turbo mode is disabled.

Edit: Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz has the Ratios reported correctly locked.

Processor                             [ Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz]
|- Architecture                                                      [IvyBridge]
|- Vendor ID                                                      [GenuineIntel]
|- Signature                                                            [ 06_3A]
|- Stepping                                                             [     9]
|- Microcode                                                            [     0]
|- Online CPU                                                           [  8/8 ]
|- Base Clock                                                           [ 98.97]
|- Overclocking                                                         [  LOCK]
|- Frequency            (Mhz)                      Ratio                        
                 Min   1583.59                    [  16 ]                       
                 Max   3365.12                    [  34 ]                       
|- Factory                                                                      
                       3400                       [  34 ]               [100.00]
|- Turbo Boost                                                                  
                  1C   3860.00                    [  39 ]                       
                  2C   3860.00                    [  39 ]                       
                  3C   3761.02                    [  38 ]                       
                  4C   3662.05                    [  37 ]                       
|- Uncore                                                                       
                 Min   1583.59                    [  16 ]                       
                 Max   3365.12                    [  34 ]                       
                                                                                
ISA Extensions:                                                                 
|- 3DNow!/Ext [N,N]        AES [Y]   AVX/AVX2 [Y/N]   BMI1/BMI2 [N/N] 
|- CLFSH        [Y]       CMOV [Y]      CMPXCH8 [Y]      CMPXCH16 [Y] 
|- F16C         [Y]        FPU [Y]         FXSR [Y]     LAHF/SAHF [Y] 
|- MMX/Ext    [Y/N]    MONITOR [Y]        MOVBE [N]      PCLMULDQ [Y] 
|- POPCNT       [Y]     RDRAND [Y]       RDTSCP [Y]           SEP [Y] 
|- SGX          [N]        SSE [Y]         SSE2 [Y]          SSE3 [Y] 
|- SSSE3        [Y] SSE4.1/4A [Y/N]      SSE4.2 [Y]       SYSCALL [Y] 
                                                                                
Features:                                                                       
|- 1 GB Pages Support                                      1GB-PAGES   [Missing]
|- 100 MHz multiplier Control                            100MHzSteps   [Missing]
|- Advanced Configuration & Power Interface                     ACPI   [Present]
|- Advanced Programmable Interrupt Controller                   APIC   [Present]
|- Core Multi-Processing                                  CMP Legacy   [Missing]
|- L1 Data Cache Context ID                                  CNXT-ID   [Missing]
|- Direct Cache Access                                           DCA   [Missing]
|- Debugging Extension                                            DE   [Present]
|- Debug Store & Precise Event Based Sampling               DS, PEBS   [Present]
|- CPL Qualified Debug Store                                  DS-CPL   [Present]
|- 64-Bit Debug Store                                         DTES64   [Present]
|- Fast-String Operation                                Fast-Strings   [Present]
|- Fused Multiply Add                                       FMA|FMA4   [Missing]
|- Hardware Lock Elision                                         HLE   [Missing]
|- Long Mode 64 bits                                         IA64|LM   [Present]
|- LightWeight Profiling                                         LWP   [Missing]
|- Machine-Check Architecture                                    MCA   [Present]
|- Model Specific Registers                                      MSR   [Present]
|- Memory Type Range Registers                                  MTRR   [Present]
|- OS-Enabled Ext. State Management                          OSXSAVE   [Present]
|- Physical Address Extension                                    PAE   [Present]
|- Page Attribute Table                                          PAT   [Present]
|- Pending Break Enable                                          PBE   [Present]
|- Process Context Identifiers                                  PCID   [Present]
|- Perfmon and Debug Capability                                 PDCM   [Present]
|- Page Global Enable                                            PGE   [Present]
|- Page Size Extension                                           PSE   [Present]
|- 36-bit Page Size Extension                                  PSE36   [Present]
|- Processor Serial Number                                       PSN   [Missing]
|- Restricted Transactional Memory                               RTM   [Missing]
|- Safer Mode Extensions                                         SMX   [Present]
|- Self-Snoop                                                     SS   [Present]
|- Time Stamp Counter                                            TSC [Invariant]
|- Time Stamp Counter Deadline                          TSC-DEADLINE   [Present]
|- Virtual Mode Extension                                        VME   [Present]
|- Virtual Machine Extensions                                    VMX   [Present]
|- Extended xAPIC Support                                     x2APIC   [ x2APIC]
|- Execution Disable Bit Support                              XD-Bit   [Present]
|- XSAVE/XSTOR States                                          XSAVE   [Present]
|- xTPR Update Control                                          xTPR   [Present]
                                                                                
Technologies:                                                                   
|- System Management Mode                                   SMM-Dual       [ ON]
|- Hyper-Threading                                               HTT       [ ON]
|- SpeedStep                                                    EIST       < ON>
|- Dynamic Acceleration                                          IDA       [ ON]
|- Turbo Boost                                                 TURBO       < ON>
|- Virtualization                                                VMX       [ ON]
   |- I/O MMU                                                   VT-d       [OFF]
   |- Hypervisor                                                           [OFF]
                                                                                
Performance Monitoring:                                                         
|- Version                                                        PM       [  3]
|- Counters:          General                   Fixed                           
|                     4 x 48 bits             3 x 48 bits                       
|- Enhanced Halt State                                           C1E       < ON>
|- C1 Auto Demotion                                              C1A       < ON>
|- C3 Auto Demotion                                              C3A       < ON>
|- C1 UnDemotion                                                 C1U       < ON>
|- C3 UnDemotion                                                 C3U       < ON>
|- Frequency ID control                                          FID       [OFF]
|- Voltage ID control                                            VID       [OFF]
|- P-State Hardware Coordination Feedback                MPERF/APERF       [ ON]
|- Hardware-Controlled Performance States                        HWP       [OFF]
|- Hardware Duty Cycling                                         HDC       [OFF]
|- Package C-State                                                              
   |- Configuration Control                                   CONFIG   [   LOCK]
   |- Lowest C-State                                           LIMIT   [      6]
   |- I/O MWAIT Redirection                                  IOMWAIT   [ ENABLE]
   |- Max C-State Inclusion                                    RANGE   [      6]
|- MWAIT States:      C0      C1      C2      C3      C4                        
|                      0       2       1       1       0                        
|- Core Cycles                                                         [Present]
|- Instructions Retired                                                [Present]
|- Reference Cycles                                                    [Present]
|- Last Level Cache References                                         [Present]
|- Last Level Cache Misses                                             [Present]
|- Branch Instructions Retired                                         [Present]
|- Branch Mispredicts Retired                                          [Present]
                                                                                
Power & Thermal Monitoring:                                                     
|- Clock Modulation                                             ODCM   <Disable>
   |- DutyCycle                                                        <  6.25%>
|- Power Management                                         PWR MGMT   [   LOCK]
   |- Energy Policy                                        Bias Hint   [      0]
|- Junction Temperature                                        TjMax   [    105]
|- Digital Thermal Sensor                                        DTS   [Present]
|- Power Limit Notification                                      PLN   [Present]
|- Package Thermal Management                                    PTM   [Present]
|- Thermal Monitor 1                                         TM1|TTP   [ Enable]
|- Thermal Monitor 2                                         TM2|HTC   [Present]
|- Units                                                                        
   |- Power                                               watt   [  0.125000000]
   |- Energy                                             joule   [  0.000015259]
   |- Window                                            second   [  0.000976562]
@cyring cyring added the bug label Jul 26, 2018
@cyring cyring self-assigned this Jul 26, 2018
@cyring cyring added bugfix and removed bug labels Jul 27, 2018
@cyring
Copy link
Owner Author

cyring commented Jul 27, 2018

Changed the bits decoding of MSR PLATFORM INFO. Overclocking exceptions remain feasible through the Specifics list.
This issue stays opened for any user request of model addition.

@cyring cyring changed the title Overclocking blacklist Overclocking black-or-whitelist Jul 27, 2018
@cyring
Copy link
Owner Author

cyring commented Jul 30, 2018

Need to blacklist overclocking on the i5-7500 which reports unlocked ratios.

Processor                              [Intel(R) Core(TM) i5-7500 CPU @ 3.40GHz]
|- Architecture                                               [Kaby/Coffee Lake]
|- Vendor ID                                                      [GenuineIntel]
|- Signature                                                            [ 06_9E]
|- Stepping                                                             [     9]
|- Microcode                                                            [     0]
|- Online CPU                                                           [  4/4 ]
|- Base Clock                                                           [ 99.44]
|- Overclocking                                                         [UNLOCK]
|- Frequency            (Mhz)                      Ratio                        
                 Min    795.55                    [   8 ]                       
                 Max   3381.08                    [  34 ]                       
|- Factory                                                                      
                       3400                       [  34 ]               [100.00]
|- Turbo Boost                                                                  
                  1C   3778.85                    <  38 >                       
                  2C   3679.41                    <  37 >                       
                  3C   3679.41                    <  37 >                       
                  4C   3579.96                    <  36 >                       
|- Uncore                                                                       
                 Min    795.55                    [   8 ]                       
                 Max   3480.52                    [  35 ]                       
                                                                                
ISA Extensions:                                                                 
|- 3DNow!/Ext [N,N]        AES [Y]   AVX/AVX2 [Y/Y]   BMI1/BMI2 [Y/Y] 
|- CLFSH        [Y]       CMOV [Y]      CMPXCH8 [Y]      CMPXCH16 [Y] 
|- F16C         [Y]        FPU [Y]         FXSR [Y]     LAHF/SAHF [Y] 
|- MMX/Ext    [Y/N]    MONITOR [Y]        MOVBE [Y]      PCLMULDQ [Y] 
|- POPCNT       [Y]     RDRAND [Y]       RDTSCP [Y]           SEP [Y] 
|- SGX          [Y]        SSE [Y]         SSE2 [Y]          SSE3 [Y] 
|- SSSE3        [Y] SSE4.1/4A [Y/N]      SSE4.2 [Y]       SYSCALL [Y] 
                                                                                
Features:                                                                       
|- 1 GB Pages Support                                      1GB-PAGES   [Present]
|- 100 MHz multiplier Control                            100MHzSteps   [Missing]
|- Advanced Configuration & Power Interface                     ACPI   [Present]
|- Advanced Programmable Interrupt Controller                   APIC   [Present]
|- Core Multi-Processing                                  CMP Legacy   [Missing]
|- L1 Data Cache Context ID                                  CNXT-ID   [Missing]
|- Direct Cache Access                                           DCA   [Missing]
|- Debugging Extension                                            DE   [Present]
|- Debug Store & Precise Event Based Sampling               DS, PEBS   [Present]
|- CPL Qualified Debug Store                                  DS-CPL   [Present]
|- 64-Bit Debug Store                                         DTES64   [Present]
|- Fast-String Operation                                Fast-Strings   [Present]
|- Fused Multiply Add                                       FMA|FMA4   [Present]
|- Hardware Lock Elision                                         HLE   [Present]
|- Long Mode 64 bits                                         IA64|LM   [Present]
|- LightWeight Profiling                                         LWP   [Missing]
|- Machine-Check Architecture                                    MCA   [Present]
|- Model Specific Registers                                      MSR   [Present]
|- Memory Type Range Registers                                  MTRR   [Present]
|- OS-Enabled Ext. State Management                          OSXSAVE   [Present]
|- Physical Address Extension                                    PAE   [Present]
|- Page Attribute Table                                          PAT   [Present]
|- Pending Break Enable                                          PBE   [Present]
|- Process Context Identifiers                                  PCID   [Present]
|- Perfmon and Debug Capability                                 PDCM   [Present]
|- Page Global Enable                                            PGE   [Present]
|- Page Size Extension                                           PSE   [Present]
|- 36-bit Page Size Extension                                  PSE36   [Present]
|- Processor Serial Number                                       PSN   [Missing]
|- Restricted Transactional Memory                               RTM   [Present]
|- Safer Mode Extensions                                         SMX   [Present]
|- Self-Snoop                                                     SS   [Present]
|- Time Stamp Counter                                            TSC [Invariant]
|- Time Stamp Counter Deadline                          TSC-DEADLINE   [Present]
|- Virtual Mode Extension                                        VME   [Present]
|- Virtual Machine Extensions                                    VMX   [Present]
|- Extended xAPIC Support                                     x2APIC   [ x2APIC]
|- Execution Disable Bit Support                              XD-Bit   [Present]
|- XSAVE/XSTOR States                                          XSAVE   [Present]
|- xTPR Update Control                                          xTPR   [Present]
                                                                                
Technologies:                                                                   
|- System Management Mode                                   SMM-Dual       [ ON]
|- Hyper-Threading                                               HTT       [OFF]
|- SpeedStep                                                    EIST       < ON>
|- Dynamic Acceleration                                          IDA       [ ON]
|- Turbo Boost                                                 TURBO       < ON>
|- Virtualization                                                VMX       [ ON]
   |- I/O MMU                                                   VT-d       [OFF]
   |- Hypervisor                                                           [OFF]
                                                                                
Performance Monitoring:                                                         
|- Version                                                        PM       [  4]
|- Counters:          General                   Fixed                           
|                     8 x 48 bits             3 x 48 bits                       
|- Enhanced Halt State                                           C1E       <OFF>
|- C1 Auto Demotion                                              C1A       < ON>
|- C3 Auto Demotion                                              C3A       < ON>
|- C1 UnDemotion                                                 C1U       < ON>
|- C3 UnDemotion                                                 C3U       < ON>
|- Frequency ID control                                          FID       [OFF]
|- Voltage ID control                                            VID       [OFF]
|- P-State Hardware Coordination Feedback                MPERF/APERF       [ ON]
|- Hardware-Controlled Performance States                        HWP       [ ON]
|- Hardware Duty Cycling                                         HDC       [ ON]
|- Package C-State                                                              
   |- Configuration Control                                   CONFIG   [   LOCK]
   |- Lowest C-State                                           LIMIT   [      0]
   |- I/O MWAIT Redirection                                  IOMWAIT   [DISABLE]
   |- Max C-State Inclusion                                    RANGE   [      0]
|- MWAIT States:      C0      C1      C2      C3      C4                        
|                      0       2       1       2       4                        
|- Core Cycles                                                         [Present]
|- Instructions Retired                                                [Present]
|- Reference Cycles                                                    [Present]
|- Last Level Cache References                                         [Present]
|- Last Level Cache Misses                                             [Present]
|- Branch Instructions Retired                                         [Present]
|- Branch Mispredicts Retired                                          [Present]
                                                                                
Power & Thermal Monitoring:                                                     
|- Clock Modulation                                             ODCM   <Disable>
   |- DutyCycle                                                        <  6.25%>
|- Power Management                                         PWR MGMT   [   LOCK]
   |- Energy Policy                                        Bias Hint   [      0]
|- Junction Temperature                                        TjMax   [    100]
|- Digital Thermal Sensor                                        DTS   [Present]
|- Power Limit Notification                                      PLN   [Present]
|- Package Thermal Management                                    PTM   [Present]
|- Thermal Monitor 1                                         TM1|TTP   [ Enable]
|- Thermal Monitor 2                                         TM2|HTC   [Present]
|- Units                                                                        
   |- Power                                               watt   [  0.125000000]
   |- Energy                                             joule   [  0.000061035]
   |- Window                                            second   [  0.000976562]

Fix to apply in corefreqk.h

static PROCESSOR_SPECIFIC Kabylake_Specific[] = {
	{
	.brandSubStr = "Intel(R) Core(TM) i5-7500 CPU",
	.ratioUnlocked = 0
	},
	{NULL, 0}
};

/* 42*/	{
	.Signature = _Kabylake,
	.Query = Query_Broadwell,
	.Update = PerCore_Skylake_Query,
	.Start = Start_Skylake,
	.Stop = Stop_Skylake,
	.Exit = NULL,
	.Timer = InitTimer_Skylake,
	.BaseClock = BaseClock_Skylake,
	.OverClock = Intel_Turbo_Config8C,
	.Architecture = "Kaby/Coffee Lake",
	.thermalFormula = THERMAL_FORMULA_INTEL,
	.voltageFormula = VOLTAGE_FORMULA_INTEL_SNB,
	.powerFormula   = POWER_FORMULA_INTEL,
	.PCI_ids = PCI_Kabylake_ids,
	.Uncore = {
		.Start = Start_Uncore_Skylake,
		.Stop = Stop_Uncore_Skylake
		},
	.Specific = Kabylake_Specific
	},

@cyring cyring removed the bugfix label Jul 30, 2018
@cyring
Copy link
Owner Author

cyring commented Jul 31, 2018

Fix the vertical alignment of ratio at offset 0

wOC->matrix.scroll.vert = (hthMax - hthWin) >> 1;

		wOC->matrix.scroll.vert = hthMax >> 1;

@cyring
Copy link
Owner Author

cyring commented Aug 1, 2018

Max and Min Uncore overclocking is successfully tested

2018-08-02-112812_642x386_scrot

Fix for the selection window in corefreq-cli.c

    Window *CreateUC(unsigned long long id)
    {
	ATTRIBUTE attribute[2][28] = {
		{
		LWK,HWK,HWK,HWK,HWK,LWK,HWK,HWK,LWK,HDK,HDK,HDK,LWK,LWK,
		LWK,LWK,HWK,HWK,HWK,HWK,LWK,LWK,LWK,LWK,LWK,LWK,LWK,LWK
		},
		{
		LWK,HRK,HRK,HRK,HRK,LRK,HRK,HRK,LWK,HDK,HDK,HDK,LWK,LWK,
		LWK,LWK,HWK,HWK,HWK,HWK,LWK,LWK,LWK,LWK,LWK,LWK,LWK,LWK
		}
	};
	ASCII item[32];
	CLOCK_ARG overclock  = {.sllong = id};
	unsigned int ratio = overclock.Ratio & OVERCLOCK_RATIO_MASK, multiplier;
	signed int offset,
	lowestOperatingShift = abs(Shm->Uncore.Boost[UNCORE_BOOST(SIZE) - ratio]
				 - Shm->Proc.Boost[BOOST(MIN)]),
	highestOperatingShift	= Shm->Proc.Features.Factory.Ratio
				+(Shm->Proc.Features.Factory.Ratio >> 3)
				- Shm->Uncore.Boost[UNCORE_BOOST(SIZE) - ratio];
	const CUINT	hthMin = 16;
		CUINT	hthMax = 1 + lowestOperatingShift+highestOperatingShift,
			hthWin = CUMIN(hthMin, hthMax);

	Window *wUC = CreateWindow(wLayer, id, 1, hthWin, 40,
				(TOP_HEADER_ROW + hthWin+2 < drawSize.height) ?
					TOP_HEADER_ROW + 2 : 1);
      if (wUC != NULL) {
	for (offset = -lowestOperatingShift;
		offset <= highestOperatingShift;
			offset++)
		{
		overclock.Ratio = ratio | BOXKEY_UNCORE_CLOCK;
		overclock.Offset = offset;
		multiplier = Shm->Uncore.Boost[UNCORE_BOOST(SIZE) - ratio];
		multiplier += offset;

		sprintf((char*) item, " %7.2f MHz   [%4d ]  %+3d ",
			(double)(multiplier
				* Shm->Cpu[Shm->Proc.Service.Core].Clock.Hz)
				/ 1000000.0,
			multiplier, offset);

		StoreTCell(wUC, overclock.sllong, item,
			attribute[multiplier > Shm->Proc.Features.Factory.Ratio?
					1 : 0]);
		}
	sprintf((char*) item, " %s Clock Uncore ", ratio == 1 ? "Max" : "Min");
	StoreWindow(wUC, .title, (char*) item);

	if (lowestOperatingShift >= hthWin) {
		wUC->matrix.scroll.vert = hthMax
					- hthWin * (1 + (highestOperatingShift
							/ hthWin));
		wUC->matrix.select.row  = lowestOperatingShift
					- wUC->matrix.scroll.vert;
	} else {
		wUC->matrix.select.row  = lowestOperatingShift;
	}
	StoreWindow(wUC,	.key.Enter,	MotionEnter_Cell);
	StoreWindow(wUC,	.key.Down,	MotionDown_Win);
	StoreWindow(wUC,	.key.Up,	MotionUp_Win);
	StoreWindow(wUC,	.key.PgUp,	MotionPgUp_Win);
	StoreWindow(wUC,	.key.PgDw,	MotionPgDw_Win);
	StoreWindow(wUC,	.key.Home,	MotionTop_Win);
	StoreWindow(wUC,	.key.End,	MotionBottom_Win);

	StoreWindow(wUC,	.key.WinLeft,	MotionOriginLeft_Win);
	StoreWindow(wUC,	.key.WinRight,	MotionOriginRight_Win);
	StoreWindow(wUC,	.key.WinDown,	MotionOriginDown_Win);
	StoreWindow(wUC,	.key.WinUp,	MotionOriginUp_Win);
      }
	return(wUC);
    }

@cyring
Copy link
Owner Author

cyring commented Aug 3, 2018

i5-7300U [KBL/UY]

Window *CreateOC(unsigned long long id)

    Window *CreateOC(unsigned long long id)
    {
	ATTRIBUTE attribute[3][28] = {
		{
		LWK,HWK,HWK,HWK,HWK,LWK,HWK,HWK,LWK,HDK,HDK,HDK,LWK,LWK,
		LWK,LWK,HWK,HWK,HWK,HWK,LWK,LWK,LWK,LWK,LWK,LWK,LWK,LWK
		},
		{
		LWK,HBK,HBK,HBK,HBK,LBK,HBK,HBK,LWK,HDK,HDK,HDK,LWK,LWK,
		LWK,LWK,HWK,HWK,HWK,HWK,LWK,LWK,LWK,LWK,LWK,LWK,LWK,LWK
		},
		{
		LWK,HRK,HRK,HRK,HRK,LRK,HRK,HRK,LWK,HDK,HDK,HDK,LWK,LWK,
		LWK,LWK,HWK,HWK,HWK,HWK,LWK,LWK,LWK,LWK,LWK,LWK,LWK,LWK
		}
	};
	ASCII item[32];
	CLOCK_ARG overclock  = {.sllong = id};
	unsigned int ratio = overclock.Ratio & OVERCLOCK_RATIO_MASK, multiplier;
	signed int offset,
		lowestOperatingShift= abs(Shm->Proc.Boost[BOOST(SIZE) - ratio]
					- Shm->Proc.Boost[BOOST(MIN)]),
		medianColdZone =( Shm->Proc.Boost[BOOST(MIN)]
				+ Shm->Proc.Features.Factory.Ratio ) >> 1,
		startingHotZone = Shm->Proc.Features.Factory.Ratio
				+(Shm->Proc.Features.Factory.Ratio * 2 / 5),
		highestOperatingShift = (unsigned int) (5100000000.0
				/ Shm->Cpu[Shm->Proc.Service.Core].Clock.Hz)
				- Shm->Proc.Boost[BOOST(SIZE) - ratio];
	const CUINT	hthMin = 16;
		CUINT	hthMax = 1+lowestOperatingShift + highestOperatingShift,
			hthWin = CUMIN(hthMin, hthMax);

	Window *wOC = CreateWindow(wLayer, id, 1, hthWin, 34,
				(TOP_HEADER_ROW + hthWin+2 < drawSize.height) ?
					TOP_HEADER_ROW + 2 : 1);
      if (wOC != NULL) {
	for (offset = -lowestOperatingShift;
		offset <= highestOperatingShift;
			offset++)
		{
		overclock.Ratio = ratio | BOXKEY_OVERCLOCK;
		overclock.Offset = offset;
		multiplier = Shm->Proc.Boost[BOOST(SIZE) - ratio] + offset;

		sprintf((char*) item, " %7.2f MHz   [%4d ]  %+3d ",
			(double)(multiplier
				* Shm->Cpu[Shm->Proc.Service.Core].Clock.Hz)
				/ 1000000.0,
			multiplier, offset);

		StoreTCell(wOC, overclock.sllong, item,
			attribute[multiplier < medianColdZone ?
					1 : multiplier >= startingHotZone ?
						2 : 0]);
		}
	sprintf((char*) item, " Under/Over-Clock %1dC ", ratio);
	StoreWindow(wOC, .title, (char*) item);

	if (lowestOperatingShift >= hthWin) {
		wOC->matrix.scroll.vert = hthMax
					- hthWin * (1 + (highestOperatingShift
							/ hthWin));
		wOC->matrix.select.row  = lowestOperatingShift
					- wOC->matrix.scroll.vert;
	} else {
		wOC->matrix.select.row  = lowestOperatingShift;
	}
	StoreWindow(wOC,	.key.Enter,	MotionEnter_Cell);
	StoreWindow(wOC,	.key.Down,	MotionDown_Win);
	StoreWindow(wOC,	.key.Up,	MotionUp_Win);
	StoreWindow(wOC,	.key.PgUp,	MotionPgUp_Win);
	StoreWindow(wOC,	.key.PgDw,	MotionPgDw_Win);
	StoreWindow(wOC,	.key.Home,	MotionTop_Win);
	StoreWindow(wOC,	.key.End,	MotionBottom_Win);

	StoreWindow(wOC,	.key.WinLeft,	MotionOriginLeft_Win);
	StoreWindow(wOC,	.key.WinRight,	MotionOriginRight_Win);
	StoreWindow(wOC,	.key.WinDown,	MotionOriginDown_Win);
	StoreWindow(wOC,	.key.WinUp,	MotionOriginUp_Win);
      }
	return(wOC);
    }

    Window *CreateUC(unsigned long long id)
    {
	ATTRIBUTE attribute[2][28] = {
		{
		LWK,HWK,HWK,HWK,HWK,LWK,HWK,HWK,LWK,HDK,HDK,HDK,LWK,LWK,
		LWK,LWK,HWK,HWK,HWK,HWK,LWK,LWK,LWK,LWK,LWK,LWK,LWK,LWK
		},
		{
		LWK,HRK,HRK,HRK,HRK,LRK,HRK,HRK,LWK,HDK,HDK,HDK,LWK,LWK,
		LWK,LWK,HWK,HWK,HWK,HWK,LWK,LWK,LWK,LWK,LWK,LWK,LWK,LWK
		}
	};
	ASCII item[32];
	CLOCK_ARG overclock  = {.sllong = id};
	unsigned int ratio = overclock.Ratio & OVERCLOCK_RATIO_MASK, multiplier;
	signed int offset,
	lowestOperatingShift = abs(Shm->Uncore.Boost[UNCORE_BOOST(SIZE) - ratio]
				 - Shm->Proc.Boost[BOOST(MIN)]),
	highestOperatingShift	= Shm->Proc.Features.Factory.Ratio
				+(Shm->Proc.Features.Factory.Ratio >> 1)
				- Shm->Uncore.Boost[UNCORE_BOOST(SIZE) - ratio],
	startingHotZone = Shm->Proc.Features.Factory.Ratio + 
			+(Shm->Proc.Features.Factory.Ratio * 2 / 5);
	const CUINT	hthMin = 16;
		CUINT	hthMax = 1+lowestOperatingShift + highestOperatingShift,
			hthWin = CUMIN(hthMin, hthMax);

	Window *wUC = CreateWindow(wLayer, id, 1, hthWin, 40,
				(TOP_HEADER_ROW + hthWin+2 < drawSize.height) ?
					TOP_HEADER_ROW + 2 : 1);
      if (wUC != NULL) {
	for (offset = -lowestOperatingShift;
		offset <= highestOperatingShift;
			offset++)
		{
		overclock.Ratio = ratio | BOXKEY_UNCORE_CLOCK;
		overclock.Offset = offset;
		multiplier = Shm->Uncore.Boost[UNCORE_BOOST(SIZE) - ratio];
		multiplier += offset;

		sprintf((char*) item, " %7.2f MHz   [%4d ]  %+3d ",
			(double)(multiplier
				* Shm->Cpu[Shm->Proc.Service.Core].Clock.Hz)
				/ 1000000.0,
			multiplier, offset);

		StoreTCell(wUC, overclock.sllong, item,
			attribute[multiplier > startingHotZone ? 1 : 0]);
		}
	sprintf((char*) item, " %s Clock Uncore ", ratio == 1 ? "Max" : "Min");
	StoreWindow(wUC, .title, (char*) item);

	if (lowestOperatingShift >= hthWin) {
		wUC->matrix.scroll.vert = hthMax
					- hthWin * (1 + (highestOperatingShift
							/ hthWin));
		wUC->matrix.select.row  = lowestOperatingShift
					- wUC->matrix.scroll.vert;
	} else {
		wUC->matrix.select.row  = lowestOperatingShift;
	}
	StoreWindow(wUC,	.key.Enter,	MotionEnter_Cell);
	StoreWindow(wUC,	.key.Down,	MotionDown_Win);
	StoreWindow(wUC,	.key.Up,	MotionUp_Win);
	StoreWindow(wUC,	.key.PgUp,	MotionPgUp_Win);
	StoreWindow(wUC,	.key.PgDw,	MotionPgDw_Win);
	StoreWindow(wUC,	.key.Home,	MotionTop_Win);
	StoreWindow(wUC,	.key.End,	MotionBottom_Win);

	StoreWindow(wUC,	.key.WinLeft,	MotionOriginLeft_Win);
	StoreWindow(wUC,	.key.WinRight,	MotionOriginRight_Win);
	StoreWindow(wUC,	.key.WinDown,	MotionOriginDown_Win);
	StoreWindow(wUC,	.key.WinUp,	MotionOriginUp_Win);
      }
	return(wUC);
    }

void Query_Broadwell(void)

void Query_Broadwell(void)
{
	Proc->Features.Uncore_Unlock = 1;
	Nehalem_Platform_Info();
	HyperThreading_Technology();
	Haswell_Uncore_Ratio(NULL);
	SandyBridge_PowerInterface();
}

/* 30*/ {

/* 30*/	{
	.Signature = _Haswell_DT,
	.Query = Query_Haswell,
	.Update = PerCore_IvyBridge_Query,
	.Start = Start_SandyBridge,
	.Stop = Stop_SandyBridge,
	.Exit = NULL,
	.Timer = InitTimer_SandyBridge,
	.BaseClock = BaseClock_Haswell,
	.OverClock = Intel_Turbo_Config8C,
	.Architecture = "Haswell/Desktop",
	.thermalFormula = THERMAL_FORMULA_INTEL,
	.voltageFormula = VOLTAGE_FORMULA_INTEL_SNB,
	.powerFormula   = POWER_FORMULA_INTEL,
	.PCI_ids = PCI_Haswell_ids,
	.Uncore = {
		.Start = Start_Uncore_SandyBridge,
		.Stop = Stop_Uncore_SandyBridge
		},
	.Specific = Void_Specific
	},

extern void Query_Haswell_EP(void) ;

extern void Query_Haswell(void) ;

void Query_Haswell_EP(void)

void Query_Haswell(void)
{
	Proc->Features.Uncore_Unlock = 1;
	Nehalem_Platform_Info();
	HyperThreading_Technology();
	SandyBridge_Uncore_Ratio();
	Intel_Turbo_TDP_Config();
	SandyBridge_PowerInterface();
}


@cyring
Copy link
Owner Author

cyring commented Aug 15, 2018

Code backported

@cyring cyring closed this as completed Aug 15, 2018
@cyring
Copy link
Owner Author

cyring commented May 8, 2019

Reopening case based on this last experimentation.

  1. The BIOS has been set with the following parameters :
  • Turbo is disable
  • CPU ratio is set to 28
  • C-States, EIST, C1E, C1A, C3A enable
  • Base clock is set to its factory value 133.333 MHz
  1. The Kernel runs in POLL mode with this command line:
idle=poll processor.max_cstate=1 intel_idle.max_cstate=0 cpufreq.off=1 intel_pstate=disable nmi_watchdog=0 modprobe.blacklist=pcspkr,iTCO_wdt,intel_cstate,intel_uncore,intel_powerclamp,i7core_edac,aesni_intel,ghash_clmulni_intel,crc32c_intel,crypto-crc32c-intel,i5500_temp,vboxnetflt,vboxnetadp,vboxpci,vboxdrv,kvm_intel,kvm,coretemp cpu0_hotplug audit=0
  1. Results with BIOS CPU coefficient locked
    2019-05-08-105924_804x644_scrot
    2019-05-08-105909_804x644_scrot
    2019-05-08-105851_804x644_scrot

  2. BIOS CPU coefficient set to Auto

  • System is reboot with the CPU ratio set to Auto in BIOS

  • The Kernel is boot with idle=nomwait

  • Nominal values
    2019-05-08-121401_804x644_scrot

  • Target = Target + 1
    2019-05-08-121456_804x644_scrot

  • Turbo 6C = Turbo 6C + 1
    2019-05-08-121523_804x644_scrot

  • Again, Turbo 6C = Turbo 6C + 1
    2019-05-08-122941_804x644_scrot

  1. Conclusion (partial)
    The Max Frequency is a function of :
  • Turbo register with the highest Simultaneous Core Count ratio in action
  • Target OSPM ratio set to 1 + max non boosted ratio
  1. C-States governed by ACPI
  • In BIOS: coefficient set to Auto and Turbo is enable
  • The Kernel command line is changed to allow C-States governed by ACPI only; without the intel_cstate idle driver.
idle=mwait processor.max_cstate=6 intel_idle.max_cstate=0 cpufreq.off=1 intel_pstate=disable elevator=noop nmi_watchdog=0 modprobe.blacklist=pcspkr,iTCO_wdt,intel_cstate,intel_uncore,intel_powerclamp,i7core_edac,aesni_intel,ghash_clmulni_intel,crc32c_intel,crypto-crc32c-intel,i5500_temp,vboxnetflt,vboxnetadp,vboxpci,vboxdrv,kvm_intel,kvm,coretemp cpu0_hotplug audit=0 
  • Initial state
    2019-05-08-175809_804x644_scrot

  • Turbo enable by CoreFreq
    2019-05-08-175959_804x644_scrot

  1. Conclusion (partial)
    The Max Frequency is now a function of :
  • Turbo register with One Core Count ratio in action
  • Target OSPM ratio set to 1 + max non boosted ratio

@cyring cyring reopened this May 8, 2019
@cyring
Copy link
Owner Author

cyring commented May 8, 2019

Kernel x86_64 functions

Start

start_kernel()
___ -> check_bugs()
_________ -> identify_boot_cpu()
_______________ -> identify_cpu()
_____________________ -> select_idle_routine()

select_idle_routine()

SMP

The idle loop implementation

do_idle
___ -> cpu_idle_poll()
_________ -> cpu_relax()
_______________ -> asm volatile("rep; nop" ::: "memory")
OR
___ -> cpuidle_idle_call()
_________ -> default_idle_call()
_______________ -> arch_cpu_idle()
_____________________ -> x86_idle() as a function of select_idle_routine()
___________________________ -> default_idle()
___________________________ OR
___________________________ -> mwait_idle()
_________ OR
_________ -> call_cpuidle()
_______________ -> cpuidle_enter()
_____________________ -> cpuidle_enter_state()
___________________________ -> target_state->enter() is one driver idle function vector

Registers & Instructions

  • across all architectures
    IA32_MONITOR_FILTER_SIZE (0x6)

@cyring cyring changed the title Overclocking black-or-whitelist Intel Overclocking May 8, 2019
@cyring cyring changed the title Intel Overclocking x86_64 Overclocking May 8, 2019
@cyring
Copy link
Owner Author

cyring commented Sep 2, 2019

Idle & Frequency sub-drivers implemented.

@cyring cyring closed this as completed Sep 2, 2019
This was referenced Dec 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant