Re: [PATCH 14/14] gpu: nova-core: gsp: add the load-and-execute event dispatcher

From: Alexandre Courbot

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


On Mon Nov 30, 2026 at 6:28 PM JST, Eliot Courtney wrote:
<...>
> @@ -113,6 +117,82 @@ pub(super) fn resume_gsp_rm(
> }
>
> impl GspBootContext<'_, '_> {
> + /// Runs the handler of the load-and-execute event `event`.
> + ///
> + /// The command ID of `event` selects the handler, and the payload of `event`
> + /// holds the parameters of that handler. `bootloader` is the generic falcon
> + /// bootloader, which the handler of a `GMCAPI_CMD_EXEC_GENERIC_BOOTLOADER`
> + /// event requires. Each handler is followed by [`resume_gsp_rm`], which
> + /// receives `libos_dma_address` and `bootloader_app_version`.
> + ///
> + /// # Errors
> + ///
> + /// - `EINVAL` if the command ID of `event` is not that of a load-and-execute
> + /// event, or if the payload of `event` is shorter than the parameters of
> + /// the handler.
> + ///
> + /// Errors from the handlers and from the resume of GSP-RM are propagated
> + /// as-is.
> + #[expect(dead_code)]
> + pub(super) fn handle_load_exec_event(
> + &self,
> + bootloader: Option<&GenericBootloader>,

Same as the previous patch, we shouldn't need this - please check the
proposed patch below.

> + libos_dma_address: DmaAddress,
> + bootloader_app_version: u32,
> + event: &GmcMessage<'_>,
> + ) -> Result {
> + let dev = self.dev();
> + let command = event.header().command();
> + let (slice_1, slice_2) = event.payload();
> + let mut payload = SBufferIter::new_reader([slice_1, slice_2]);
> +
> + let (id, result) = match command.id() {
> + Ok(id @ GmcCommandId::ExecGenericBootloader) => (
> + id,
> + GenericBootloaderParams::read(&mut payload)
> + .and_then(|params| self.handle_generic_bootloader(bootloader, &params)),
> + ),
> + Ok(id @ GmcCommandId::ExecHsBinary) => (
> + id,
> + HsBinaryParams::read(&mut payload)
> + .and_then(|params| self.handle_hs_binary(&params)),
> + ),
> + _ => {
> + dev_err!(dev, "Not a load-and-execute event: {:?}\n", command);
> + return Err(EINVAL);
> + }
> + };
> +
> + result
> + .and_then(|mbox0| {
> + if mbox0 == FLCN_ERR_BINARY_NOT_STARTED {
> + dev_err!(
> + dev,
> + "Binary of load-and-execute event {:?} did not start\n",
> + id
> + );

Shouldn't we return an error if the binary hasn't been started at all?

I'd suggest to apply this, then the r000 switch series can be simplified
some more.

diff --git a/drivers/gpu/nova-core/gsp/load_exec.rs b/drivers/gpu/nova-core/gsp/load_exec.rs
index 374e851d2b60..1ecf4e4dd5e3 100644
--- a/drivers/gpu/nova-core/gsp/load_exec.rs
+++ b/drivers/gpu/nova-core/gsp/load_exec.rs
@@ -120,10 +120,9 @@ impl GspBootContext<'_, '_> {
/// Runs the handler of the load-and-execute event `event`.
///
/// The command ID of `event` selects the handler, and the payload of `event`
- /// holds the parameters of that handler. `bootloader` is the generic falcon
- /// bootloader, which the handler of a `GMCAPI_CMD_EXEC_GENERIC_BOOTLOADER`
- /// event requires. Each handler is followed by [`resume_gsp_rm`], which
- /// receives `libos_dma_address` and `bootloader_app_version`.
+ /// holds the parameters of that handler. Each handler is followed by
+ /// [`resume_gsp_rm`], which receives `libos_dma_address` and
+ /// `bootloader_app_version`.
///
/// # Errors
///
@@ -136,7 +135,6 @@ impl GspBootContext<'_, '_> {
#[expect(dead_code)]
pub(super) fn handle_load_exec_event(
&self,
- bootloader: Option<&GenericBootloader>,
libos_dma_address: DmaAddress,
bootloader_app_version: u32,
event: &GmcMessage<'_>,
@@ -150,7 +148,7 @@ pub(super) fn handle_load_exec_event(
Ok(id @ GmcCommandId::ExecGenericBootloader) => (
id,
GenericBootloaderParams::read(&mut payload)
- .and_then(|params| self.handle_generic_bootloader(bootloader, &params)),
+ .and_then(|params| self.handle_generic_bootloader(&params)),
),
Ok(id @ GmcCommandId::ExecHsBinary) => (
id,