From: "Danilo Krummrich" <dakr@kernel.org>
To: "Beata Michalska" <beata.michalska@arm.com>
Cc: <ojeda@kernel.org>, <gregkh@linuxfoundation.org>,
<rafael@kernel.org>, <aliceryhl@google.com>, <boqun@kernel.org>,
<gary@garyguo.net>, <bjorn3_gh@protonmail.com>,
<lossin@kernel.org>, <a.hindborg@kernel.org>, <tmgross@umich.edu>,
<daniel.almeida@collabora.com>, <boris.brezillon@collabora.com>,
<work@onurozkan.dev>, <samitolvanen@google.com>,
<acourbot@nvidia.com>, <rust-for-linux@vger.kernel.org>,
<driver-core@lists.linux.dev>, <linux-kernel@vger.kernel.org>,
<linux-pm@vger.kernel.org>
Subject: Re: [PATCH v5 1/3] rust: add runtime PM support
Date: Wed, 11 Nov 2026 23:45:23 +0100 [thread overview]
Message-ID: <DMSQVECFDJK0.2G5WLV9WPQN3M@kernel.org> (raw)
In-Reply-To: <avTT5VuspuFKbnBv@arm.com>
On Wed Nov 11, 2026 at 9:45 PM CET, Beata Michalska wrote:
> On Thu, Nov 05, 2026 at 05:47:28PM +0100, Danilo Krummrich wrote:
>> On Mon Oct 26, 2026 at 1:05 PM CET, Beata Michalska wrote:
>> > +#[vtable]
>> > +pub trait PMOps: Sized {
>> > + /// The bus adapter that installs the generated PM ops.
>> > + type Adapter: driver::DriverLayout + 'static;
>> > +
>> > + /// Type of the bound bus device passed to runtime PM callbacks.
>> > + type DeviceType: AsBusDevice<device::Bound>;
>> > +
>> > + /// Type of the payload moved through runtime PM transitions.
>> > + type RuntimePayloadType: Send + 'static;
>>
>> I got back to this type after writing the below, because at first I thought this
>> is purely the data type that is cycled through suspend() and resume().
>>
>> However, reading further this is currently the Registration's private data. This
>> won't work. The Registration's private data must not require 'static as we need
>> device resources in this data.
>>
>> So, there should be at least two separate types:
>>
>> (1) The private data of pm::Registration.
>>
>> (2) An object that is created and returned by suspend() and passed by value to
>> resume(), so it can store e.g. reverse guard types (see below).
>>
>> This should also get us rid of the PMPayload magic.
>>
> The `'static' lifetime is definitely a shortsighted idea on my side.
> Splitting the data does seem reasonable, though I'm not sure how that would allow
> us to get rid of moving around the `PMPayload`, as this is what I assume you
> are referring to by 'magic'. The pm framework still needs to keep the callback
> data between the transitions. Also I am not convinced the pm should distinguish
> between suspend and resume data - my thinking was it should be handled by the
> driver. We just need 'an' object to move back and forth.
For data that does outlive all the suspend/resume cycles (i.e. data that lives
as long as the pm::Registration), it should go into pm::Ops::RegistrationData.
For Tyr this would e.g. be:
let runtime_payload = TyrPmRegistrationData {
clks: Clocks {
core: core_clk,
stacks: stacks_clk,
coregroup: coregroup_clk,
},
_regulators: Regulators {
_mali: mali_regulator,
_sram: sram_regulator,
},
};
pm::Ops::SuspendData and pm::Ops::ResumeData (if needed) should only live
throughout suspend and resume, so they can carry e.g. reverse guard types such
as pci::DeviceDisableGuard, which should only live during a a suspend (it can't
live in resume data for obvious reasons, so a single type is not sufficient).
If we have both, pm::Ops::SuspendData and pm::Ops::ResumeData, nothing prevents
drivers to make those types share fields or even be identical, so you can still
cycle things around. Although I don't really see what would be the use case of
that.
I assume that my below function signature caused some confusion, because I
messed it up. What I actually meant is:
fn runtime_resume<'a>(
dev: &Self::DeviceType,
reg_data: Self::RegistrationData<'>,
suspended: Self::SuspendData<'a>,
) -> Result<(), (Self::SuspendData<'a>, Error)>;
>> > +
>> > + /// Runtime resume callback.
>>
>> It would be good to expand this doc-comment explaining the semantics of
>> RuntimePayloadType.
>>
>> > + fn runtime_resume<'a>(
>> > + _dev: &'a Self::DeviceType,
>> > + _payload: Self::RuntimePayloadType,
>> > + ) -> PMCallbackResult<Self::RuntimePayloadType> {
>> > + build_error!(VTABLE_DEFAULT_ERROR)
>> > + }
>> > +
>> > + /// Runtime suspend callback.
>> > + fn runtime_suspend<'a>(
>> > + _dev: &'a Self::DeviceType,
>> > + _payload: Self::RuntimePayloadType,
>> > + ) -> PMCallbackResult<Self::RuntimePayloadType> {
>> > + build_error!(VTABLE_DEFAULT_ERROR)
>> > + }
>>
>> I think for Tyr it so far is sufficient to have a single RuntimePayloadType that
>> keeps cycling through the callbacks, but there will be use-cases where the types
>> differ.
>>
>> For instance, for a PCI driver you will have DeviceDisableGuard stored in
>> suspend() and then you'll want to drop it in resume() so the device gets enabled
>> again.
>>
>> We should also avoid requiring 'static, as reverse guards will borrow the
>> regular guard, e.g. pci::DeviceDisableGuard will borrow from
>> pci::DeviceEnableGuard.
>>
>> For runtime_resume() I think of something like:
>>
>> fn runtime_resume<'a>(
>> dev: &Self::DeviceType,
>> suspended: Self::SuspendData<'a>,
>> ) -> Result<(), (Self::SuspendData<'a>, Error)>;
>>
next prev parent reply other threads:[~2026-11-11 22:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-26 12:05 Request::put_noidleFrom 43bd77ceaa3d6a9f61ae8074be13824a94fa76c1 Mon Sep 17 00:00:00 2001 Beata Michalska
2026-10-26 12:05 ` [PATCH v5 1/3] rust: add runtime PM support Beata Michalska
2026-11-05 5:16 ` Onur Özkan
2026-11-11 20:03 ` Beata Michalska
2026-11-05 16:47 ` Danilo Krummrich
2026-11-11 20:45 ` Beata Michalska
2026-11-11 22:45 ` Danilo Krummrich [this message]
2026-10-26 12:05 ` [PATCH v5 2/3] rust: platform: wire runtime PM callbacks Beata Michalska
2026-10-26 12:05 ` [PATCH v5 3/3 DO NOT MERGE] drm/tyr: enable runtime PM Beata Michalska
2026-10-26 12:15 ` Request::put_noidleFrom 43bd77ceaa3d6a9f61ae8074be13824a94fa76c1 Mon Sep 17 00:00:00 2001 Greg KH
2026-10-26 12:28 ` Beata Michalska
2026-10-26 12:25 ` [PATCH v5 0/3] Rust: add runtime PM support Beata Michalska
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=DMSQVECFDJK0.2G5WLV9WPQN3M@kernel.org \
--to=dakr@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=beata.michalska@arm.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=boris.brezillon@collabora.com \
--cc=daniel.almeida@collabora.com \
--cc=driver-core@lists.linux.dev \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=samitolvanen@google.com \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.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.