[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aGV3ce3ZJEOanSMJ@pollux>
Date: Wed, 2 Jul 2025 20:16:17 +0200
From: Danilo Krummrich <dakr@...nel.org>
To: Daniel Almeida <daniel.almeida@...labora.com>
Cc: Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>,
Bjorn Helgaas <bhelgaas@...gle.com>,
Mika Westerberg <mika.westerberg@...ux.intel.com>,
Ying Huang <huang.ying.caritas@...il.com>,
Benno Lossin <lossin@...nel.org>, linux-kernel@...r.kernel.org,
rust-for-linux@...r.kernel.org, Fiona Behrens <me@...enk.dev>
Subject: Re: [PATCH v11 1/4] rust: io: add resource abstraction
On Wed, Jul 02, 2025 at 03:11:04PM -0300, Daniel Almeida wrote:
> Hi Danilo
>
> > On 2 Jul 2025, at 07:21, Danilo Krummrich <dakr@...nel.org> wrote:
> >
> >> +#[cfg(CONFIG_HAS_IOPORT)]
> >> +/// Returns a reference to the global `ioport_resource` variable.
> >> +pub fn ioport_resource() -> &'static Resource {
> >> + // SAFETY: `bindings::ioport_resoure` has global lifetime and is of type Resource.
> >> + unsafe { Resource::as_ref(&raw mut bindings::ioport_resource) }
> >> +}
> >> +
> >> +#[cfg(CONFIG_HAS_IOMEM)]
> >> +/// Returns a reference to the global `iomem_resource` variable.
> >> +pub fn iomem_resource() -> &'static Resource {
> >> + // SAFETY: `bindings::iomem_resoure` has global lifetime and is of type Resource.
> >> + unsafe { Resource::as_ref(&raw mut bindings::iomem_resource) }
> >> +}
> >
> > This caught my attention, and I have a few questions:
> >
> > 1) What do you need them for? I don't see any methods that would usually
> > consume those.
> >
> > 2) Why are they behind CONFIG_HAS_IOPORT and CONFIG_HAS_IOMEM, even though the
> > C instances are not?
> >
> > 3) What happens if we pass them to IoMem::new()? Is this really safe, or do we
> > need them to be a special Resource type?
> >
>
> Good catch, actually.
>
> I worked on this patch with Fiona and IIRC, she needed access to these two for
> her LED abstractions. This patch has seen a few iterations already and this may
> or may not be obsolete by now. I must say I've never used these before so I
> don't really know how they work nor do I need this at all.
They serve as parent / root resource instances, e.g. if you want to create new
resource regions yourself.
> Fiona, do you still need these two accessors?
I'd say let's drop them for now, we can easily add them later on in the context
of an actual user.
Powered by blists - more mailing lists