1Kernel driver fam15h_power
2==========================
3
4Supported chips:
5* AMD Family 15h Processors
6* AMD Family 16h Processors
7
8  Prefix: 'fam15h_power'
9  Addresses scanned: PCI space
10  Datasheets:
11  BIOS and Kernel Developer's Guide (BKDG) For AMD Family 15h Processors
12  BIOS and Kernel Developer's Guide (BKDG) For AMD Family 16h Processors
13  AMD64 Architecture Programmer's Manual Volume 2: System Programming
14
15Author: Andreas Herrmann <herrmann.der.user@googlemail.com>
16
17Description
18-----------
19
201) Processor TDP (Thermal design power)
21
22Given a fixed frequency and voltage, the power consumption of a
23processor varies based on the workload being executed. Derated power
24is the power consumed when running a specific application. Thermal
25design power (TDP) is an example of derated power.
26
27This driver permits reading of registers providing power information
28of AMD Family 15h and 16h processors via TDP algorithm.
29
30For AMD Family 15h and 16h processors the following power values can
31be calculated using different processor northbridge function
32registers:
33
34* BasePwrWatts: Specifies in watts the maximum amount of power
35  consumed by the processor for NB and logic external to the core.
36* ProcessorPwrWatts: Specifies in watts the maximum amount of power
37  the processor can support.
38* CurrPwrWatts: Specifies in watts the current amount of power being
39  consumed by the processor.
40
41This driver provides ProcessorPwrWatts and CurrPwrWatts:
42* power1_crit (ProcessorPwrWatts)
43* power1_input (CurrPwrWatts)
44
45On multi-node processors the calculated value is for the entire
46package and not for a single node. Thus the driver creates sysfs
47attributes only for internal node0 of a multi-node processor.
48
492) Accumulated Power Mechanism
50
51This driver also introduces an algorithm that should be used to
52calculate the average power consumed by a processor during a
53measurement interval Tm. The feature of accumulated power mechanism is
54indicated by CPUID Fn8000_0007_EDX[12].
55
56* Tsample: compute unit power accumulator sample period
57* Tref: the PTSC counter period
58* PTSC: performance timestamp counter
59* N: the ratio of compute unit power accumulator sample period to the
60  PTSC period
61* Jmax: max compute unit accumulated power which is indicated by
62  MaxCpuSwPwrAcc MSR C001007b
63* Jx/Jy: compute unit accumulated power which is indicated by
64  CpuSwPwrAcc MSR C001007a
65* Tx/Ty: the value of performance timestamp counter which is indicated
66  by CU_PTSC MSR C0010280
67* PwrCPUave: CPU average power
68
69i. Determine the ratio of Tsample to Tref by executing CPUID Fn8000_0007.
70	N = value of CPUID Fn8000_0007_ECX[CpuPwrSampleTimeRatio[15:0]].
71
72ii. Read the full range of the cumulative energy value from the new
73MSR MaxCpuSwPwrAcc.
74	Jmax = value returned.
75iii. At time x, SW reads CpuSwPwrAcc MSR and samples the PTSC.
76	Jx = value read from CpuSwPwrAcc and Tx = value read from
77PTSC.
78
79iv. At time y, SW reads CpuSwPwrAcc MSR and samples the PTSC.
80	Jy = value read from CpuSwPwrAcc and Ty = value read from
81PTSC.
82
83v. Calculate the average power consumption for a compute unit over
84time period (y-x). Unit of result is uWatt.
85	if (Jy < Jx) // Rollover has occurred
86		Jdelta = (Jy + Jmax) - Jx
87	else
88		Jdelta = Jy - Jx
89	PwrCPUave = N * Jdelta * 1000 / (Ty - Tx)
90
91This driver provides PwrCPUave and interval(default is 10 millisecond
92and maximum is 1 second):
93* power1_average (PwrCPUave)
94* power1_average_interval (Interval)
95
96The power1_average_interval can be updated at /etc/sensors3.conf file
97as below:
98
99chip "fam15h_power-*"
100	set power1_average_interval 0.01
101
102Then save it with "sensors -s".
103