All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Guenter Roeck" <linux@roeck-us.net>, linux-hwmon@vger.kernel.org
Subject: Re: [PATCH] hwmon: (gpio-fan) Fix runtime PM imbalance in probe and teardown
Date: Thu, 05 Nov 2026 18:29:31 +0000	[thread overview]
Message-ID: <sashiko-outbox-199767@kernel.org> (raw)
In-Reply-To: <20261105182427.2369928-1-linux@roeck-us.net>

> In gpio_fan_probe(), gpio_fan_stop() is registered conditionally as a
> devres action before runtime PM is initialized, while gpio_fan_stop()
> unconditionally calls pm_runtime_disable(). This breaks runtime PM
> disable_depth and usage_count invariants across several paths:
> 
> - On alarm-only devices without control GPIOs, gpio_fan_stop() is never
>   registered, leaving pm_runtime_enable() unbalanced on unbind and
>   triggering "Unbalanced pm_runtime_enable!" on subsequent binds.
> - When control GPIOs are present and devm_add_action_or_reset(), hwmon
>   registration, or fan_alarm_init() fails, gpio_fan_stop() runs before
>   pm_runtime_enable(), incrementing disable_depth to 2 (leaving runtime
>   PM permanently disabled on re-probe) and, if speed_index > 0,
>   underflowing usage_count via pm_runtime_put_sync().
> - If pm_runtime_resume_and_get() fails when speed_index > 0, it drops
>   its reference while speed_index remains non-zero, causing
>   gpio_fan_stop() to call pm_runtime_put_sync() and underflow
>   usage_count.
> - Registering the hwmon device before enabling runtime PM exposes sysfs
>   attributes that can invoke set_fan_speed() before runtime PM state is
>   initialized.
> 
> Initialize runtime PM upfront with pm_runtime_set_suspended() and
> devm_pm_runtime_enable(), remove pm_runtime_disable() from
> gpio_fan_stop(), and acquire the initial active runtime PM reference
> before registering gpio_fan_stop() and the hwmon device.
> 
> Fixes: 0d01110e6356 ("hwmon: (gpio-fan) Add regulator support")
> Reported-by: Sashiko <sashiko@sashiko.dev>
> Link: https://sashiko.dev/#/bug/linux-349aa3ba-30c3-4c3c-b47e-f52839af2b8d
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261105182427.2369928-1-linux@roeck-us.net?part=1


      reply	other threads:[~2026-11-05 18:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-05 18:24 [PATCH] hwmon: (gpio-fan) Fix runtime PM imbalance in probe and teardown Guenter Roeck
2026-11-05 18:29 ` sashiko-bot [this message]

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=sashiko-outbox-199767@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.