0001 Kernel driver fam15h_power
0002 ==========================
0003
0004 Supported chips:
0005
0006 * AMD Family 15h Processors
0007
0008 * AMD Family 16h Processors
0009
0010 Prefix: 'fam15h_power'
0011
0012 Addresses scanned: PCI space
0013
0014 Datasheets:
0015
0016 - BIOS and Kernel Developer's Guide (BKDG) For AMD Family 15h Processors
0017 - BIOS and Kernel Developer's Guide (BKDG) For AMD Family 16h Processors
0018 - AMD64 Architecture Programmer's Manual Volume 2: System Programming
0019
0020 Author: Andreas Herrmann <herrmann.der.user@googlemail.com>
0021
0022 Description
0023 -----------
0024
0025 1) Processor TDP (Thermal design power)
0026
0027 Given a fixed frequency and voltage, the power consumption of a
0028 processor varies based on the workload being executed. Derated power
0029 is the power consumed when running a specific application. Thermal
0030 design power (TDP) is an example of derated power.
0031
0032 This driver permits reading of registers providing power information
0033 of AMD Family 15h and 16h processors via TDP algorithm.
0034
0035 For AMD Family 15h and 16h processors the following power values can
0036 be calculated using different processor northbridge function
0037 registers:
0038
0039 * BasePwrWatts:
0040 Specifies in watts the maximum amount of power
0041 consumed by the processor for NB and logic external to the core.
0042
0043 * ProcessorPwrWatts:
0044 Specifies in watts the maximum amount of power
0045 the processor can support.
0046 * CurrPwrWatts:
0047 Specifies in watts the current amount of power being
0048 consumed by the processor.
0049
0050 This driver provides ProcessorPwrWatts and CurrPwrWatts:
0051
0052 * power1_crit (ProcessorPwrWatts)
0053 * power1_input (CurrPwrWatts)
0054
0055 On multi-node processors the calculated value is for the entire
0056 package and not for a single node. Thus the driver creates sysfs
0057 attributes only for internal node0 of a multi-node processor.
0058
0059 2) Accumulated Power Mechanism
0060
0061 This driver also introduces an algorithm that should be used to
0062 calculate the average power consumed by a processor during a
0063 measurement interval Tm. The feature of accumulated power mechanism is
0064 indicated by CPUID Fn8000_0007_EDX[12].
0065
0066 * Tsample:
0067 compute unit power accumulator sample period
0068
0069 * Tref:
0070 the PTSC counter period
0071
0072 * PTSC:
0073 performance timestamp counter
0074
0075 * N:
0076 the ratio of compute unit power accumulator sample period to the
0077 PTSC period
0078
0079 * Jmax:
0080 max compute unit accumulated power which is indicated by
0081 MaxCpuSwPwrAcc MSR C001007b
0082
0083 * Jx/Jy:
0084 compute unit accumulated power which is indicated by
0085 CpuSwPwrAcc MSR C001007a
0086 * Tx/Ty:
0087 the value of performance timestamp counter which is indicated
0088 by CU_PTSC MSR C0010280
0089
0090 * PwrCPUave:
0091 CPU average power
0092
0093 i. Determine the ratio of Tsample to Tref by executing CPUID Fn8000_0007.
0094
0095 N = value of CPUID Fn8000_0007_ECX[CpuPwrSampleTimeRatio[15:0]].
0096
0097 ii. Read the full range of the cumulative energy value from the new
0098 MSR MaxCpuSwPwrAcc.
0099
0100 Jmax = value returned.
0101
0102 iii. At time x, SW reads CpuSwPwrAcc MSR and samples the PTSC.
0103
0104 Jx = value read from CpuSwPwrAcc and Tx = value read from PTSC.
0105
0106 iv. At time y, SW reads CpuSwPwrAcc MSR and samples the PTSC.
0107
0108 Jy = value read from CpuSwPwrAcc and Ty = value read from PTSC.
0109
0110 v. Calculate the average power consumption for a compute unit over
0111 time period (y-x). Unit of result is uWatt::
0112
0113 if (Jy < Jx) // Rollover has occurred
0114 Jdelta = (Jy + Jmax) - Jx
0115 else
0116 Jdelta = Jy - Jx
0117 PwrCPUave = N * Jdelta * 1000 / (Ty - Tx)
0118
0119 This driver provides PwrCPUave and interval(default is 10 millisecond
0120 and maximum is 1 second):
0121
0122 * power1_average (PwrCPUave)
0123 * power1_average_interval (Interval)
0124
0125 The power1_average_interval can be updated at /etc/sensors3.conf file
0126 as below:
0127
0128 chip `fam15h_power-*`
0129 set power1_average_interval 0.01
0130
0131 Then save it with "sensors -s".