From: "Danilo Krummrich" <dakr@kernel.org>
To: "Lorenzo Delgado" <lnsdev@proton.me>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Trevor Gross" <tmgross@umich.edu>,
"Tamir Duberstein" <tamird@kernel.org>,
"Onur Özkan" <work@onurozkan.dev>,
"Abdiel Janulgue" <abdiel.janulgue@gmail.com>,
"Robin Murphy" <robin.murphy@arm.com>,
"John Hubbard" <jhubbard@nvidia.com>,
"Timur Tabi" <ttabi@nvidia.com>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
driver-core@lists.linux.dev, dri-devel@lists.freedesktop.org,
nova-gpu@lists.linux.dev
Subject: Re: [PATCH] rust: io: convert ResourceSize into a transparent newtype
Date: Sun, 19 Jul 2026 16:53:02 +0200 [thread overview]
Message-ID: <DK2MT37NYCTQ.3JCJ9EAQ9TJEE@kernel.org> (raw)
In-Reply-To: <20260719104012.364283-1-lnsdev@proton.me>
On Sun Jul 19, 2026 at 12:40 PM CEST, Lorenzo Delgado wrote:
> I tried that, but it doesn't build. ResourceSize wraps resource_size_t,
> which is u64 on 64-bit (CONFIG_PHYS_ADDR_T_64BIT), so the impl the patch
> already has,
>
> impl From<ResourceSize> for bindings::resource_size_t
>
> is already From<ResourceSize> for u64 there, and a second one conflicts:
>
> error[E0119]: conflicting implementations of trait
> `From<ResourceSize>` for type `u64`
Sure, but in the case a cfg-gate is perfectly fine, as the impl will always be
availble. Either through impl for u64 directly or through impl for
bindings::resource_size_t.
> There's a simpler way that stays infallible and adds nothing to io.rs.
> ResourceSize already has into_raw() (io/resource.rs uses it at the C
> boundaries), so nova-core can do:
>
> let num_pages =
> usize::from_safe_cast(sg_entry.dma_len().into_raw()).div_ceil(GSP_PAGE_SIZE);
>
> into_raw() gives back resource_size_t, and from_safe_cast handles that
> as u32 or u64 depending on the config, so it stays infallible. I'll use
> that in v2 unless you'd prefer something else.
I don't want to grow it arbitrarily in nova-core - which is also why I opened
the question of moving FromSafeCast to generic infrastructure again - but in
this case we should rather add the FromSafeCast<ResourceSize> for usize impl in
drivers/gpu/nova-core/num.rs for now and move it subsequently.
next prev parent reply other threads:[~2026-07-19 14:53 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 [this message]
2026-07-19 20:53 ` Gary Guo
2026-07-19 20:09 ` [PATCH v2] " Lorenzo Delgado
2026-07-19 20:17 ` sashiko-bot
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=DK2MT37NYCTQ.3JCJ9EAQ9TJEE@kernel.org \
--to=dakr@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=abdiel.janulgue@gmail.com \
--cc=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=driver-core@lists.linux.dev \
--cc=gary@garyguo.net \
--cc=jhubbard@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lnsdev@proton.me \
--cc=lossin@kernel.org \
--cc=nova-gpu@lists.linux.dev \
--cc=ojeda@kernel.org \
--cc=robin.murphy@arm.com \
--cc=rust-for-linux@vger.kernel.org \
--cc=simona@ffwll.ch \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=ttabi@nvidia.com \
--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.