All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Lorenzo Delgado" <lnsdev@proton.me>
Cc: "Alexandre Courbot" <acourbot@nvidia.com>,
	ojeda@kernel.org, dri-devel@lists.freedesktop.org,
	"Danilo Krummrich" <dakr@kernel.org>
Subject: Re: [PATCH v2] rust: io: convert ResourceSize into a transparent newtype
Date: Sun, 19 Jul 2026 20:17:03 +0000	[thread overview]
Message-ID: <20260719201704.06DD11F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260719200945.687904-1-lnsdev@proton.me>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Incomplete API Implementation: PCI FFI boundary methods continue to return raw `bindings::resource_size_t` instead of the typed `ResourceSize` API.
- [Low] Incorrect import order for `core::num::TryFromIntError` violating kernel guidelines.
--

--- Patch [1]: [PATCH v2] rust: io: convert ResourceSize into a transparent newtype ---
commit b81b66fe76cbe9487443105d289e399a714dd21d
Author: Lorenzo Delgado <lnsdev@proton.me>

rust: io: convert ResourceSize into a transparent newtype

This patch wraps ResourceSize in a #[repr(transparent)] newtype to prevent
unintended integer operations and truncating casts. It provides explicit
boundary conversions and updates existing producers and consumers to use the
new typed API.

Link: https://github.com/Rust-for-Linux/linux/issues/1203

> Wrap it in a `#[repr(transparent)]` newtype so each conversion at a
> boundary becomes explicit and reviewable. The representation is
> unchanged, so this is ABI-identical; only the spelling at the FFI
> boundary changes. Provide the conversion surface `from_raw`/`into_raw`,
> `From` in both directions, and a fallible `TryFrom<ResourceSize> for
> usize` for checked narrowing. Update the two producers, `Resource::size`
> and `SGEntry::dma_len`, and the `request_region` consumer. In nova-core,

[Severity: Medium]
Does this miss other producers in the FFI boundary?

Looking at rust/kernel/pci.rs, both resource_start() and resource_len()
continue to return the raw bindings::resource_size_t type rather than the
new ResourceSize type.

Should these functions also be updated to return the new ResourceSize
type to ensure the API remains consistent and fully protected against
implicit casts across the subsystem?

> diff --git a/rust/kernel/io.rs b/rust/kernel/io.rs
> index fcc7678fd9e3c..ebf00b4536d6d 100644
> --- a/rust/kernel/io.rs
> +++ b/rust/kernel/io.rs
> @@ -6,9 +6,12 @@
>  
>  use crate::{
>      bindings,
> +    fmt,
>      prelude::*, //
>  };
>  
> +use core::num::TryFromIntError;

[Severity: Low]
This isn't a bug, but should the core import be placed before the crate
imports?

The kernel's Rust coding guidelines typically require vertical imports
where core and alloc are grouped together and placed before kernel (or crate)
imports.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260719200945.687904-1-lnsdev@proton.me?part=1

      reply	other threads:[~2026-07-19 20:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-12 11:36 [PATCH] rust: io: convert ResourceSize into a transparent newtype Lorenzo Delgado
2026-07-16 21:45 ` Danilo Krummrich
2026-07-19 10:40   ` Lorenzo Delgado
2026-07-19 14:53     ` Danilo Krummrich
2026-07-19 20:53       ` Gary Guo
2026-07-19 20:09 ` [PATCH v2] " Lorenzo Delgado
2026-07-19 20:17   ` sashiko-bot [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=20260719201704.06DD11F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=dakr@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=lnsdev@proton.me \
    --cc=ojeda@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 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.