blob: fdde632c93a3838cc5ce2735d879eac9b118fcc2 [file] [log] [blame]
Andreas Herrmann512d1022011-05-25 20:43:31 +02001Kernel driver fam15h_power
2==========================
3
4Supported chips:
Mauro Carvalho Chehabb413e3f2019-04-17 06:46:15 -03005
Andreas Herrmann512d1022011-05-25 20:43:31 +02006* AMD Family 15h Processors
Mauro Carvalho Chehabb413e3f2019-04-17 06:46:15 -03007
Huang Rui5aeb5d22015-08-27 16:07:37 +08008* AMD Family 16h Processors
Andreas Herrmann512d1022011-05-25 20:43:31 +02009
10 Prefix: 'fam15h_power'
Mauro Carvalho Chehabb413e3f2019-04-17 06:46:15 -030011
Andreas Herrmann512d1022011-05-25 20:43:31 +020012 Addresses scanned: PCI space
Mauro Carvalho Chehabb413e3f2019-04-17 06:46:15 -030013
Andreas Herrmann512d1022011-05-25 20:43:31 +020014 Datasheets:
Mauro Carvalho Chehabb413e3f2019-04-17 06:46:15 -030015
16 - BIOS and Kernel Developer's Guide (BKDG) For AMD Family 15h Processors
17 - BIOS and Kernel Developer's Guide (BKDG) For AMD Family 16h Processors
18 - AMD64 Architecture Programmer's Manual Volume 2: System Programming
Andreas Herrmann512d1022011-05-25 20:43:31 +020019
Andreas Herrmannd034fbf2012-10-29 18:50:47 +010020Author: Andreas Herrmann <herrmann.der.user@googlemail.com>
Andreas Herrmann512d1022011-05-25 20:43:31 +020021
22Description
23-----------
24
Huang Ruia6e232f2016-04-06 15:44:14 +0800251) Processor TDP (Thermal design power)
26
27Given a fixed frequency and voltage, the power consumption of a
28processor varies based on the workload being executed. Derated power
29is the power consumed when running a specific application. Thermal
30design power (TDP) is an example of derated power.
31
Andreas Herrmann512d1022011-05-25 20:43:31 +020032This driver permits reading of registers providing power information
Huang Ruia6e232f2016-04-06 15:44:14 +080033of AMD Family 15h and 16h processors via TDP algorithm.
Andreas Herrmann512d1022011-05-25 20:43:31 +020034
Huang Rui5aeb5d22015-08-27 16:07:37 +080035For AMD Family 15h and 16h processors the following power values can
36be calculated using different processor northbridge function
37registers:
Andreas Herrmann512d1022011-05-25 20:43:31 +020038
Mauro Carvalho Chehabb413e3f2019-04-17 06:46:15 -030039* BasePwrWatts:
40 Specifies in watts the maximum amount of power
41 consumed by the processor for NB and logic external to the core.
42
43* ProcessorPwrWatts:
44 Specifies in watts the maximum amount of power
45 the processor can support.
46* CurrPwrWatts:
47 Specifies in watts the current amount of power being
48 consumed by the processor.
Andreas Herrmann512d1022011-05-25 20:43:31 +020049
50This driver provides ProcessorPwrWatts and CurrPwrWatts:
Mauro Carvalho Chehabb413e3f2019-04-17 06:46:15 -030051
Andreas Herrmann512d1022011-05-25 20:43:31 +020052* power1_crit (ProcessorPwrWatts)
53* power1_input (CurrPwrWatts)
54
55On multi-node processors the calculated value is for the entire
56package and not for a single node. Thus the driver creates sysfs
57attributes only for internal node0 of a multi-node processor.
Huang Ruia6e232f2016-04-06 15:44:14 +080058
592) Accumulated Power Mechanism
60
61This driver also introduces an algorithm that should be used to
62calculate the average power consumed by a processor during a
63measurement interval Tm. The feature of accumulated power mechanism is
64indicated by CPUID Fn8000_0007_EDX[12].
65
Mauro Carvalho Chehabb413e3f2019-04-17 06:46:15 -030066* Tsample:
67 compute unit power accumulator sample period
68
69* Tref:
70 the PTSC counter period
71
72* PTSC:
73 performance timestamp counter
74
75* N:
76 the ratio of compute unit power accumulator sample period to the
77 PTSC period
78
79* Jmax:
80 max compute unit accumulated power which is indicated by
81 MaxCpuSwPwrAcc MSR C001007b
82
83* Jx/Jy:
84 compute unit accumulated power which is indicated by
85 CpuSwPwrAcc MSR C001007a
86* Tx/Ty:
87 the value of performance timestamp counter which is indicated
88 by CU_PTSC MSR C0010280
89
90* PwrCPUave:
91 CPU average power
Huang Ruia6e232f2016-04-06 15:44:14 +080092
93i. Determine the ratio of Tsample to Tref by executing CPUID Fn8000_0007.
Mauro Carvalho Chehabb413e3f2019-04-17 06:46:15 -030094
Huang Ruia6e232f2016-04-06 15:44:14 +080095 N = value of CPUID Fn8000_0007_ECX[CpuPwrSampleTimeRatio[15:0]].
96
97ii. Read the full range of the cumulative energy value from the new
Mauro Carvalho Chehabb413e3f2019-04-17 06:46:15 -030098 MSR MaxCpuSwPwrAcc.
99
Huang Ruia6e232f2016-04-06 15:44:14 +0800100 Jmax = value returned.
Mauro Carvalho Chehabb413e3f2019-04-17 06:46:15 -0300101
Huang Ruia6e232f2016-04-06 15:44:14 +0800102iii. At time x, SW reads CpuSwPwrAcc MSR and samples the PTSC.
Mauro Carvalho Chehabb413e3f2019-04-17 06:46:15 -0300103
104 Jx = value read from CpuSwPwrAcc and Tx = value read from PTSC.
Huang Ruia6e232f2016-04-06 15:44:14 +0800105
106iv. At time y, SW reads CpuSwPwrAcc MSR and samples the PTSC.
Mauro Carvalho Chehabb413e3f2019-04-17 06:46:15 -0300107
108 Jy = value read from CpuSwPwrAcc and Ty = value read from PTSC.
Huang Ruia6e232f2016-04-06 15:44:14 +0800109
110v. Calculate the average power consumption for a compute unit over
Mauro Carvalho Chehabb413e3f2019-04-17 06:46:15 -0300111 time period (y-x). Unit of result is uWatt::
112
Huang Ruia6e232f2016-04-06 15:44:14 +0800113 if (Jy < Jx) // Rollover has occurred
114 Jdelta = (Jy + Jmax) - Jx
115 else
116 Jdelta = Jy - Jx
117 PwrCPUave = N * Jdelta * 1000 / (Ty - Tx)
118
119This driver provides PwrCPUave and interval(default is 10 millisecond
120and maximum is 1 second):
Mauro Carvalho Chehabb413e3f2019-04-17 06:46:15 -0300121
Huang Ruia6e232f2016-04-06 15:44:14 +0800122* power1_average (PwrCPUave)
123* power1_average_interval (Interval)
124
125The power1_average_interval can be updated at /etc/sensors3.conf file
126as below:
127
Mauro Carvalho Chehabb413e3f2019-04-17 06:46:15 -0300128chip `fam15h_power-*`
Huang Ruia6e232f2016-04-06 15:44:14 +0800129 set power1_average_interval 0.01
130
131Then save it with "sensors -s".