From: Brian Norris <briannorris@chromium.org>
To: "Rafael J. Wysocki (Intel)" <rafael@kernel.org>
Cc: linux-doc@vger.kernel.org, linux-pm@vger.kernel.org,
linux-kernel@vger.kernel.org,
Doug Anderson <dianders@chromium.org>,
Ulf Hansson <ulfh@kernel.org>
Subject: Re: [PATCH v4 2/2] PM: runtime: Add Example Driver Patterns section
Date: Fri, 16 Oct 2026 17:34:42 -0700 [thread overview]
Message-ID: <atLCom0YznHV8U6D@google.com> (raw)
In-Reply-To: <CAJZ5v0gNQqffxcdzWff=z3hi0BXzJBOV6WKgf6RXuOydzQJQMw@mail.gmail.com>
Hi Rafael,
On Fri, Oct 16, 2026 at 08:05:12PM +0200, Rafael J. Wysocki (Intel) wrote:
> On Fri, Oct 16, 2026 at 7:42 PM Rafael J. Wysocki (Intel)
> <rafael@kernel.org> wrote:
> > On Thu, Oct 15, 2026 at 10:55 PM Brian Norris <briannorris@chromium.org> wrote:
> > > On Thu, Oct 15, 2026 at 10:11:04PM +0200, Rafael J. Wysocki (Intel) wrote:
> > > > On Wed, Oct 14, 2026 at 10:15 PM Brian Norris <briannorris@chromium.org> wrote:
> > > > > On Wed, Oct 14, 2026 at 09:07:54PM +0200, Rafael J. Wysocki (Intel) wrote:
> > > > > > On Thu, Oct 1, 2026 at 5:51 PM Brian Norris <briannorris@chromium.org> wrote:
> > > > > > >
>
> [cut]
[ Thanks for the earlier clarification about PM domain. It helps me
understand where you're coming from. ]
> > > I kinda think the point of most of this power domain architecture is
> > > that a typical driver just doesn't have to worry about it at all (in
> > > probe(), and if you use runtime PM properly), so I'd prefer not
> > > mentioning it in the Basic example. But sure.
> >
> > Well, your basic example needs to be put in a certain context because
> > it may not be generally applicable everywhere.
> >
> > I think that you should make it clear what the driver's expectations
> > regarding the physical state of the device at the probe time are and
> > the general rule is that it is better to leave the device in the same
> > state in which it is expected to be found next time.
Ack, will do to the best of my ability.
> To be somewhat more precise, if the driver expects to find the device
> completely off and the runtime PM callbacks are set up to make it
> operational, runtime PM can be used to power it up in probe:
>
> /* Assume the runtime PM status to be "suspended". */
> pm_runtime_enable(dev);
> pm_runtime_get_sync(dev);
>
> but then in remove or on probe errors the "power off" state needs to
> be restored manually:
>
> pm_runtime_disable(dev);
> /* Allow the parent and suppliers (if any) to suspend. */
> pm_runtime_set_suspended(dev);
> device_specific_power_off(dev);
That's ... precisely the second example, "Probe with Hardware Powered
Off". It's couched more in my non-ACPI background, but it's the same.
And it mostly avoids pseudocode, so it should be a bit more clear than
the "Basic Probe" we've been talking about.
But there, I still propose that the main distinction is about what work
needs done in the driver in question. The PM domain is still mostly
irrelevant to the driver writer, except perhaps in the language I use
about "on", "off", "operational", etc. And yes, sometimes that means the
work needed to "become operational" is minimal/empty; but that seems
like an obvious reduction from "do what's needed to power on" (nothing)
and "undo what you did on the way up" (nothing).
> However, if the driver expects to find the device operational (for
> example, because it assumes the ACPI PM domain to be there), it may
> just update the runtime PM status before enabling runtime PM:
>
> /* Assume the runtime PM status to be "suspended". */
> pm_runtime_set_active(dev);
> pm_runtime_enable(dev);
>
> but then in remove or on probe errors it may just leave the device in
> its current physical state (whatever it is) and assume somebody else
> to take care of turning it off subsequently:
>
> pm_runtime_disable(dev);
> /* Allow the parent and suppliers (if any) to suspend. */
> pm_runtime_set_suspended(dev);
>
> These are two distinct cases that are rather hard to cover in one
> simple example.
To me, this case is barely different than my existing "Basic Probe"
case, except that the "/* Power on and initialize hardware registers... */"
(or "foo_initialize()") is empty, and so the setup and teardown becomes
smaller.
So I still think my first 2 example cases are perfectly sufficient to
cover what you're talking about. I can just improve a bit of the
language and clarity w.r.t. the things you've mentioned. For example, I
can clarify that the driver might need to power on resources or itself,
or the PM domain might have done that for you -- regardless, one needs
to tear down what they set up (which is nothing but the
pm_runtime_set_[status](), in some cases).
Brian
next prev parent reply other threads:[~2026-10-17 0:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-01 15:50 [PATCH v4 0/2] PM: runtime: Overhaul kerneldoc, runtime_pm.rst docs Brian Norris
2026-10-01 15:50 ` [PATCH v4 1/2] PM: runtime: Expand introduction with core concepts and structure Brian Norris
2026-10-14 19:00 ` Rafael J. Wysocki (Intel)
2026-10-01 15:50 ` [PATCH v4 2/2] PM: runtime: Add Example Driver Patterns section Brian Norris
2026-10-14 19:07 ` Rafael J. Wysocki (Intel)
2026-10-14 20:15 ` Brian Norris
2026-10-15 20:11 ` Rafael J. Wysocki (Intel)
2026-10-15 20:55 ` Brian Norris
2026-10-16 17:42 ` Rafael J. Wysocki (Intel)
2026-10-16 18:05 ` Rafael J. Wysocki (Intel)
2026-10-16 18:11 ` Rafael J. Wysocki (Intel)
2026-10-17 0:34 ` Brian Norris [this message]
2026-10-17 0:34 ` Brian Norris
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=atLCom0YznHV8U6D@google.com \
--to=briannorris@chromium.org \
--cc=dianders@chromium.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=ulfh@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