From: Eliot Courtney <ecourtney@nvidia.com>
To: Danilo Krummrich <dakr@kernel.org>,
Alice Ryhl <aliceryhl@google.com>,
Alexandre Courbot <acourbot@nvidia.com>,
David Airlie <airlied@gmail.com>,
Simona Vetter <simona@ffwll.ch>
Cc: John Hubbard <jhubbard@nvidia.com>,
Alistair Popple <apopple@nvidia.com>,
Timur Tabi <ttabi@nvidia.com>, Zhi Wang <zhiw@nvidia.com>,
nova-gpu@lists.linux.dev, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org,
Eliot Courtney <ecourtney@nvidia.com>
Subject: [PATCH 13/14] gpu: nova-core: gsp: add the r000 load-and-execute bootloader handler
Date: Mon, 30 Nov 2026 18:28:37 +0900 [thread overview]
Message-ID: <20261130-falcon-v1-13-cb94f87b5674@nvidia.com> (raw)
In-Reply-To: <20261130-falcon-v1-0-cb94f87b5674@nvidia.com>
From: John Hubbard <jhubbard@nvidia.com>
On Turing and GA100, the r000 GSP-RM requires an image to run on the
falcon core during boot, through the generic falcon bootloader. GSP-RM
is suspended while the image runs.
The driver runs the image on behalf of GSP-RM, in the following steps:
1. GSP-RM raises a load-and-execute event, which carries a descriptor of
the image.
2. GSP-RM suspends the RISC-V core.
3. The driver waits until the RISC-V core is suspended.
4. The driver resets the GSP falcon, which selects the falcon core.
5. The driver loads the bootloader and the descriptor into the GSP
falcon.
6. The driver starts the bootloader, which loads the image and starts
it.
7. The driver waits for the falcon core to halt.
8. The driver resumes GSP-RM on the RISC-V core.
Nova-core has no handler for the bootloader's load-and-execute event.
Add the handler, which performs steps 3 through 8.
Co-developed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
[ecourtney: zerocopy derives for `GenericBootloaderParams`, no `unsafe impl`]
[ecourtney: derive `FromBytes` for `BootloaderDmemDescV2`, no `unsafe impl`]
[ecourtney: move MAILBOX0 check and resume to `handle_load_exec_event()`]
[ecourtney: module doc's FBIF sentence moved to the HS binary patch]
[ecourtney: move some methods to be impls of `GspBootContext`]
Signed-off-by: Eliot Courtney <ecourtney@nvidia.com>
---
drivers/gpu/nova-core/firmware/gen_bootloader.rs | 2 +-
drivers/gpu/nova-core/gsp/load_exec.rs | 140 +++++++++++++++++++++++
2 files changed, 141 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/nova-core/firmware/gen_bootloader.rs b/drivers/gpu/nova-core/firmware/gen_bootloader.rs
index 7e53f287ca2a..b4631cf9e76c 100644
--- a/drivers/gpu/nova-core/firmware/gen_bootloader.rs
+++ b/drivers/gpu/nova-core/firmware/gen_bootloader.rs
@@ -46,7 +46,7 @@
/// This has to be filled by the GPU driver and copied into DMEM at offset
/// [`BootloaderDesc.dmem_load_off`].
#[repr(C, packed)]
-#[derive(Debug, Clone, IntoBytes, Immutable)]
+#[derive(Debug, Clone, FromBytes, IntoBytes, Immutable)]
pub(crate) struct BootloaderDmemDescV2 {
/// Reserved, should always be first element.
reserved: [u32; 4],
diff --git a/drivers/gpu/nova-core/gsp/load_exec.rs b/drivers/gpu/nova-core/gsp/load_exec.rs
index 6d832cb9ec24..4dbb27dc03a1 100644
--- a/drivers/gpu/nova-core/gsp/load_exec.rs
+++ b/drivers/gpu/nova-core/gsp/load_exec.rs
@@ -29,11 +29,16 @@
Falcon,
FalconBromParams,
FalconDmemSegment,
+ FalconFbifTarget,
FalconFirmware,
FalconImage,
FalconImemSegment,
FalconSegmentSource, //
},
+ firmware::gen_bootloader::{
+ BootloaderDmemDescV2,
+ GenericBootloader, //
+ },
gsp::{
cmdq::gmc::MessageFromGsp,
GspBootContext, //
@@ -172,6 +177,88 @@ fn handle_hs_binary(&self, params: &HsBinaryParams) -> Result<u32> {
);
})
}
+
+ /// Runs the image of a `GMCAPI_CMD_EXEC_GENERIC_BOOTLOADER` event on the
+ /// falcon core of the GSP falcon, through the generic falcon bootloader, and
+ /// returns `MAILBOX0` once the image has halted.
+ ///
+ /// `params` holds the descriptor of the image. The generic falcon bootloader
+ /// loads and starts the image that the descriptor names, per
+ /// [`GenericBootloader::run`]. The handler:
+ ///
+ /// 1. Checks that the descriptor in `params` has the size of
+ /// [`BootloaderDmemDescV2`], and gets the FBIF (Framebuffer Interface)
+ /// target that `params` selects.
+ /// 2. Waits until GSP-RM has suspended the RISC-V core, for up to five
+ /// seconds.
+ /// 3. Resets the GSP falcon, which selects the falcon core.
+ /// 4. Runs `bootloader` with the descriptor and with
+ /// [`FLCN_ERR_BINARY_NOT_STARTED`] in `MAILBOX0`, and waits until the
+ /// falcon core halts, for up to two seconds. The image halts the falcon
+ /// core when it is done, so the handler learns from the halt that the
+ /// image has finished.
+ ///
+ /// # Errors
+ ///
+ /// - `EINVAL` if `bootloader` is `None`, if the descriptor size in `params`
+ /// is not the size of [`BootloaderDmemDescV2`], or if the address space and
+ /// the cache attribute in `params` select no FBIF target.
+ /// - `ETIMEDOUT` if GSP-RM has not suspended the RISC-V core within five
+ /// seconds, or if the falcon core has not halted within two seconds of
+ /// its start.
+ ///
+ /// Errors from the reset of the GSP falcon and the run of the bootloader are
+ /// propagated as-is.
+ #[expect(dead_code)]
+ fn handle_generic_bootloader(
+ &self,
+ bootloader: Option<&GenericBootloader>,
+ params: &GenericBootloaderParams,
+ ) -> Result<u32> {
+ /// Expected size of the descriptor, in bytes.
+ const DMEM_DESC_SIZE: u32 = cv!(size_of::<BootloaderDmemDescV2>());
+
+ let dev = self.dev();
+ let gsp_falcon = self.gsp_falcon;
+ let Some(bootloader) = bootloader else {
+ dev_err!(
+ dev,
+ "No generic bootloader for the load-and-execute event\n"
+ );
+ return Err(EINVAL);
+ };
+
+ if params.dmem_desc_size != DMEM_DESC_SIZE {
+ dev_err!(
+ dev,
+ "Generic bootloader descriptor is {} bytes, expected {}\n",
+ params.dmem_desc_size,
+ DMEM_DESC_SIZE
+ );
+ return Err(EINVAL);
+ }
+
+ let fbif_target = params.fbif_target()?;
+
+ self.reset_gsp_falcon_after_suspend()?;
+
+ bootloader
+ .run(
+ gsp_falcon,
+ ¶ms.dmem_desc,
+ fbif_target,
+ FLCN_ERR_BINARY_NOT_STARTED,
+ )
+ .map(|(mbox0, _)| mbox0)
+ .inspect_err(|e| {
+ dev_err!(
+ dev,
+ "Failed to run the generic bootloader: {:?} (mbox0={:#x})\n",
+ e,
+ gsp_falcon.read_mailbox0()
+ );
+ })
+ }
}
/// Payload of a `GMCAPI_CMD_EXEC_HS_BINARY` event, which describes the HS binary to run.
@@ -291,3 +378,56 @@ fn boot_addr(&self) -> u32 {
self.imem.va
}
}
+
+/// Payload of a `GMCAPI_CMD_EXEC_GENERIC_BOOTLOADER` event, which describes the image for the
+/// generic falcon bootloader to run.
+#[repr(C)]
+#[derive(FromBytes, IntoBytes)]
+struct GenericBootloaderParams {
+ /// Descriptor of the image, which the bootloader reads from DMEM.
+ dmem_desc: BootloaderDmemDescV2,
+ /// Size in bytes of the descriptor, as GSP-RM defines it.
+ dmem_desc_size: u32,
+ /// Address space of the image: [`Self::ADDR_SYSMEM`] for system memory, or
+ /// [`Self::ADDR_FBMEM`] for the framebuffer.
+ addr_space: u32,
+ /// CPU cache attribute of an image in system memory: [`Self::NV_MEMORY_CACHED`] or
+ /// [`Self::NV_MEMORY_UNCACHED`].
+ cpu_cache_attrib: u32,
+ _reserved: [u32; 4],
+}
+
+impl GenericBootloaderParams {
+ const ADDR_SYSMEM: u32 = 1;
+ const ADDR_FBMEM: u32 = 2;
+ const NV_MEMORY_CACHED: u32 = 0;
+ const NV_MEMORY_UNCACHED: u32 = 1;
+
+ /// Returns the FBIF target that `addr_space` and `cpu_cache_attrib` select.
+ ///
+ /// # Errors
+ ///
+ /// - `EINVAL` if the pair selects no FBIF target.
+ fn fbif_target(&self) -> Result<FalconFbifTarget> {
+ match (self.addr_space, self.cpu_cache_attrib) {
+ (Self::ADDR_FBMEM, _) => Ok(FalconFbifTarget::LocalFb),
+ (Self::ADDR_SYSMEM, Self::NV_MEMORY_CACHED) => Ok(FalconFbifTarget::CoherentSysmem),
+ (Self::ADDR_SYSMEM, Self::NV_MEMORY_UNCACHED) => {
+ Ok(FalconFbifTarget::NoncoherentSysmem)
+ }
+ _ => Err(EINVAL),
+ }
+ }
+}
+
+impl MessageFromGsp for GenericBootloaderParams {
+ type InitError = Error;
+
+ fn read(payload: &mut SBufferIter<array::IntoIter<&[u8], 2>>) -> Result<Self> {
+ let mut params = Self::new_zeroed();
+
+ payload.read_exact(params.as_mut_bytes())?;
+
+ Ok(params)
+ }
+}
--
2.56.1
next prev parent reply other threads:[~2026-11-30 9:29 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 9:28 [PATCH 00/14] gpu: nova-core: merge `load` and `boot` for falcons, add load+exec handlers Eliot Courtney
2026-11-30 9:28 ` [PATCH 01/14] gpu: nova-core: falcon: program BROM and BOOTVEC in `boot` Eliot Courtney
2026-11-30 9:28 ` [PATCH 02/14] gpu: nova-core: use correct offset for imem in `BooterFirmware` Eliot Courtney
2026-11-30 9:28 ` [PATCH 03/14] gpu: nova-core: remove some dependencies on FalconDmaLoadTarget Eliot Courtney
2026-11-30 9:28 ` [PATCH 04/14] gpu: nova-core: falcon: separate staging data for DMA from its location Eliot Courtney
2026-11-30 9:28 ` [PATCH 05/14] gpu: nova-core: falcon: add `FalconImage` for `FalconFirmware` trait Eliot Courtney
2026-11-30 9:28 ` [PATCH 06/14] gpu: nova-core: falcon: load the firmware image in Falcon::boot Eliot Courtney
2026-11-30 9:28 ` [PATCH 07/14] gpu: nova-core: firmware: use `zerocopy` for `BootloaderDmemDescV2` Eliot Courtney
2026-11-30 9:28 ` [PATCH 08/14] gpu: nova-core: falcon: factor out the wait for the GSP suspend Eliot Courtney
2026-11-30 9:28 ` [PATCH 09/14] gpu: nova-core: gsp: factor out the core resume Eliot Courtney
2026-11-30 9:28 ` [PATCH 10/14] gpu: nova-core: gsp: fix resume_gsp_rm()'s error messages Eliot Courtney
2026-11-30 9:28 ` [PATCH 11/14] gpu: nova-core: falcon: select the BAR2 engine ID for framebuffer DMA Eliot Courtney
2026-11-30 9:28 ` [PATCH 12/14] gpu: nova-core: gsp: add the r000 load-and-execute HS binary handler Eliot Courtney
2026-11-30 9:28 ` Eliot Courtney [this message]
2026-11-30 9:28 ` [PATCH 14/14] gpu: nova-core: gsp: add the load-and-execute event dispatcher Eliot Courtney
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=20261130-falcon-v1-13-cb94f87b5674@nvidia.com \
--to=ecourtney@nvidia.com \
--cc=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=aliceryhl@google.com \
--cc=apopple@nvidia.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jhubbard@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nova-gpu@lists.linux.dev \
--cc=simona@ffwll.ch \
--cc=ttabi@nvidia.com \
--cc=zhiw@nvidia.com \
/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
all inboxes | Powered by JetHome®