132 lines · plain
1Kernel driver fam15h_power2==========================3 4Supported chips:5 6* AMD Family 15h Processors7 8* AMD Family 16h Processors9 10 Prefix: 'fam15h_power'11 12 Addresses scanned: PCI space13 14 Datasheets:15 16 - BIOS and Kernel Developer's Guide (BKDG) For AMD Family 15h Processors17 - BIOS and Kernel Developer's Guide (BKDG) For AMD Family 16h Processors18 - AMD64 Architecture Programmer's Manual Volume 2: System Programming19 20Author: Andreas Herrmann <herrmann.der.user@googlemail.com>21 22Description23-----------24 251) Processor TDP (Thermal design power)26 27Given a fixed frequency and voltage, the power consumption of a28processor varies based on the workload being executed. Derated power29is the power consumed when running a specific application. Thermal30design power (TDP) is an example of derated power.31 32This driver permits reading of registers providing power information33of AMD Family 15h and 16h processors via TDP algorithm.34 35For AMD Family 15h and 16h processors the following power values can36be calculated using different processor northbridge function37registers:38 39* BasePwrWatts:40 Specifies in watts the maximum amount of power41 consumed by the processor for NB and logic external to the core.42 43* ProcessorPwrWatts:44 Specifies in watts the maximum amount of power45 the processor can support.46* CurrPwrWatts:47 Specifies in watts the current amount of power being48 consumed by the processor.49 50This driver provides ProcessorPwrWatts and CurrPwrWatts:51 52* power1_crit (ProcessorPwrWatts)53* power1_input (CurrPwrWatts)54 55On multi-node processors the calculated value is for the entire56package and not for a single node. Thus the driver creates sysfs57attributes only for internal node0 of a multi-node processor.58 592) Accumulated Power Mechanism60 61This driver also introduces an algorithm that should be used to62calculate the average power consumed by a processor during a63measurement interval Tm. The feature of accumulated power mechanism is64indicated by CPUID Fn8000_0007_EDX[12].65 66* Tsample:67 compute unit power accumulator sample period68 69* Tref:70 the PTSC counter period71 72* PTSC:73 performance timestamp counter74 75* N:76 the ratio of compute unit power accumulator sample period to the77 PTSC period78 79* Jmax:80 max compute unit accumulated power which is indicated by81 MaxCpuSwPwrAcc MSR C001007b82 83* Jx/Jy:84 compute unit accumulated power which is indicated by85 CpuSwPwrAcc MSR C001007a86* Tx/Ty:87 the value of performance timestamp counter which is indicated88 by CU_PTSC MSR C001028089 90* PwrCPUave:91 CPU average power92 93i. Determine the ratio of Tsample to Tref by executing CPUID Fn8000_0007.94 95 N = value of CPUID Fn8000_0007_ECX[CpuPwrSampleTimeRatio[15:0]].96 97ii. Read the full range of the cumulative energy value from the new98 MSR MaxCpuSwPwrAcc.99 100 Jmax = value returned.101 102iii. At time x, SW reads CpuSwPwrAcc MSR and samples the PTSC.103 104 Jx = value read from CpuSwPwrAcc and Tx = value read from PTSC.105 106iv. At time y, SW reads CpuSwPwrAcc MSR and samples the PTSC.107 108 Jy = value read from CpuSwPwrAcc and Ty = value read from PTSC.109 110v. Calculate the average power consumption for a compute unit over111 time period (y-x). Unit of result is uWatt::112 113 if (Jy < Jx) // Rollover has occurred114 Jdelta = (Jy + Jmax) - Jx115 else116 Jdelta = Jy - Jx117 PwrCPUave = N * Jdelta * 1000 / (Ty - Tx)118 119This driver provides PwrCPUave and interval(default is 10 millisecond120and maximum is 1 second):121 122* power1_average (PwrCPUave)123* power1_average_interval (Interval)124 125The power1_average_interval can be updated at /etc/sensors3.conf file126as below:127 128chip `fam15h_power-*`129 set power1_average_interval 0.01130 131Then save it with "sensors -s".132