Re: [PATCH 13/14] gpu: nova-core: gsp: add the r000 load-and-execute bootloader handler

From: Alexandre Courbot

Date: Tue Dec 01 2026 - 10:14:45 EST


On Mon Nov 30, 2026 at 6:28 PM JST, Eliot Courtney wrote:
<...>
> @@ -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);
> + };

It looked a bit sus to me that we have a function handling a generic
bootloader event that can fail because there is no bootloader. And
indeed this method signature cascaded into more complexity down the
r000 switch (notably by introducing [1] and more churn during the
switch).

If GSP-RM (a trusted component) asks us to run a bootloader event, this
means we are capable of running a bootloader and there is no reason to
second-guess it. WDYT of the patch below? It simplifies things a bit,
and these simplifications then cascade into the next patch and the r000
switch.

[1] https://lore.kernel.org/all/20260918010719.1176945-26-jhubbard@xxxxxxxxxx/

diff --git a/drivers/gpu/nova-core/gsp/load_exec.rs b/drivers/gpu/nova-core/gsp/load_exec.rs
index 4dbb27dc03a1..1eab4c00e4d3 100644
--- a/drivers/gpu/nova-core/gsp/load_exec.rs
+++ b/drivers/gpu/nova-core/gsp/load_exec.rs
@@ -189,10 +189,11 @@ fn handle_hs_binary(&self, params: &HsBinaryParams) -> Result<u32> {
/// 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
+ /// 2. Loads the generic falcon bootloader image for the GPU's chipset.
+ /// 3. 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
+ /// 4. Resets the GSP falcon, which selects the falcon core.
+ /// 5. Runs the 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
@@ -200,33 +201,22 @@ fn handle_hs_binary(&self, params: &HsBinaryParams) -> Result<u32> {
///
/// # 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.
+ /// - `EINVAL` 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.
+ /// Errors from loading the bootloader, 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> {
+ fn handle_generic_bootloader(&self, 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!(
@@ -239,6 +229,7 @@ fn handle_generic_bootloader(
}

let fbif_target = params.fbif_target()?;
+ let bootloader = GenericBootloader::new(dev, self.chipset)?;

self.reset_gsp_falcon_after_suspend()?;