From: Kwanghoon Son <asdfkwang@gmail.com>
To: sashiko-reviews@lists.linux.dev
Cc: ojeda@kernel.org, gary@garyguo.net, rust-for-linux@vger.kernel.org
Subject: Re: [PATCH] rust: io: mem: Fix exclusive MMIO region requests
Date: Thu, 29 Oct 2026 22:11:24 -0400 [thread overview]
Message-ID: <auP8zJwRmAdnpZO3@debian> (raw)
In-Reply-To: <sashiko-outbox-187333@kernel.org>
On Wed, Oct 28, 2026 at 02:12:54AM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
> - [Low] rust: io: dead_code warning in Resource::iomem() when CONFIG_HAS_IOMEM=n
> - [Low] rust: io: missing #[inline] annotation on Resource::iomem()
> --
>
> commit 87df13a505aabe5d12ec487bcf72bfc859780ac8
> Author: Kwanghoon Son <asdfkwang@gmail.com>
>
> rust: io: mem: Fix exclusive MMIO region requests
>
> This commit updates ExclusiveIoMem::ioremap() to request the MMIO region
> from the global iomem_resource root via a new Resource::iomem() helper
> rather than from the device's own resource.
>
> > diff --git a/rust/kernel/io/resource.rs b/rust/kernel/io/resource.rs
> > index 758ce62b3cce3..c99a2530186fc 100644
> > --- a/rust/kernel/io/resource.rs
> > +++ b/rust/kernel/io/resource.rs
> > @@ -79,6 +79,12 @@ unsafe impl Sync for Region {}
> > pub struct Resource(Opaque<bindings::resource>);
> >
> > impl Resource {
> > + /// Returns the global I/O memory resource root.
> > + pub(crate) fn iomem() -> &'static Self {
> > + // SAFETY: iomem_resource is permanent; C serializes resource-tree updates.
> > + unsafe { Self::from_raw(&raw mut bindings::iomem_resource) }
> > + }
>
> [Severity: Low]
> Will Resource::iomem() in rust/kernel/io/resource.rs trigger a dead_code
> warning (or a build failure with CONFIG_WERROR=y) when CONFIG_RUST=y and
> CONFIG_HAS_IOMEM=n (for example, on ARCH=um or s390 without CONFIG_PCI)?
>
> In rust/kernel/io.rs, the mem module is gated on CONFIG_HAS_IOMEM while the
> resource module is compiled unconditionally:
>
> #[cfg(CONFIG_HAS_IOMEM)]
> pub mod mem;
> pub mod poll;
> pub mod register;
> pub mod resource;
>
> Since the only caller of pub(crate) fn iomem() is ExclusiveIoMem::ioremap() in
> rust/kernel/io/mem.rs, should Resource::iomem() also be annotated with
> #[cfg(CONFIG_HAS_IOMEM)] (or made pub)?
I reproduced the dead_code warning.
I'll add #[cfg(CONFIG_HAS_IOMEM)] in v2, matching the condition on its only caller.
>
> [Severity: Low]
> This isn't a bug, but should Resource::iomem() in rust/kernel/io/resource.rs
> also have an #[inline] attribute, matching the other small helper functions in
> the kernel crate abstractions?
I'd prefer to follow those and leave it without the attribute, unless
there is a specific reason to add it here.
I'll wait more reviews on this and send send v2!
Best regards,
Kwang.
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20261027-b4-rust-iomem-origin-master-fix-v1-1-16215ae197af@gmail.com?part=1
prev parent reply other threads:[~2026-10-30 2:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 2:00 [PATCH] rust: io: mem: Fix exclusive MMIO region requests Kwanghoon Son
[not found] ` <sashiko-outbox-187333@kernel.org>
2026-10-30 2:11 ` Kwanghoon Son [this message]
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=auP8zJwRmAdnpZO3@debian \
--to=asdfkwang@gmail.com \
--cc=gary@garyguo.net \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox