Re: [PATCH v2 1/3] rust: add runtime PM support
Beata Michalska <[email protected]> Tue, 4 Aug 2026 14:27:55 +0200
| Newsgroups | org.kernel.vger.rust-for-linux,dev.linux.lists.driver-core,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pm |
|---|---|
| Message-ID | <[email protected]> |
On Tue, Aug 04, 2026 at 08:06:07AM +0000, Alice Ryhl wrote:
> On Tue, Jul 21, 2026 at 05:34:02PM +0200, Beata Michalska wrote:
> > diff --git a/rust/helpers/pm_runtime.c b/rust/helpers/pm_runtime.c
> > new file mode 100644
> > index 000000000000..d0d71fcb0097
> > --- /dev/null
> > +++ b/rust/helpers/pm_runtime.c
> > @@ -0,0 +1,44 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +
> > +#include <linux/pm_runtime.h>
> > +
> > +__rust_helper void rust_helper_pm_runtime_get_noresume(struct device *dev)
> > +{
> > + pm_runtime_get_noresume(dev);
> > +}
> > +
> > +__rust_helper void rust_helper_pm_runtime_put_noidle(struct device *dev)
> > +{
> > + pm_runtime_put_noidle(dev);
> > +}
>
> Should this file be wrapped in `#ifdef !CONFIG_PM` or similar?
It kinda is (should be) on the C side of things.
Though I can wrap it in another layer of ifdef.
>
> > +/// Runtime Power Management modes that determine how a particular PM
> > +/// transition is to be carried out.
> > +/// Corresponds to C Runtime PM flag argument bits:
> > +/// - `RPM_ASYNC`
> > +/// - `RPM_NOWAIT`
> > +/// - `RPM_GET_PUT`
> > +/// - `RPM_AUTO`
> > +#[derive(Clone, Copy, PartialEq, Eq, Debug)]
> > +struct Mode(u32);
>
> Nit: we have a macro for bit flags.
>
> See for example:
> https://lore.kernel.org/rust-for-linux/[email protected]/
Will migrate it to that macro then.
>
> > +#[cfg(CONFIG_PM)]
> > +impl Request {
> > + ...
> > +}
> > +
> > +#[cfg(not(CONFIG_PM))]
> > +impl Request {
> > + ...
> > +}
>
> Doesn't your rust/helpers file already handle these for you? The methods
> exist as stubs in the C header on not(CONFIG_PM), I think?
Some, yes, but not all.
---
BR
Beata
>
> Alice