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 v2 7/7] gpu: nova-core: gsp: add the load-and-execute event dispatcher
Date: Wed, 02 Dec 2026 21:06:39 +0900 [thread overview]
Message-ID: <20261202-falcon-v2-7-33ed73a20796@nvidia.com> (raw)
In-Reply-To: <20261202-falcon-v2-0-33ed73a20796@nvidia.com>
From: John Hubbard <jhubbard@nvidia.com>
The two load-and-execute events of the r000 boot protocol arrive as GMC
events, and the command ID of a GMC event names its kind. Nova-core has
a handler for each of the two events, and no code that selects the
handler from the command ID.
Add a dispatcher that selects the handler from the command ID of a GMC
event, decodes the payload of the event into the parameters of that
handler, and rejects an event with any other command ID.
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: check MAILBOX0 and call `resume_gsp_rm()` here, for both events]
[ecourtney: return EIO without resuming if MAILBOX0 != FLCN_OK]
[ecourtney: move to `GspBootContext::handle_load_exec_event()`]
[ecourtney: drop `bootloader` param, loaded in handler]
Signed-off-by: Eliot Courtney <ecourtney@nvidia.com>
---
drivers/gpu/nova-core/gsp/load_exec.rs | 93 ++++++++++++++++++++++++++++++++--
1 file changed, 90 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/nova-core/gsp/load_exec.rs b/drivers/gpu/nova-core/gsp/load_exec.rs
index 1eab4c00e4d3..a32b13c361ad 100644
--- a/drivers/gpu/nova-core/gsp/load_exec.rs
+++ b/drivers/gpu/nova-core/gsp/load_exec.rs
@@ -40,7 +40,11 @@
GenericBootloader, //
},
gsp::{
- cmdq::gmc::MessageFromGsp,
+ cmdq::gmc::{
+ GmcMessage,
+ MessageFromGsp, //
+ },
+ fw::GmcCommandId,
GspBootContext, //
},
sbuffer::SBufferIter, //
@@ -49,6 +53,9 @@
/// DMEM virtual address value that means "no virtual address assigned".
const FLCN_DMEM_VA_INVALID: u32 = 0xffff_ffff;
+/// `MAILBOX0` value that means a falcon binary succeeded.
+const FLCN_OK: u32 = 0x00;
+
/// `MAILBOX0` value that means that a falcon binary has not started.
///
/// A binary that reports its status through `MAILBOX0` replaces it.
@@ -113,6 +120,88 @@ 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. 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.
+ /// - `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.
+ #[expect(dead_code)]
+ pub(super) fn handle_load_exec_event(
+ &self,
+ 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(¶ms)),
+ ),
+ Ok(id @ GmcCommandId::ExecHsBinary) => (
+ id,
+ 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);
+ }
+ };
+
+ result
+ .and_then(|mbox0| match mbox0 {
+ FLCN_OK => {
+ dev_dbg!(dev, "Binary of load-and-execute event {:?} succeeded\n", id);
+
+ resume_gsp_rm(
+ dev,
+ self.gsp_falcon,
+ self.sec2_falcon,
+ libos_dma_address,
+ bootloader_app_version,
+ )
+ }
+ FLCN_ERR_BINARY_NOT_STARTED => {
+ dev_err!(
+ dev,
+ "Binary of load-and-execute event {:?} did not start\n",
+ id
+ );
+ Err(EIO)
+ }
+ err => {
+ dev_err!(
+ dev,
+ "Binary of load-and-execute event {:?} failed with error {:#x}\n",
+ id,
+ err
+ );
+ Err(EIO)
+ }
+ })
+ .inspect_err(|e| {
+ dev_err!(dev, "Load-and-execute event {:?} failed: {:?}\n", id, e);
+ })
+ }
+
/// Waits until GSP-RM has suspended the RISC-V core, and then resets the GSP
/// falcon.
fn reset_gsp_falcon_after_suspend(&self) -> Result {
@@ -157,7 +246,6 @@ fn reset_gsp_falcon_after_suspend(&self) -> Result {
///
/// Errors from the reset of the GSP falcon and the DMA transfers are
/// propagated as-is.
- #[expect(dead_code)]
fn handle_hs_binary(&self, params: &HsBinaryParams) -> Result<u32> {
let dev = self.dev();
let gsp_falcon = self.gsp_falcon;
@@ -210,7 +298,6 @@ fn handle_hs_binary(&self, params: &HsBinaryParams) -> Result<u32> {
///
/// 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, params: &GenericBootloaderParams) -> Result<u32> {
/// Expected size of the descriptor, in bytes.
const DMEM_DESC_SIZE: u32 = cv!(size_of::<BootloaderDmemDescV2>());
--
2.56.1
prev parent reply other threads:[~2026-12-02 12:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 12:06 [PATCH v2 0/7] gpu: nova-core: gsp: add r000 load+exec handlers Eliot Courtney
2026-12-02 12:06 ` [PATCH v2 1/7] gpu: nova-core: falcon: factor out the wait for the GSP suspend Eliot Courtney
2026-12-02 12:06 ` [PATCH v2 2/7] gpu: nova-core: gsp: factor out the core resume Eliot Courtney
2026-12-02 12:06 ` [PATCH v2 3/7] gpu: nova-core: gsp: fix resume_gsp_rm()'s error messages Eliot Courtney
2026-12-02 12:06 ` [PATCH v2 4/7] gpu: nova-core: falcon: select the BAR2 engine ID for DMA transfers Eliot Courtney
2026-12-02 12:06 ` [PATCH v2 5/7] gpu: nova-core: gsp: add the r000 load-and-execute HS binary handler Eliot Courtney
2026-12-02 12:06 ` [PATCH v2 6/7] gpu: nova-core: gsp: add the r000 load-and-execute bootloader handler Eliot Courtney
2026-12-02 12:06 ` Eliot Courtney [this message]
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=20261202-falcon-v2-7-33ed73a20796@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®