[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DDK6IHKS13RS.3UVIM301BBFUP@nvidia.com>
Date: Fri, 17 Oct 2025 09:43:04 +0900
From: "Alexandre Courbot" <acourbot@...dia.com>
To: "Danilo Krummrich" <dakr@...nel.org>, "Alistair Popple"
<apopple@...dia.com>
Cc: "Alexandre Courbot" <acourbot@...dia.com>,
<rust-for-linux@...r.kernel.org>, <dri-devel@...ts.freedesktop.org>,
"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>, "Benno Lossin"
<lossin@...nel.org>, "Andreas Hindborg" <a.hindborg@...nel.org>, "Alice
Ryhl" <aliceryhl@...gle.com>, "Trevor Gross" <tmgross@...ch.edu>, "David
Airlie" <airlied@...il.com>, "Simona Vetter" <simona@...ll.ch>, "Maarten
Lankhorst" <maarten.lankhorst@...ux.intel.com>, "Maxime Ripard"
<mripard@...nel.org>, "Thomas Zimmermann" <tzimmermann@...e.de>, "John
Hubbard" <jhubbard@...dia.com>, "Joel Fernandes" <joelagnelf@...dia.com>,
"Timur Tabi" <ttabi@...dia.com>, <linux-kernel@...r.kernel.org>,
<nouveau@...ts.freedesktop.org>
Subject: Re: [PATCH v5 03/14] gpu: nova-core: gsp: Create wpr metadata
On Fri Oct 17, 2025 at 8:11 AM JST, Danilo Krummrich wrote:
> On Fri Oct 17, 2025 at 1:03 AM CEST, Alistair Popple wrote:
>> On 2025-10-16 at 17:23 +1100, Alexandre Courbot <acourbot@...dia.com> wrote...
>>> On Mon Oct 13, 2025 at 3:20 PM JST, Alistair Popple wrote:
>>> > +impl GspFwWprMeta {
>>> > + pub(crate) fn new(gsp_firmware: &GspFirmware, fb_layout: &FbLayout) -> Self {
>>> > + Self(bindings::GspFwWprMeta {
>>> > + magic: r570_144::GSP_FW_WPR_META_MAGIC as u64,
>>> > + revision: u64::from(r570_144::GSP_FW_WPR_META_REVISION),
>>> > + sysmemAddrOfRadix3Elf: gsp_firmware.radix3_dma_handle(),
>>> > + sizeOfRadix3Elf: gsp_firmware.size as u64,
>>>
>>> Very unfortunately I'm afraid we will need to replace the `as` in this
>>> method with `u64::try_from` and make it return a `Result` for now.
>>
>> And presumably most of the other `as` keywords in this function dealing with
>> usize as well? Have made the change but would you mind quickly explaining
>> why this is needed? Is the concern that usize might be more than 64 bits or
>> something?
Indeed, the concern is that `as` performs a lossy conversion without
warning, which could catch us off-guard if e.g. some type changes in the
bindings.
>
> Since nova-core depends on CONFIG_64BIT, I think we want a helper function that
> converts usize to u64 infallibly.
>
> This helper function can simply generate a compile time error, when
> !CONFIG_64BIT, etc.
>
> We can do this locally in nova-core, but it could also find it's place in the
> generic infrastructure. nova-core clearly won't be the last driver running into
> this inconvinience.
That would definitely be the correct way to address this.
Powered by blists - more mailing lists