Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: linux-hwmon@vger.kernel.org
Subject: [PATCH 0/3] hwmon: (acpi_power_meter) Fix locking and unknown value handling
Date: Sat, 31 Oct 2026 09:54:44 -0700	[thread overview]
Message-ID: <20261031165447.1771473-1-linux@roeck-us.net> (raw)

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(-)

             reply	other threads:[~2026-10-31 16:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-31 16:54 Guenter Roeck [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261031165447.1771473-1-linux@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=linux-hwmon@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox