Linux Hardware Monitor development
 help / color / mirror / Atom feed
* [PATCH 0/3] hwmon: (acpi_power_meter) Fix locking and unknown value handling
@ 2026-10-31 16:54 Guenter Roeck
  2026-10-31 16:54 ` [PATCH 1/3] hwmon: (acpi_power_meter) Fix missing locking in sysfs show callbacks and resume Guenter Roeck
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Guenter Roeck @ 2026-10-31 16:54 UTC (permalink / raw)
  To: linux-hwmon

Sashiko identified a number of issues in the acpi_power_meter driver.
I used gemini-3-carbon to analyze the bug reports and to implement fixes.
Subsequently, I used Sashiko again to review the fixes. This series is the
result of this effort.

This series fixes locking races and incomplete handling of ACPI unknown
sentinel values in the acpi_power_meter hwmon driver:

1. Fix missing locking in sysfs show callbacks and system resume.
   acpi_power_meter_resume() frees and reallocates capability strings
   without holding resource->lock, racing with concurrent
   METER_NOTIFY_CONFIG notifications (and sysfs readers when the freezer
   is disabled). In addition, the extra sysfs show callbacks read
   capability strings, capability integers, and 64-bit trip points
   without acquiring res->lock, exposing torn or uncommitted trip values
   when racing with set_trip(). Acquire resource->lock in resume and in
   all extra sysfs show callbacks, and return -ENODATA if a capability
   string pointer is NULL.

2. Prevent spurious power alarms when power is unknown.
   When _PMM returns an unknown sentinel (U32_MAX or U64_MAX),
   update_meter() stores it in resource->power and returns 0, causing
   get_power_alarm_state() to evaluate resource->power > resource->cap
   as true and report a false alarm. Convert get_power_alarm_state() to
   return a boolean alarm state so reading power1_alarm never returns an
   error code, preserve and clear any latched METER_NOTIFY_CAPPING
   notification when notifications are supported, and otherwise report 0
   (no alarm) when readings fail or power is unknown.

3. Check for both 32-bit and 64-bit unknown ACPI values across attributes.
   ACPI Power Meter objects report unknown or unavailable integer values
   as all-ones (U32_MAX or U64_MAX depending on DSDT revision), but most
   attributes in the driver either only checked 32-bit 0xffffffff or did
   not check for unknown sentinels at all. Introduce
   acpi_power_meter_is_unknown() and use it to return -ENODATA for
   unknown non-alarm numeric hwmon attributes, emit "unknown" in
   power1_cap_hyst_show() and power1_accuracy_show(), avoid comparing
   against an unknown cap in get_power_alarm_state(), and skip jiffies
   caching in update_meter() when sampling_time is unknown.

----------------------------------------------------------------
Guenter Roeck (3):
      hwmon: (acpi_power_meter) Fix missing locking in sysfs show callbacks and resume
      hwmon: (acpi_power_meter) Prevent spurious power alarm when power is unknown
      hwmon: (acpi_power_meter) Check for 32-bit and 64-bit unknown ACPI values

 drivers/hwmon/acpi_power_meter.c | 101 ++++++++++++++++++++++++++++-----------
 1 file changed, 74 insertions(+), 27 deletions(-)

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-10-31 17:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-31 16:54 [PATCH 0/3] hwmon: (acpi_power_meter) Fix locking and unknown value handling Guenter Roeck
2026-10-31 16:54 ` [PATCH 1/3] hwmon: (acpi_power_meter) Fix missing locking in sysfs show callbacks and resume Guenter Roeck
2026-10-31 16:58   ` sashiko-bot
2026-10-31 16:54 ` [PATCH 2/3] hwmon: (acpi_power_meter) Prevent spurious power alarm when power is unknown Guenter Roeck
2026-10-31 17:02   ` sashiko-bot
2026-10-31 16:54 ` [PATCH 3/3] hwmon: (acpi_power_meter) Check for 32-bit and 64-bit unknown ACPI values Guenter Roeck
2026-10-31 17:02   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox