summaryrefslogtreecommitdiff
path: root/tools/perf/scripts/python
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2026-10-31 09:22:24 -0700
committerGuenter Roeck <linux@roeck-us.net>2026-11-03 09:40:35 -0800
commitfe23bad2156f1d5f0df8ae4a79ee590b79efc13a (patch)
treee352bb0bff2c0bf38cf9f457d4fef176ca1289fb /tools/perf/scripts/python
parent847ec34ec2ad5a317f1aa254781dded9e7b5faa9 (diff)
hwmon: (acpi_power_meter) Check for 32-bit and 64-bit unknown ACPI values
According to the ACPI specification (Section 10.4), ACPI Power Meter objects (_PMC capability fields, _PMM, _GHL, _PAI) report unknown or unavailable integer values using an integer with all bits set, which can be either U32_MAX (0xffffffff) or U64_MAX (0xffffffffffffffff) depending on the DSDT revision. Currently, only hwmon_power_average checks both 32-bit and 64-bit unknown sentinels: - power1_cap_hyst_show() only compares res->caps.hysteresis against the 32-bit UNKNOWN_HYSTERESIS (0xffffffff), so a 64-bit U64_MAX sentinel bypasses the check, overflows when multiplied by 1000, and emits a bogus number instead of "unknown". - power1_accuracy_show() does not check for unknown sentinels at all, formatting 0xffffffff as "4294967.295%". - power_meter_read() does not check min_avg_interval, max_avg_interval, avg_interval, min_cap, max_cap, or cap for unknown sentinels, exposing scaled or overflowed values (or negative values when cast to signed long) to userspace instead of returning -ENODATA. - get_power_alarm_state() does not check whether resource->cap is unknown before comparing resource->power > resource->cap. - update_meter() passes an unknown caps.sampling_time directly to msecs_to_jiffies(), caching sensor readings for weeks on 64-bit builds. Introduce acpi_power_meter_is_unknown() to check for both U32_MAX and U64_MAX, and use it across sysfs attribute handlers and meter updates: - Return -ENODATA in power_meter_read() when numeric power, interval, or cap attributes report an unknown value. - Emit "unknown" in power1_cap_hyst_show() and power1_accuracy_show() when hysteresis or accuracy is unknown. - Avoid comparing against an unknown cap in get_power_alarm_state(), returning 0 (no alarm, no error) unless a hardware capping notification was latched. - Skip the sampling_time cache window in update_meter() when sampling_time is unknown. Reported-by: Sashiko <sashiko-bot@kernel.org> Fixes: de584afa5e18 ("hwmon driver for ACPI 4.0 power meters") Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'tools/perf/scripts/python')
0 files changed, 0 insertions, 0 deletions