150476SpeterKernel driver fam15h_power 219026Sjulian========================== 367627Sasmodai 419026SjulianSupported chips: 519026Sjulian 619026Sjulian* AMD Family 15h Processors 719026Sjulian 819026Sjulian* AMD Family 16h Processors 919026Sjulian 1019026Sjulian Prefix: 'fam15h_power' 1119026Sjulian 1219026Sjulian Addresses scanned: PCI space 1319026Sjulian 1419026Sjulian Datasheets: 1519026Sjulian 1619026Sjulian - BIOS and Kernel Developer's Guide (BKDG) For AMD Family 15h Processors 1719026Sjulian - BIOS and Kernel Developer's Guide (BKDG) For AMD Family 16h Processors 1819026Sjulian - AMD64 Architecture Programmer's Manual Volume 2: System Programming 1919026Sjulian 2019026SjulianAuthor: Andreas Herrmann <herrmann.der.user@googlemail.com> 2119026Sjulian 2219026SjulianDescription 2319026Sjulian----------- 2419026Sjulian 2519026Sjulian1) Processor TDP (Thermal design power) 2619026Sjulian 2739257SgibbsGiven a fixed frequency and voltage, the power consumption of a 285884Sdgprocessor varies based on the workload being executed. Derated power 2979538Sruis the power consumed when running a specific application. Thermal 305884Sdgdesign power (TDP) is an example of derated power. 315884Sdg 3239257SgibbsThis driver permits reading of registers providing power information 335884Sdgof AMD Family 15h and 16h processors via TDP algorithm. 3422300Smpp 355884SdgFor AMD Family 15h and 16h processors the following power values can 365884Sdgbe calculated using different processor northbridge function 37140600Sruregisters: 3879727Sschweikh 3939257Sgibbs* BasePwrWatts: 4057676Ssheldonh Specifies in watts the maximum amount of power 4157676Ssheldonh consumed by the processor for NB and logic external to the core. 42117011Sru 43117011Sru* ProcessorPwrWatts: 4489610Smpp Specifies in watts the maximum amount of power 4539257Sgibbs the processor can support. 465884Sdg* CurrPwrWatts: 4739257Sgibbs Specifies in watts the current amount of power being 4839257Sgibbs consumed by the processor. 495884Sdg 5079727SschweikhThis driver provides ProcessorPwrWatts and CurrPwrWatts: 515884Sdg 5257676Ssheldonh* power1_crit (ProcessorPwrWatts) 5357676Ssheldonh* power1_input (CurrPwrWatts) 5479727Sschweikh 555884SdgOn multi-node processors the calculated value is for the entire 566813Sdufaultpackage and not for a single node. Thus the driver creates sysfs 5768716Sruattributes only for internal node0 of a multi-node processor. 5868716Sru 5968716Sru2) Accumulated Power Mechanism 605884Sdg 6179727SschweikhThis driver also introduces an algorithm that should be used to 625884Sdgcalculate the average power consumed by a processor during a 635884Sdgmeasurement interval Tm. The feature of accumulated power mechanism is 646813Sdufaultindicated by CPUID Fn8000_0007_EDX[12]. 656813Sdufault 666813Sdufault* Tsample: 676813Sdufault compute unit power accumulator sample period 685884Sdg 69193204Sjmallett* Tref: 70193204Sjmallett the PTSC counter period 71193204Sjmallett 72193204Sjmallett* PTSC: 73193204Sjmallett performance timestamp counter 74193204Sjmallett 755884Sdg* N: 7639257Sgibbs the ratio of compute unit power accumulator sample period to the 77117011Sru PTSC period 78117011Sru 7989610Smpp* Jmax: 80117011Sru max compute unit accumulated power which is indicated by 81117011Sru MaxCpuSwPwrAcc MSR C001007b 8239257Sgibbs 8339257Sgibbs* Jx/Jy: 8439257Sgibbs compute unit accumulated power which is indicated by 8539257Sgibbs CpuSwPwrAcc MSR C001007a 8639257Sgibbs* Tx/Ty: 8739257Sgibbs the value of performance timestamp counter which is indicated 8839257Sgibbs by CU_PTSC MSR C0010280 8939257Sgibbs 9039257Sgibbs* PwrCPUave: 9139257Sgibbs CPU average power 9239257Sgibbs 9379727Sschweikhi. Determine the ratio of Tsample to Tref by executing CPUID Fn8000_0007. 945884Sdg 9557676Ssheldonh N = value of CPUID Fn8000_0007_ECX[CpuPwrSampleTimeRatio[15:0]]. 9657676Ssheldonh 975884Sdgii. Read the full range of the cumulative energy value from the new 98119893Sru MSR MaxCpuSwPwrAcc. 9939257Sgibbs 10039257Sgibbs Jmax = value returned. 101117011Sru 102117011Sruiii. At time x, SW reads CpuSwPwrAcc MSR and samples the PTSC. 103117011Sru 104117011Sru Jx = value read from CpuSwPwrAcc and Tx = value read from PTSC. 105117011Sru 10639257Sgibbsiv. At time y, SW reads CpuSwPwrAcc MSR and samples the PTSC. 10739257Sgibbs 10839257Sgibbs Jy = value read from CpuSwPwrAcc and Ty = value read from PTSC. 10939257Sgibbs 11039257Sgibbsv. Calculate the average power consumption for a compute unit over 11139257Sgibbs time period (y-x). Unit of result is uWatt:: 11239257Sgibbs 11339257Sgibbs if (Jy < Jx) // Rollover has occurred 11439257Sgibbs Jdelta = (Jy + Jmax) - Jx 115117011Sru else 116117011Sru Jdelta = Jy - Jx 117117011Sru PwrCPUave = N * Jdelta * 1000 / (Ty - Tx) 118117011Sru 119117011SruThis driver provides PwrCPUave and interval(default is 10 millisecond 12039257Sgibbsand maximum is 1 second): 12139257Sgibbs 122117011Sru* power1_average (PwrCPUave) 12339257Sgibbs* power1_average_interval (Interval) 12439257Sgibbs 125117011SruThe power1_average_interval can be updated at /etc/sensors3.conf file 126117011Sruas below: 12739257Sgibbs 128117011Sruchip `fam15h_power-*` 129117011Sru set power1_average_interval 0.01 130117011Sru 131117011SruThen save it with "sensors -s". 132117011Sru