From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Brian Norris <briannorris@chromium.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
Pavel Machek <pavel@kernel.org>,
"Rafael J . Wysocki" <rafael.j.wysocki@intel.com>,
Len Brown <lenb@kernel.org>,
linux-kernel@vger.kernel.org, kunit-dev@googlegroups.com,
linux-pm@vger.kernel.org, Dhruva Gole <d-gole@ti.com>
Subject: Re: [PATCH v2 2/3] PM: runtime: Make put{,_sync}() return 1 when already suspended
Date: Fri, 26 Sep 2025 15:25:30 +0300 [thread overview]
Message-ID: <aNaGOgGm7QRWEJ1m@kekkonen.localdomain> (raw)
In-Reply-To: <20250925124216.v2.2.I2cdc7d58d89da55bfd53d78f81c7e08e4b10eb80@changeid>
Hi Brian,
Thanks for the update.
On Thu, Sep 25, 2025 at 12:42:15PM -0700, Brian Norris wrote:
> The pm_runtime.h docs say pm_runtime_put() and pm_runtime_put_sync()
> return 1 when already suspended, but this is not true -- they return
> -EAGAIN. On the other hand, pm_runtime_put_sync_suspend() and
> pm_runtime_put_sync_autosuspend() *do* return 1.
>
> This is an artifact of the fact that the former are built on rpm_idle(),
> whereas the latter are built on rpm_suspend().
>
> There are precious few pm_runtime_put()/pm_runtime_put_sync() callers
> that check the return code at all, but most of them only log errors, and
> usually only for negative error codes. None of them should be treating
> this as an error, so:
>
> * at best, this may fix some case where a driver treats this condition
> as an error, when it shouldn't;
>
> * at worst, this should make no effect; and
>
> * somewhere in between, we could potentially clear up non-fatal log
> messages.
>
> Fix the pm_runtime_already_suspended_test() while tweaking the behavior.
> The test makes a lot more sense when these all return 1 when the device
> is already suspended:
>
> pm_runtime_put_sync(dev);
> pm_runtime_suspend(dev);
> pm_runtime_autosuspend(dev);
> pm_request_autosuspend(dev);
> pm_runtime_put_sync_autosuspend(dev);
>
> Notably, I've avoided testing the return codes for these, since they
> really should be ignored by callers, and we may make them 'void'
> altogether:
>
> pm_runtime_put(dev);
> pm_runtime_put_autosuspend(dev);
>
> Signed-off-by: Brian Norris <briannorris@chromium.org>
> Reviewed-by: Dhruva Gole <d-gole@ti.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
--
Sakari Ailus
next prev parent reply other threads:[~2025-09-26 12:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-25 19:42 [PATCH v2 1/3] PM: runtime: Add basic kunit tests for API contracts Brian Norris
2025-09-25 19:42 ` [PATCH v2 2/3] PM: runtime: Make put{,_sync}() return 1 when already suspended Brian Norris
2025-09-26 12:25 ` Sakari Ailus [this message]
2025-09-25 19:42 ` [PATCH v2 3/3] PM: runtime: Update kerneldoc return codes Brian Norris
2025-09-26 12:25 ` Sakari Ailus
2025-09-27 11:44 ` [PATCH v2 1/3] PM: runtime: Add basic kunit tests for API contracts Rafael J. Wysocki
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=aNaGOgGm7QRWEJ1m@kekkonen.localdomain \
--to=sakari.ailus@linux.intel.com \
--cc=briannorris@chromium.org \
--cc=d-gole@ti.com \
--cc=kunit-dev@googlegroups.com \
--cc=lenb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=pavel@kernel.org \
--cc=rafael.j.wysocki@intel.com \
--cc=rafael@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