Every GMC event received while waiting for the GSP_INIT reply currently goes to the load-and-execute dispatcher, which rejects anything else with EINVAL. An unrelated event thus fails the boot, where OpenRM carries on.
Rename the dispatcher to try_handle_load_exec_event() and return None on unrelated events so boot() logs and ignores them instead. A failing load-and-execute handler remains fatal, as it leaves the GSP halted. Signed-off-by: Alexandre Courbot <[email protected]> --- drivers/gpu/nova-core/gsp/boot.rs | 6 +++++- drivers/gpu/nova-core/gsp/cmdq/gmc.rs | 2 +- drivers/gpu/nova-core/gsp/load_exec.rs | 20 +++++++++----------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/nova-core/gsp/boot.rs b/drivers/gpu/nova-core/gsp/boot.rs index 763dbe1f8fdb..1f5a6682b768 100644 --- a/drivers/gpu/nova-core/gsp/boot.rs +++ b/drivers/gpu/nova-core/gsp/boot.rs @@ -92,7 +92,11 @@ pub(crate) fn boot( let static_info = self .cmdq .send_gmc_command(GspInit::new(pdev, chipset, ctx.vgpu.state())?, |event| { - ctx.handle_load_exec_event(libos_dma_address, bootloader_app_version, event) + ctx.try_handle_load_exec_event(libos_dma_address, bootloader_app_version, event) + .unwrap_or_else(|| { + event.log(dev); + Ok(()) + }) })? .map_err(|status| { dev_err!(dev, "GSP_INIT failed with status {:#x}\n", status); diff --git a/drivers/gpu/nova-core/gsp/cmdq/gmc.rs b/drivers/gpu/nova-core/gsp/cmdq/gmc.rs index 6565a8fb0e96..14ef82db7be7 100644 --- a/drivers/gpu/nova-core/gsp/cmdq/gmc.rs +++ b/drivers/gpu/nova-core/gsp/cmdq/gmc.rs @@ -281,7 +281,7 @@ fn reply_status(&self, command: GmcCommandId, seq: u32) -> Option<u32> { /// /// A reply that nobody claimed (e.g. one that arrived after its request timed out) and an /// unknown command id are logged at warning level. Other events are not logged. - pub(super) fn log(&self, dev: &device::Device) { + pub(crate) fn log(&self, dev: &device::Device) { let command = self.header.command(); let seq = self.header.sequence(); diff --git a/drivers/gpu/nova-core/gsp/load_exec.rs b/drivers/gpu/nova-core/gsp/load_exec.rs index 7d379eb13e02..752259a55059 100644 --- a/drivers/gpu/nova-core/gsp/load_exec.rs +++ b/drivers/gpu/nova-core/gsp/load_exec.rs @@ -120,7 +120,7 @@ pub(super) fn resume_gsp_rm( } impl GspBootContext<'_, '_> { - /// Runs the handler of the load-and-execute event `event`. + /// Runs the handler of `event` if it is a load-and-execute event, or returns `None` otherwise. /// /// The command ID of `event` selects the handler, and the payload of `event` /// holds the parameters of that handler. Each handler is followed by @@ -129,20 +129,19 @@ impl GspBootContext<'_, '_> { /// /// # 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 + /// - `EINVAL` if the payload of `event` is shorter than the parameters of /// the handler. /// - `EIO` if the binary did not start or reported a non-zero status in /// `MAILBOX0`. /// /// Errors from the handlers and from the resume of GSP-RM are propagated /// as-is. - pub(super) fn handle_load_exec_event( + pub(super) fn try_handle_load_exec_event( &self, libos_dma_address: DmaAddress, bootloader_app_version: u32, event: &GmcMessage<'_>, - ) -> Result { + ) -> Option<Result> { let dev = self.dev(); let command = event.header().command(); let (slice_1, slice_2) = event.payload(); @@ -159,13 +158,10 @@ pub(super) fn handle_load_exec_event( HsBinaryParams::read(&mut payload) .and_then(|params| self.handle_hs_binary(¶ms)), ), - _ => { - dev_err!(dev, "Not a load-and-execute event: {:?}\n", command); - return Err(EINVAL); - } + _ => return None, }; - result + let result = result .and_then(|mbox0| match mbox0 { FLCN_OK => { dev_dbg!(dev, "Binary of load-and-execute event {:?} succeeded\n", id); @@ -198,7 +194,9 @@ pub(super) fn handle_load_exec_event( }) .inspect_err(|e| { dev_err!(dev, "Load-and-execute event {:?} failed: {:?}\n", id, e); - }) + }); + + Some(result) } /// Waits until GSP-RM has suspended the RISC-V core, and then resets the GSP -- 2.56.1
