hwmon driver for ACPI 4.0 power meters
Subsystems (3)
PATCH 6/8 hwmon driver for ACPI 4.0 power meters
From: "Darrick J. Wong" <[email protected]>
This driver exposes ACPI 4.0 compliant power meters as hardware monitoring devices. This second revision of the driver also exports the ACPI string info as sysfs attributes, a list of the devices that the meter measures, and will send ACPI notifications over the ACPI netlink socket. This latest revision only enables the power capping controls if it can be confirmed that the power cap can be enforced by the hardware and explains how the notification interfaces work.
---
Documentation/hwmon/acpi_power_meter | 51 + drivers/acpi/Kconfig | 11 drivers/acpi/Makefile | 1 drivers/acpi/power_meter.c | 1018 +++++++++++++++++++++++++ 4 files changed, 1081 insertions(+)
Documentation/hwmon/acpi_power_meter new file +51 -0
@@ -0,0 +1,51 @@ +Kernel driver power_meter +========================= + +This driver talks to ACPI 4.0 power meters. + +Supported systems: + * Any recent system with ACPI 4.0. + Prefix: 'power_meter' + Datasheet: http://acpi.info/, section 10.4. + +Author: Darrick J. Wong + +Description +----------- + +This driver implements sensor reading support for the power meters exposed in +the ACPI 4.0 spec (Chapter 10.4). These devices have a simple set of +features--a power meter that returns average power use over a configurable +interval, an optional capping mechanism, and a couple of trip points. The +sysfs interface conforms with the specification outlined in the "Power" section +of Documentation/hwmon/sysfs-interface. + +Special Features +---------------- + +The power[1-*]_is_battery knob indicates if the power supply is a battery. +Both power[1-*]_average_{min,max} must be set before the trip points will work. +When both of them are set, an ACPI event will be broadcast on the ACPI netlink +socket and a poll notification will be sent to the appropriate +power[1-*]_average sysfs file. + +The power[1-*]_{model_number, serial_number, oem_info} fields display arbitrary +strings that ACPI provides with the meter. The measures/ directory contains +symlinks to the devices that this meter measures. + +Some computers have the ability to enforce a power cap in hardware. If this is +the case, the power[1-*]_cap and related sysfs files will appear. When the +average power consumption exceeds the cap, an ACPI event will be broadcast on +the netlink event socket and a poll notification will be sent to the +appropriate power[1-*]_alarm file to indicate that capping has begun, and the +hardware has taken action to reduce power consumption. Most likely this will +result in reduced performance. + +There are a few other ACPI notifications that can be sent by the firmware. In +all cases the ACPI event will be broadcast on the ACPI netlink event socket as +well as sent as a poll notification to a sysfs file. The events are as +follows: + +power[1-*]_cap will be notified if the firmware changes the power cap. +power[1-*]_interval will be notified if the firmware changes the averaging +interval.
drivers/acpi/Kconfig renamed from drivers/acpi/Kconfig~hwmon-driver-for-acpi-40-power-meters +11 -0
@@ -86,6 +86,17 @@ config ACPI_PROCFS_POWER Say N to delete power /proc/acpi/ directories that have moved to /sys/ +config ACPI_POWER_METER + tristate "ACPI 4.0 power meter" + depends on HWMON + help + This driver exposes ACPI 4.0 power meters as hardware monitoring + devices. Say Y (or M) if you have a computer with ACPI 4.0 firmware + and a power meter. + + To compile this driver as a module, choose M here: + the module will be called power-meter. + config ACPI_SYSFS_POWER bool "Future power /sys interface" select POWER_SUPPLY
drivers/acpi/Makefile renamed from drivers/acpi/Makefile~hwmon-driver-for-acpi-40-power-meters +1 -0
@@ -56,6 +56,7 @@ obj-$(CONFIG_ACPI_HOTPLUG_MEMORY) += acp obj-$(CONFIG_ACPI_BATTERY) += battery.o obj-$(CONFIG_ACPI_SBS) += sbshc.o obj-$(CONFIG_ACPI_SBS) += sbs.o +obj-$(CONFIG_ACPI_POWER_METER) += power_meter.o # processor has its own "processor." module_param namespace processor-y := processor_core.o processor_throttling.o
drivers/acpi/power_meter.c new file +1018 -0
1,018 lines not on this page · raw message
_
Quoted 10 lines · On Fri, Sep 18, 2009 at 12:41:09PM -0700, [email protected] wrote:
From: "Darrick J. Wong" <[email protected]>
This driver exposes ACPI 4.0 compliant power meters as hardware monitoring devices. This second revision of the driver also exports the ACPI string info as sysfs attributes, a list of the devices that the meter measures, and will send ACPI notifications over the ACPI netlink socket. This latest revision only enables the power capping controls if it can be confirmed that the power cap can be enforced by the hardware and explains how the notification interfaces work.
Quoted 2 lines
[[email protected]: remove default-y]
[[email protected]: build fix]
Looks good to me.
(Ack'ing my own patch?)
--D
applied.
Even though there is no way right now to test if we got this right, I'm told that we'll see support for this feature in platforms soon, so in the spirit of "release early and often", I think this driver should go upstream now.
thanks,
Len Brown, Intel Open Source Technology Center
Quoted 7 lines · On Fri, Sep 18, 2009 at 12:41:09PM -0700, [email protected] wrote:
This driver exposes ACPI 4.0 compliant power meters as hardware monitoring devices. This second revision of the driver also exports the ACPI string info as sysfs attributes, a list of the devices that the meter measures, and will send ACPI notifications over the ACPI netlink socket. This latest revision only enables the power capping controls if it can be confirmed that the power cap can be enforced by the hardware and explains how the notification interfaces work.
I know I'm a bit late on this, but what do you mean by "it can be confirmed that the power cap can be enforced by the hardware"? Isn't that what bit 2 of the capabilities list means?
Signature · 1 line
Matthew Garrett | [email protected]
Quoted 10 lines · Matthew Garrett
Quoted 7 lines · On Fri, Sep 18, 2009 at 12:41:09PM -0700, [email protected] wrote:
This driver exposes ACPI 4.0 compliant power meters as hardware monitoring devices. This second revision of the driver also exports the ACPI string info as sysfs attributes, a list of the devices that the meter measures, and will send ACPI notifications over the ACPI netlink socket. This latest revision only enables the power capping controls if it can be confirmed that the power cap can be enforced by the hardware and explains how the notification interfaces work.
Quoted 3 lines
I know I'm a bit late on this, but what do you mean by "it can be confirmed that the power cap can be enforced by the hardware"? Isn't that what bit 2 of the capabilities list means?
As I recall, Pavel had an objection that it wasn't clear to him that ACPI advertising a capping ability necessarily meant that the platform hardware would actually _enforce_ that cap, so I put in a DMI hook so that the cap only appears on systems where ACPI advertises the ability /and/ someone can verify that it's enforced outside software (either by patching the DMI table or by supplying a module parameter).
I guess we were afraid that someone would build an ACPI power meter and then require software to read the cap out of ACPI and enforce it(??) though I can't find a link to that discussion. I'll just attach it below, since the marc.info archive of mm-commits doesn't seem to have caught it.
--D
Quoted 18 lines · Darrick J. Wong
Quoted 10 lines · Pavel Machek
Hi!
Review
Quoted 4 lines
(quoted diff) +4
-0+power[1-*]_cap If power use rises above this limit, the + system should take action to reduce power use. + A poll notification is sent to this file if the + cap is changed by the hardware.This one needs better documentation, I'd say. Who should take action? What action? What happens if this is ignored? Hardware can change it; does that mean we now have mandatory new daemon watching this?
Hmm, well, I was hoping the note for power*_alarm would suffice, but I guess I could explicitly state that non-specific Bad Things may happen to the computer if software ignores overpower situations. From what I've seen of hardware-based monitor/cap systems, however, the hardware will usually take action if it doesn't observe the software making changes.
Quoted 3 lines
Of course, if the hw can manage everything, then no daemon's necessary. If it doesn't, then one most probably is required. Unfortunately that leaves us with "Contact your vendor to find out". Not terribly satisfying. :(
Not satisfying, right. Is it possible to remove that feature from current patches until the situation is clear?
Requiring a daemon for safe operation of the system would be huge step back...
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 6 lines · Darrick J. Wong
Quoted 4 lines · Pavel Machek
Quoted 3 lines
Of course, if the hw can manage everything, then no daemon's necessary. If it doesn't, then one most probably is required. Unfortunately that leaves us with "Contact your vendor to find out". Not terribly satisfying. :(
Quoted 6 lines
Quoted 2 lines
Not satisfying, right. Is it possible to remove that feature from current patches until the situation is clear?
Which feature, specifically? Everything related to the cap, or just the notification? I doubt that we'll ever be able to clarify this question for all
Everything related to the cap.
Quoted 5 lines
systems other than to implement a whitelist or something. Perhaps it would not be so bad to have a "
power1_cap_enforcer" file that tells you if the cap is done in hw, if it's expected that the OS must do capping, or if the kernel simply has no idea. But I've observed resistance to whitelists in the kernel, so I'm not sure that would fly.
Well, user<->kernel interface that we do not understand is bad idea, too. whitelist would be preferable to _that_.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 11 lines · Darrick J. Wong
As I recall, Pavel had an objection that it wasn't clear to him that ACPI advertising a capping ability necessarily meant that the platform hardware would actually _enforce_ that cap, so I put in a DMI hook so that the cap only appears on systems where ACPI advertises the ability /and/ someone can verify that it's enforced outside software (either by patching the DMI table or by supplying a module parameter).
I guess we were afraid that someone would build an ACPI power meter and then require software to read the cap out of ACPI and enforce it(??) though I can't find a link to that discussion. I'll just attach it below, since the marc.info archive of mm-commits doesn't seem to have caught it.
The spec defines bit 2 of the capabilities list as "Power meter supports hardware enforced limit" - I don't think we're meant to worry about the OS here.
Signature · 1 line
Matthew Garrett | [email protected]