From: Johan Hovold <johan@kernel.org>
To: Jonathan Cameron <jic23@kernel.org>
Cc: "Guangshuo Li" <lgs201920130244@gmail.com>,
"Andreas Klinger" <ak@it-klinger.de>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: proximity: srf04: fix runtime PM autosuspend cleanup
Date: Mon, 24 Aug 2026 14:32:20 +0200 [thread overview]
Message-ID: <aow51Nk-cet9qaUQ@hovoldconsulting.com> (raw)
In-Reply-To: <20260822010809.04404b4e@jic23-huawei>
On Sat, Aug 22, 2026 at 01:08:09AM +0100, Jonathan Cameron wrote:
> On Tue, 18 Aug 2026 09:14:15 +0200
> Johan Hovold <johan@kernel.org> wrote:
>
> > On Fri, Aug 07, 2026 at 10:19:37PM +0800, Guangshuo Li wrote:
> > > srf04_probe() calls pm_runtime_use_autosuspend() when the optional
> > > power GPIO is present, but srf04_remove() does not call the matching
> > > pm_runtime_dont_use_autosuspend() before disabling runtime PM.
> > >
> > > The runtime PM documentation requires pm_runtime_use_autosuspend() to
> > > be balanced with pm_runtime_dont_use_autosuspend() when the driver is
> > > removed. Failing to do so can leave the autosuspend usage state
> > > unbalanced and may result in a usage_count leak when the autosuspend
> > > delay is negative.
> >
> > I believe the term "leak" here is misleading as the usage count would be
> > dropped again when the user re-enables autosuspend through sysfs, right?
>
> A user has no reason to do that under normal circumstances.
This issue only arises when a (privileged) user *does* exactly that in
order to disable autosuspend by writing a negative timeout value through
sysfs. And the reference then taken is dropped when the user later
undoes the operation through sysfs.
So there is no usage count leak here.
> So whilst that might work it is rather non user friendly to the extent
> I think I'd consider it a bug that should be fixed. Backport or not
> is a different question.
What is leaking is the autosuspend setting, but the implication of that
is generally not even noticeable. Remember that this only happens when
root unbinds a driver. And in almost every case, it is the same driver
that will later be rebound.
I guess you can try to come up with a situation where a different driver
is later bound which does not use autosuspend, but here we are very much
in hypothetical corner-of-a-corner-case territory which is not relevant
for stable.
> > That said, drivers should clean up after themselves so disabling
> > autosuspend is still the right to do. But it's more of a cleanup than a
> > fix (and does not need to be backported).
Johan
prev parent reply other threads:[~2026-08-24 12:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-07 14:19 [PATCH] iio: proximity: srf04: fix runtime PM autosuspend cleanup Guangshuo Li
2026-08-07 15:02 ` Joshua Crofts
2026-08-18 7:07 ` Johan Hovold
2026-08-07 23:41 ` Jonathan Cameron
2026-08-18 7:14 ` Johan Hovold
2026-08-22 0:08 ` Jonathan Cameron
2026-08-24 12:32 ` Johan Hovold [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=aow51Nk-cet9qaUQ@hovoldconsulting.com \
--to=johan@kernel.org \
--cc=ak@it-klinger.de \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=lgs201920130244@gmail.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
/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