Alexandre Courbot
2025-Oct-16 06:23 UTC
[PATCH v5 03/14] gpu: nova-core: gsp: Create wpr metadata
On Mon Oct 13, 2025 at 3:20 PM JST, Alistair Popple wrote:> The GSP requires some pieces of metadata to boot. These are passed in a > struct which the GSP transfers via DMA. Create this struct and get a > handle to it for future use when booting the GSP. > > Signed-off-by: Alistair Popple <apopple at nvidia.com> > > --- > > Changes for v5: > - Make member visibility match the struct visibility (thanks Danilo) > > Changes for v3: > - Don't re-export WPR constants (thanks Alex) > > Changes for v2: > - Rebased on Alex's latest version > --- > drivers/gpu/nova-core/fb.rs | 1 - > drivers/gpu/nova-core/firmware/gsp.rs | 3 +- > drivers/gpu/nova-core/firmware/riscv.rs | 6 +- > drivers/gpu/nova-core/gsp.rs | 2 + > drivers/gpu/nova-core/gsp/boot.rs | 7 +++ > drivers/gpu/nova-core/gsp/fw.rs | 55 ++++++++++++++++++- > .../gpu/nova-core/gsp/fw/r570_144/bindings.rs | 2 + > 7 files changed, 69 insertions(+), 7 deletions(-) > > diff --git a/drivers/gpu/nova-core/fb.rs b/drivers/gpu/nova-core/fb.rs > index 4d6a1f452183..5580498ba2fb 100644 > --- a/drivers/gpu/nova-core/fb.rs > +++ b/drivers/gpu/nova-core/fb.rs > @@ -87,7 +87,6 @@ pub(crate) fn unregister(&self, bar: &Bar0) { > /// > /// Contains ranges of GPU memory reserved for a given purpose during the GSP boot process. > #[derive(Debug)] > -#[expect(dead_code)] > pub(crate) struct FbLayout { > /// Range of the framebuffer. Starts at `0`. > pub(crate) fb: Range<u64>, > diff --git a/drivers/gpu/nova-core/firmware/gsp.rs b/drivers/gpu/nova-core/firmware/gsp.rs > index 3a1cf0607de7..c9ad912a3150 100644 > --- a/drivers/gpu/nova-core/firmware/gsp.rs > +++ b/drivers/gpu/nova-core/firmware/gsp.rs > @@ -131,7 +131,7 @@ pub(crate) struct GspFirmware { > /// Size in bytes of the firmware contained in [`Self::fw`]. > pub size: usize, > /// Device-mapped GSP signatures matching the GPU's [`Chipset`]. > - signatures: DmaObject, > + pub signatures: DmaObject,This needs to be `pub(crate)` or rustc 1.78 emits a warning (I'll also have to fix the surrounding ones in my own patch). <snip>> +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.
Alistair Popple
2025-Oct-16 23:03 UTC
[PATCH v5 03/14] gpu: nova-core: gsp: Create wpr metadata
On 2025-10-16 at 17:23 +1100, Alexandre Courbot <acourbot at nvidia.com> wrote...> On Mon Oct 13, 2025 at 3:20 PM JST, Alistair Popple wrote: > > The GSP requires some pieces of metadata to boot. These are passed in a > > struct which the GSP transfers via DMA. Create this struct and get a > > handle to it for future use when booting the GSP. > > > > Signed-off-by: Alistair Popple <apopple at nvidia.com> > > > > --- > > > > Changes for v5: > > - Make member visibility match the struct visibility (thanks Danilo) > > > > Changes for v3: > > - Don't re-export WPR constants (thanks Alex) > > > > Changes for v2: > > - Rebased on Alex's latest version > > --- > > drivers/gpu/nova-core/fb.rs | 1 - > > drivers/gpu/nova-core/firmware/gsp.rs | 3 +- > > drivers/gpu/nova-core/firmware/riscv.rs | 6 +- > > drivers/gpu/nova-core/gsp.rs | 2 + > > drivers/gpu/nova-core/gsp/boot.rs | 7 +++ > > drivers/gpu/nova-core/gsp/fw.rs | 55 ++++++++++++++++++- > > .../gpu/nova-core/gsp/fw/r570_144/bindings.rs | 2 + > > 7 files changed, 69 insertions(+), 7 deletions(-) > > > > diff --git a/drivers/gpu/nova-core/fb.rs b/drivers/gpu/nova-core/fb.rs > > index 4d6a1f452183..5580498ba2fb 100644 > > --- a/drivers/gpu/nova-core/fb.rs > > +++ b/drivers/gpu/nova-core/fb.rs > > @@ -87,7 +87,6 @@ pub(crate) fn unregister(&self, bar: &Bar0) { > > /// > > /// Contains ranges of GPU memory reserved for a given purpose during the GSP boot process. > > #[derive(Debug)] > > -#[expect(dead_code)] > > pub(crate) struct FbLayout { > > /// Range of the framebuffer. Starts at `0`. > > pub(crate) fb: Range<u64>, > > diff --git a/drivers/gpu/nova-core/firmware/gsp.rs b/drivers/gpu/nova-core/firmware/gsp.rs > > index 3a1cf0607de7..c9ad912a3150 100644 > > --- a/drivers/gpu/nova-core/firmware/gsp.rs > > +++ b/drivers/gpu/nova-core/firmware/gsp.rs > > @@ -131,7 +131,7 @@ pub(crate) struct GspFirmware { > > /// Size in bytes of the firmware contained in [`Self::fw`]. > > pub size: usize, > > /// Device-mapped GSP signatures matching the GPU's [`Chipset`]. > > - signatures: DmaObject, > > + pub signatures: DmaObject, > > This needs to be `pub(crate)` or rustc 1.78 emits a warning (I'll also > have to fix the surrounding ones in my own patch).Thanks, missed that one.> <snip> > > +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?