hwmon: Add amd_energy driver to report energy counters
Subsystems (2)
PATCH v3 1/3 hwmon: Add amd_energy driver to report energy counters
This patch adds hwmon based amd_energy driver support for family 17h processors from AMD.
The driver provides following interface to the userspace
1. Reports the per core consumption
* file: "energy%d_input", label: "Ecore%03d"
2. Reports per socket energy consumption
* file: "energy%d_input", label: "Esocket%d"
2. Reports scaled energy value in Joules.
---
Changes in v3: None
drivers/hwmon/Kconfig | 10 ++ drivers/hwmon/Makefile | 1 + drivers/hwmon/amd_energy.c | 251 +++++++++++++++++++++++++++++++++++++ 3 files changed, 262 insertions(+) create mode 100644 drivers/hwmon/amd_energy.c
drivers/hwmon/Kconfig +10 -0
@@ -324,6 +324,16 @@ config SENSORS_FAM15H_POWER This driver can also be built as a module. If so, the module will be called fam15h_power. +config SENSORS_AMD_ENERGY + tristate "AMD RAPL MSR based Energy driver" + depends on X86 + help + If you say yes here you get support for core and package energy + sensors, based on RAPL MSR for AMD family 17h and above CPUs. + + This driver can also be built as a module. If so, the module + will be called as amd_energy. + config SENSORS_APPLESMC tristate "Apple SMC (Motion sensor, light sensor, keyboard backlight)" depends on INPUT && X86
drivers/hwmon/Makefile +1 -0
@@ -45,6 +45,7 @@ obj-$(CONFIG_SENSORS_ADT7411) += adt7411.o obj-$(CONFIG_SENSORS_ADT7462) += adt7462.o obj-$(CONFIG_SENSORS_ADT7470) += adt7470.o obj-$(CONFIG_SENSORS_ADT7475) += adt7475.o +obj-$(CONFIG_SENSORS_AMD_ENERGY) += amd_energy.o obj-$(CONFIG_SENSORS_APPLESMC) += applesmc.o obj-$(CONFIG_SENSORS_ARM_SCMI) += scmi-hwmon.o obj-$(CONFIG_SENSORS_ARM_SCPI) += scpi-hwmon.o
drivers/hwmon/amd_energy.c new file +251 -0
251 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v3 2/3 hwmon: (amd_energy) Add documentation
Document amd_energy driver with all chips supported by it.
---
Changes in v3: Added SPDX license tag
Documentation/hwmon/amd_energy.rst | 84 ++++++++++++++++++++++++++++++ Documentation/hwmon/index.rst | 1 + 2 files changed, 85 insertions(+) create mode 100644 Documentation/hwmon/amd_energy.rst
Documentation/hwmon/amd_energy.rst new file +84 -0
@@ -0,0 +1,84 @@ +.. SPDX-License-Identifier: GPL-2.0 + +Kernel driver amd_energy +========================== + +Supported chips: + +* AMD Family 17h Processors + + Prefix: 'amd_energy' + + Addresses used: RAPL MSRs + + Datasheets: + + - Processor Programming Reference (PPR) for AMD Family 17h Model 01h, Revision B1 Processors + + https://developer.amd.com/wp-content/resources/55570-B1_PUB.zip + + - Preliminary Processor Programming Reference (PPR) for AMD Family 17h Model 31h, Revision B0 Processors + + https://developer.amd.com/wp-content/resources/56176_ppr_Family_17h_Model_71h_B0_pub_Rev_3.06.zip + +Author: Naveen Krishna Chatradhi <[email protected]> + +Description +----------- + +The Energy driver exposes the energy counters that are +reported via the Running Average Power Limit (RAPL) +Model-specific Registers (MSRs) via the hardware monitor +(HWMON) sysfs interface. + +1. Power, Energy and Time Units + MSR_RAPL_POWER_UNIT/ C001_0299: + shared with all cores in the socket + +2. Energy consumed by each Core + MSR_CORE_ENERGY_STATUS/ C001_029A: + 32-bitRO, Accumulator, core-level power reporting + +3. Energy consumed by Socket + MSR_PACKAGE_ENERGY_STATUS/ C001_029B: + 32-bitRO, Accumulator, socket-level power reporting, + shared with all cores in socket + +These registers are updated every 1ms and cleared on +reset of the system. + +Energy Caluclation +------------------ + +Energy information (in Joules) is based on the multiplier, +1/2^ESU; where ESU is an unsigned integer read from +MSR_RAPL_POWER_UNIT register. Default value is 10000b, +indicating energy status unit is 15.3 micro-Joules increment. + +Reported values are scaled as per the formula + +scaled value = ((1/2^ESU) * (Raw value) * 1000000UL) in Joules + +Users calculate power for a given domain by calculating + dEnergy/dTime for that domain. + +Sysfs attributes +---------------- + +=============== ======== ===================================== +Attribute Label Description +=============== ======== ===================================== + +* For index N between [1] and [nr_cpus] + +=============== ======== ====================================== +energy[N]_input EcoreX Core Energy X = [0] to [nr_cpus - 1] + Measured input core energy +=============== ======== ====================================== + +* For N between [nr_cpus] and [nr_cpus + nr_socks] + +=============== ======== ====================================== +energy[N]_input EsocketX Socket Energy X = [0] to [nr_socks -1] + Measured input socket energy +=============== ======== ======================================
Documentation/hwmon/index.rst +1 -0
@@ -39,6 +39,7 @@ Hardware Monitoring Kernel Drivers adt7470 adt7475 amc6821 + amd_energy asb100 asc7621 aspeed-pwm-tacho
Signature · 1 line
2.17.1
PATCH v3 3/3 MAINTAINERS: add entry for AMD energy driver
In reply to Naveen Krishna ChatradhiThe kernel driver is part of HWMON subsystem.
---
Changes in v3: Update MAINTAINERS
MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
@@ -842,6 +842,13 @@ S: Supported T: git git://people.freedesktop.org/~agd5f/linux F: drivers/gpu/drm/amd/display/ +AMD ENERGY DRIVER +M: Naveen Krishna Chatradhi <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/hwmon/amd_energy.rst +F: drivers/hwmon/amd_energy.c + AMD FAM15H PROCESSOR POWER MONITORING DRIVER M: Huang Rui <[email protected]> L: [email protected]
Signature · 1 line
2.17.1
Guenter Roeck
maintainerQuoted 10 lines · Naveen Krishna Chatradhi
This patch adds hwmon based
amd_energydriver support for family 17h processors from AMD.The driver provides following interface to the userspace
1. Reports the per core consumption
* file: "energy%d_input", label: "Ecore%03d"
2. Reports per socket energy consumption
* file: "energy%d_input", label: "Esocket%d"
2. Reports scaled energy value in Joules.
Quoted 2 lines
Cc Guenter Roeck <[email protected]>Signed-off-by Naveen Krishna Chatradhi <[email protected]>
That was too fast. I just finished reviewing v2.
Guenter