Skip to content

Commit b968279

Browse files
nchatradgroeck
authored andcommitted
hwmon: (amd_energy) Add documentation
Document amd_energy driver with energy sensors supported by it. Cc: Guenter Roeck <[email protected]> Signed-off-by: Naveen Krishna Chatradhi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
1 parent 8abee95 commit b968279

File tree

2 files changed

+110
-0
lines changed

2 files changed

+110
-0
lines changed

Documentation/hwmon/amd_energy.rst

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
Kernel driver amd_energy
4+
==========================
5+
6+
Supported chips:
7+
8+
* AMD Family 17h Processors
9+
10+
Prefix: 'amd_energy'
11+
12+
Addresses used: RAPL MSRs
13+
14+
Datasheets:
15+
16+
- Processor Programming Reference (PPR) for AMD Family 17h Model 01h, Revision B1 Processors
17+
18+
https://developer.amd.com/wp-content/resources/55570-B1_PUB.zip
19+
20+
- Preliminary Processor Programming Reference (PPR) for AMD Family 17h Model 31h, Revision B0 Processors
21+
22+
https://developer.amd.com/wp-content/resources/56176_ppr_Family_17h_Model_71h_B0_pub_Rev_3.06.zip
23+
24+
Author: Naveen Krishna Chatradhi <[email protected]>
25+
26+
Description
27+
-----------
28+
29+
The Energy driver exposes the energy counters that are
30+
reported via the Running Average Power Limit (RAPL)
31+
Model-specific Registers (MSRs) via the hardware monitor
32+
(HWMON) sysfs interface.
33+
34+
1. Power, Energy and Time Units
35+
MSR_RAPL_POWER_UNIT/ C001_0299:
36+
shared with all cores in the socket
37+
38+
2. Energy consumed by each Core
39+
MSR_CORE_ENERGY_STATUS/ C001_029A:
40+
32-bitRO, Accumulator, core-level power reporting
41+
42+
3. Energy consumed by Socket
43+
MSR_PACKAGE_ENERGY_STATUS/ C001_029B:
44+
32-bitRO, Accumulator, socket-level power reporting,
45+
shared with all cores in socket
46+
47+
These registers are updated every 1ms and cleared on
48+
reset of the system.
49+
50+
Note: If SMT is enabled, Linux enumerates all threads as cpus.
51+
Since, the energy status registers are accessed at core level,
52+
reading those registers from the sibling threads would result
53+
in duplicate values. Hence, energy counter entries are not
54+
populated for the siblings.
55+
56+
Energy Caluclation
57+
------------------
58+
59+
Energy information (in Joules) is based on the multiplier,
60+
1/2^ESU; where ESU is an unsigned integer read from
61+
MSR_RAPL_POWER_UNIT register. Default value is 10000b,
62+
indicating energy status unit is 15.3 micro-Joules increment.
63+
64+
Reported values are scaled as per the formula
65+
66+
scaled value = ((1/2^ESU) * (Raw value) * 1000000UL) in uJoules
67+
68+
Users calculate power for a given domain by calculating
69+
dEnergy/dTime for that domain.
70+
71+
Energy accumulation
72+
--------------------------
73+
74+
Current, Socket energy status register is 32bit, assuming a 240W
75+
2P system, the register would wrap around in
76+
77+
2^32*15.3 e-6/240 * 2 = 547.60833024 secs to wrap(~9 mins)
78+
79+
The Core energy register may wrap around after several days.
80+
81+
To improve the wrap around time, a kernel thread is implemented
82+
to accumulate the socket energy counters and one core energy counter
83+
per run to a respective 64-bit counter. The kernel thread starts
84+
running during probe, wakes up every 100secs and stops running
85+
when driver is removed.
86+
87+
A socket and core energy read would return the current register
88+
value added to the respective energy accumulator.
89+
90+
Sysfs attributes
91+
----------------
92+
93+
=============== ======== =====================================
94+
Attribute Label Description
95+
=============== ======== =====================================
96+
97+
* For index N between [1] and [nr_cpus]
98+
99+
=============== ======== ======================================
100+
energy[N]_input EcoreX Core Energy X = [0] to [nr_cpus - 1]
101+
Measured input core energy
102+
=============== ======== ======================================
103+
104+
* For N between [nr_cpus] and [nr_cpus + nr_socks]
105+
106+
=============== ======== ======================================
107+
energy[N]_input EsocketX Socket Energy X = [0] to [nr_socks -1]
108+
Measured input socket energy
109+
=============== ======== ======================================

Documentation/hwmon/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Hardware Monitoring Kernel Drivers
3939
adt7470
4040
adt7475
4141
amc6821
42+
amd_energy
4243
asb100
4344
asc7621
4445
aspeed-pwm-tacho

0 commit comments

Comments
 (0)