* [PATCH v2 0/7] gpu: nova-core: gsp: add r000 load+exec handlers
@ 2026-12-02 12:06 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
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Eliot Courtney @ 2026-12-02 12:06 UTC (permalink / raw)
To: Danilo Krummrich, Alice Ryhl, Alexandre Courbot, David Airlie,
Simona Vetter
Cc: John Hubbard, Alistair Popple, Timur Tabi, Zhi Wang, nova-gpu,
dri-devel, linux-kernel, Eliot Courtney
Patches 1-7 from v1 (the falcon `load`/`boot` rework and `zerocopy`
prep) were applied to drm-rust-next, so v2 only has the remaining r000
load+exec handler patches based on John's series [1].
This is based on drm-rust-next.
[1]: https://lore.kernel.org/20261120044704.165223-1-jhubbard@nvidia.com
John's cover letter, trimmed to what still applies:
> This series adds the code that runs a falcon binary on behalf of the
> r000 GSP-RM during boot. It is the next part of the r000 GSP firmware
> series [2], which moves nova-core onto the GSP firmware of the r615 and
> later releases. The patches do not depend on the switch to r000, so they
> are posted on their own, in order to make the rest of that series
> smaller. With these applied, the driver still boots the r570 firmware.
>
> Some background (perhaps a refresher for some readers): the GSP falcon
> has two cores, a falcon core and a RISC-V core, and only one of the two
> is active at a time. GSP-RM runs on the RISC-V core.
>
> During boot, the r000 GSP-RM requires a binary to run on the falcon
> core. GSP-RM raises a load-and-execute event and suspends the RISC-V
> core. The driver then resets the GSP falcon, loads and runs the binary,
> and resumes GSP-RM. There are two such events:
>
> * On GA102 and later, the binary is a Heavy-Secured (HS) binary that
> GSP-RM has placed in the framebuffer.
>
> * On Turing and GA100, the binary is an image that the generic falcon
> bootloader loads. The event carries a descriptor of the image.
>
> The series adds a handler for each of the two events, and a dispatcher
> that selects the handler from the command ID of an event. The handlers
> share steps with code that the driver already has, so the series first
> factors those steps out:
>
> * the wait for the GSP suspend, out of the shutdown path
> * the core resume, out of the CPU sequencer
>
> The only change in what the driver does with the r570 firmware is a
> slight change in the appearance of two error messages (mentioned below).
>
> Changes since v3 of the r000 series. The two handlers and the dispatcher
> come from v3 patches 15, 17 and 18:
>
> * GSP-RM is now resumed with the core resume of the CPU sequencer.
>
> * Typesafe handler code: a handler receives its decoded parameters, and
> the dispatcher decodes the payload of the event, instead of using two
> raw byte slices to describe the payload.
>
> * The selection of the BAR2 engine ID is now introduced in a separate,
> small patch.
>
> * Fixed two error messages in GSP-RM resume.
>
> An LLM coding assistant (Claude Code) helped write every patch, and
> drafted the commit messages and this letter, all of which I've edited by
> hand afterwards.
>
> [2] https://lore.kernel.org/all/20260918010719.1176945-1-jhubbard@nvidia.com/
Signed-off-by: Eliot Courtney <ecourtney@nvidia.com>
---
Changes since boot-rework2 v2 and John's v1 [1]:
- Merge the two series into one (Alex)
- Add a comment on V2-only bootloader-loaded FWSEC in patch #3 (Alex)
- Add patch #7, which derives the `zerocopy` traits for
`BootloaderDmemDescV2`
- Drop John's 1/9 (in drm-rust-next as 002b9422b314) and 3/9 (patch #1
programs BROM and BOOTVEC in `boot`)
- Rework John's patches on top of patches #1-#6
- Link to boot-rework2 v2: https://patch.msgid.link/20261129-boot-rework2-v2-0-622f3560e18a@nvidia.com
---
Changes in v2:
- Drop patches #1-#7, applied to drm-rust-next
- Rebase on drm-rust-next
- Leave out the module doc until patch #5 adds it (Alex)
- Always write `Bar2Fn0` on dma cfg reg (Alex)
- Load the generic bootloader in place instead of passing it in (Alex)
- Return `EIO` without resuming GSP-RM when `MAILBOX0` is non-zero (Alex)
- Link to v1: https://patch.msgid.link/20261130-falcon-v1-0-cb94f87b5674@nvidia.com
---
John Hubbard (7):
gpu: nova-core: falcon: factor out the wait for the GSP suspend
gpu: nova-core: gsp: factor out the core resume
gpu: nova-core: gsp: fix resume_gsp_rm()'s error messages
gpu: nova-core: falcon: select the BAR2 engine ID for DMA transfers
gpu: nova-core: gsp: add the r000 load-and-execute HS binary handler
gpu: nova-core: gsp: add the r000 load-and-execute bootloader handler
gpu: nova-core: gsp: add the load-and-execute event dispatcher
drivers/gpu/nova-core/falcon.rs | 15 +-
drivers/gpu/nova-core/falcon/gsp.rs | 15 +
drivers/gpu/nova-core/firmware/gen_bootloader.rs | 2 +-
drivers/gpu/nova-core/gsp.rs | 1 +
drivers/gpu/nova-core/gsp/boot.rs | 8 +-
drivers/gpu/nova-core/gsp/load_exec.rs | 511 +++++++++++++++++++++++
drivers/gpu/nova-core/gsp/sequencer.rs | 42 +-
drivers/gpu/nova-core/regs.rs | 2 +
drivers/gpu/nova-core/sbuffer.rs | 1 -
9 files changed, 553 insertions(+), 44 deletions(-)
---
base-commit: 73a8f8366b2389c2506959ab3e408c3c5161ac1a
change-id: 20261130-falcon-adc42c387291
Best regards,
--
Eliot Courtney <ecourtney@nvidia.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 1/7] gpu: nova-core: falcon: factor out the wait for the GSP suspend
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 ` Eliot Courtney
2026-12-02 12:06 ` [PATCH v2 2/7] gpu: nova-core: gsp: factor out the core resume Eliot Courtney
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Eliot Courtney @ 2026-12-02 12:06 UTC (permalink / raw)
To: Danilo Krummrich, Alice Ryhl, Alexandre Courbot, David Airlie,
Simona Vetter
Cc: John Hubbard, Alistair Popple, Timur Tabi, Zhi Wang, nova-gpu,
dri-devel, linux-kernel, Eliot Courtney
From: John Hubbard <jhubbard@nvidia.com>
The r000 boot protocol requires the driver to wait for the GSP suspend
bit after each load-and-execute event, as the shutdown path already
does.
In order to make the wait available to the boot sequence, factor it out
of the shutdown path, into a method of the GSP falcon.
No functional changes.
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
Reviewed-by: Eliot Courtney <ecourtney@nvidia.com>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Eliot Courtney <ecourtney@nvidia.com>
---
drivers/gpu/nova-core/falcon/gsp.rs | 15 +++++++++++++++
drivers/gpu/nova-core/gsp/boot.rs | 8 +-------
2 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/nova-core/falcon/gsp.rs b/drivers/gpu/nova-core/falcon/gsp.rs
index 54247691b53c..2ea28fa53db8 100644
--- a/drivers/gpu/nova-core/falcon/gsp.rs
+++ b/drivers/gpu/nova-core/falcon/gsp.rs
@@ -54,6 +54,21 @@ pub(crate) fn is_processor_suspended(&self) -> bool {
.processor_suspended()
}
+ /// Waits until GSP-RM has suspended the RISC-V core.
+ ///
+ /// # Errors
+ ///
+ /// - `ETIMEDOUT` if the core has not suspended within five seconds.
+ pub(crate) fn wait_for_processor_suspend(&self) -> Result {
+ read_poll_timeout(
+ || Ok(self.is_processor_suspended()),
+ |suspended| *suspended,
+ Delta::from_millis(10),
+ Delta::from_secs(5),
+ )
+ .map(|_| ())
+ }
+
/// Clears the SWGEN0 latch in the GSP falcon.
///
/// While the latch is set, no later message signals the tree, so a caller that consumed a
diff --git a/drivers/gpu/nova-core/gsp/boot.rs b/drivers/gpu/nova-core/gsp/boot.rs
index a45f2b21a2ab..09ad11ac74cb 100644
--- a/drivers/gpu/nova-core/gsp/boot.rs
+++ b/drivers/gpu/nova-core/gsp/boot.rs
@@ -104,13 +104,7 @@ fn shutdown_gsp(
cmdq.send_rpc_command(commands::rpc::UnloadingGuestDriver::new(mode))?;
// Wait until GSP signals it is suspended.
- read_poll_timeout(
- || Ok(gsp_falcon.is_processor_suspended()),
- |suspended| *suspended,
- Delta::from_millis(10),
- Delta::from_secs(5),
- )
- .map(|_| ())
+ gsp_falcon.wait_for_processor_suspend()
}
/// Attempts to unload the GSP firmware.
--
2.56.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 2/7] gpu: nova-core: gsp: factor out the core resume
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 ` Eliot Courtney
2026-12-02 12:06 ` [PATCH v2 3/7] gpu: nova-core: gsp: fix resume_gsp_rm()'s error messages Eliot Courtney
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Eliot Courtney @ 2026-12-02 12:06 UTC (permalink / raw)
To: Danilo Krummrich, Alice Ryhl, Alexandre Courbot, David Airlie,
Simona Vetter
Cc: John Hubbard, Alistair Popple, Timur Tabi, Zhi Wang, nova-gpu,
dri-devel, linux-kernel, Eliot Courtney
From: John Hubbard <jhubbard@nvidia.com>
The r000 boot protocol requires the driver to reset the GSP falcon
before running the binary of a load-and-execute event, and to resume
GSP-RM afterwards. The core reset and the core resume commands of the
CPU sequencer already do both.
In order to make the core resume available outside the sequencer,
factor it out into a module of its own.
No functional changes.
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
[ecourtney: factor out only the resume, `Falcon::boot()` calls `dma_reset()`]
[ecourtney: leave out the module doc, the HS handler patch adds it]
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Eliot Courtney <ecourtney@nvidia.com>
---
drivers/gpu/nova-core/gsp.rs | 1 +
drivers/gpu/nova-core/gsp/load_exec.rs | 69 ++++++++++++++++++++++++++++++++++
drivers/gpu/nova-core/gsp/sequencer.rs | 42 ++++-----------------
3 files changed, 78 insertions(+), 34 deletions(-)
diff --git a/drivers/gpu/nova-core/gsp.rs b/drivers/gpu/nova-core/gsp.rs
index bf0028e52e3c..2189ce39fee5 100644
--- a/drivers/gpu/nova-core/gsp.rs
+++ b/drivers/gpu/nova-core/gsp.rs
@@ -20,6 +20,7 @@
pub(crate) mod cmdq;
pub(crate) mod commands;
mod fw;
+mod load_exec;
mod logbuffer;
mod nvkv;
mod regs;
diff --git a/drivers/gpu/nova-core/gsp/load_exec.rs b/drivers/gpu/nova-core/gsp/load_exec.rs
new file mode 100644
index 000000000000..9b6b37556367
--- /dev/null
+++ b/drivers/gpu/nova-core/gsp/load_exec.rs
@@ -0,0 +1,69 @@
+// SPDX-License-Identifier: GPL-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+
+use kernel::{
+ device,
+ dma::DmaAddress,
+ prelude::*,
+ time::Delta, //
+};
+
+use crate::falcon::{
+ gsp::Gsp,
+ sec2::Sec2,
+ Falcon, //
+};
+
+/// Resumes GSP-RM on the GSP falcon by starting the SEC2 falcon.
+///
+/// Resets the GSP falcon and writes `libos_dma_address` to its mailboxes before the start, and
+/// writes `bootloader_app_version` to its OS register once the resume has completed.
+///
+/// The SEC2 falcon must hold a loaded firmware that has not started.
+///
+/// # Errors
+///
+/// - `ETIMEDOUT` if the resume has not completed within two seconds.
+/// - `EIO` if `MAILBOX0` of the SEC2 falcon is not zero after the resume, or if the RISC-V core of
+/// the GSP falcon is not active.
+///
+/// Errors from the reset of the GSP falcon are propagated as-is.
+pub(super) fn resume_gsp_rm(
+ dev: &device::Device,
+ gsp_falcon: &Falcon<'_, Gsp>,
+ sec2_falcon: &Falcon<'_, Sec2>,
+ libos_dma_address: DmaAddress,
+ bootloader_app_version: u32,
+) -> Result {
+ // Reset the GSP to prepare it for resuming.
+ gsp_falcon.reset()?;
+
+ // Write the libOS DMA address to GSP mailboxes.
+ gsp_falcon.write_mailboxes(
+ Some(libos_dma_address as u32),
+ Some((libos_dma_address >> 32) as u32),
+ );
+
+ // Start the SEC2 falcon which will trigger GSP-RM to resume on the GSP.
+ sec2_falcon.start()?;
+
+ // Poll until GSP-RM reload/resume has completed (up to 2 seconds).
+ gsp_falcon.check_reload_completed(Delta::from_secs(2))?;
+
+ // Verify SEC2 completed successfully by checking its mailbox for errors.
+ let mbox0 = sec2_falcon.read_mailbox0();
+ if mbox0 != 0 {
+ dev_err!(dev, "Sequencer: sec2 errors: {:?}\n", mbox0);
+ return Err(EIO);
+ }
+
+ // Configure GSP with the bootloader version.
+ gsp_falcon.write_os_version(bootloader_app_version);
+
+ // Verify the GSP's RISC-V core is active indicating successful GSP boot.
+ if !gsp_falcon.is_riscv_active() {
+ dev_err!(dev, "Sequencer: RISC-V core is not active\n");
+ return Err(EIO);
+ }
+ Ok(())
+}
diff --git a/drivers/gpu/nova-core/gsp/sequencer.rs b/drivers/gpu/nova-core/gsp/sequencer.rs
index 23b09fb875e9..bd83dd924244 100644
--- a/drivers/gpu/nova-core/gsp/sequencer.rs
+++ b/drivers/gpu/nova-core/gsp/sequencer.rs
@@ -32,6 +32,7 @@
Cmdq, //
},
fw,
+ load_exec,
GspBootContext,
LibosMemoryRegionInitArgument, //
},
@@ -230,40 +231,13 @@ fn run(&self, seq: &GspSequencer<'_>) -> Result {
// At this point, 'SEC2-RTOS' has been loaded into SEC2 by the sequencer
// but neither SEC2-RTOS nor GSP-RM is running yet. This part of the
// sequencer will start both.
-
- // Reset the GSP to prepare it for resuming.
- seq.gsp_falcon.reset()?;
-
- let libos_dma_address = seq.libos.dma_address();
-
- // Write the libOS DMA address to GSP mailboxes.
- seq.gsp_falcon.write_mailboxes(
- Some(libos_dma_address as u32),
- Some((libos_dma_address >> 32) as u32),
- );
-
- // Start the SEC2 falcon which will trigger GSP-RM to resume on the GSP.
- seq.sec2_falcon.start()?;
-
- // Poll until GSP-RM reload/resume has completed (up to 2 seconds).
- seq.gsp_falcon.check_reload_completed(Delta::from_secs(2))?;
-
- // Verify SEC2 completed successfully by checking its mailbox for errors.
- let mbox0 = seq.sec2_falcon.read_mailbox0();
- if mbox0 != 0 {
- dev_err!(seq.dev, "Sequencer: sec2 errors: {:?}\n", mbox0);
- return Err(EIO);
- }
-
- // Configure GSP with the bootloader version.
- seq.gsp_falcon.write_os_version(seq.bootloader_app_version);
-
- // Verify the GSP's RISC-V core is active indicating successful GSP boot.
- if !seq.gsp_falcon.is_riscv_active() {
- dev_err!(seq.dev, "Sequencer: RISC-V core is not active\n");
- return Err(EIO);
- }
- Ok(())
+ load_exec::resume_gsp_rm(
+ seq.dev,
+ seq.gsp_falcon,
+ seq.sec2_falcon,
+ seq.libos.dma_address(),
+ seq.bootloader_app_version,
+ )
}
}
}
--
2.56.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 3/7] gpu: nova-core: gsp: fix resume_gsp_rm()'s error messages
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 ` 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
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Eliot Courtney @ 2026-12-02 12:06 UTC (permalink / raw)
To: Danilo Krummrich, Alice Ryhl, Alexandre Courbot, David Airlie,
Simona Vetter
Cc: John Hubbard, Alistair Popple, Timur Tabi, Zhi Wang, nova-gpu,
dri-devel, linux-kernel, Eliot Courtney
From: John Hubbard <jhubbard@nvidia.com>
resume_gsp_rm()'s error messages have two problems:
* Both messages open with "Sequencer:", which assumes that the function
knows which code is calling it, and that this will never change. This
kind of tight coupling is almost never desirable in well-structured
code.
* One message prints the SEC2 mailbox value in decimal. That needlessly
complicates looking up the error code, given that Open RM documents
those values in hex.
Remove the sequencer's name from both messages and name the GSP-RM
resume instead, and print the SEC2 mailbox value in hexadecimal.
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
Reviewed-by: Eliot Courtney <ecourtney@nvidia.com>
Signed-off-by: Eliot Courtney <ecourtney@nvidia.com>
---
drivers/gpu/nova-core/gsp/load_exec.rs | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/nova-core/gsp/load_exec.rs b/drivers/gpu/nova-core/gsp/load_exec.rs
index 9b6b37556367..5148ea1c199f 100644
--- a/drivers/gpu/nova-core/gsp/load_exec.rs
+++ b/drivers/gpu/nova-core/gsp/load_exec.rs
@@ -53,7 +53,11 @@ pub(super) fn resume_gsp_rm(
// Verify SEC2 completed successfully by checking its mailbox for errors.
let mbox0 = sec2_falcon.read_mailbox0();
if mbox0 != 0 {
- dev_err!(dev, "Sequencer: sec2 errors: {:?}\n", mbox0);
+ dev_err!(
+ dev,
+ "SEC2 reported an error while resuming GSP-RM: {:#x}\n",
+ mbox0
+ );
return Err(EIO);
}
@@ -62,7 +66,7 @@ pub(super) fn resume_gsp_rm(
// Verify the GSP's RISC-V core is active indicating successful GSP boot.
if !gsp_falcon.is_riscv_active() {
- dev_err!(dev, "Sequencer: RISC-V core is not active\n");
+ dev_err!(dev, "GSP RISC-V core is not active after resuming GSP-RM\n");
return Err(EIO);
}
Ok(())
--
2.56.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 4/7] gpu: nova-core: falcon: select the BAR2 engine ID for DMA transfers
2026-12-02 12:06 [PATCH v2 0/7] gpu: nova-core: gsp: add r000 load+exec handlers Eliot Courtney
` (2 preceding siblings ...)
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 ` 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
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Eliot Courtney @ 2026-12-02 12:06 UTC (permalink / raw)
To: Danilo Krummrich, Alice Ryhl, Alexandre Courbot, David Airlie,
Simona Vetter
Cc: John Hubbard, Alistair Popple, Timur Tabi, Zhi Wang, nova-gpu,
dri-devel, linux-kernel, Eliot Courtney
From: John Hubbard <jhubbard@nvidia.com>
When Open RM loads a binary from the framebuffer into a falcon by DMA,
it selects BAR2 as the MMU engine ID of the transfer, in the falcon's
FBIF_TRANSCFG register. Nova-core's definition of the register has no
field for the engine ID, so the DMA transfer code has no way to select
one.
Add the field, and select the BAR2 engine ID for every DMA transfer.
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
[ecourtney: select `Bar2Fn0` for every DMA transfer, as the enum doc says]
Signed-off-by: Eliot Courtney <ecourtney@nvidia.com>
---
drivers/gpu/nova-core/falcon.rs | 14 ++++++++++++++
drivers/gpu/nova-core/regs.rs | 2 ++
2 files changed, 16 insertions(+)
diff --git a/drivers/gpu/nova-core/falcon.rs b/drivers/gpu/nova-core/falcon.rs
index 0a375394f71a..bd0885be3ffe 100644
--- a/drivers/gpu/nova-core/falcon.rs
+++ b/drivers/gpu/nova-core/falcon.rs
@@ -160,6 +160,19 @@ pub(crate) enum FalconFbifMemType with From<Bounded<u32, 1>> {
}
}
+bounded_enum! {
+ /// MMU engine ID under which the falcon's FBIF issues a DMA transfer.
+ ///
+ /// A kernel driver should select `Bar2Fn0`. (Only GPU firmware selects `Own`.)
+ #[derive(Debug, Copy, Clone)]
+ pub(crate) enum FalconFbifEngineIdFlag with From<Bounded<u32, 1>> {
+ /// The engine ID of PCI function 0's BAR2.
+ Bar2Fn0 = 0,
+ /// The falcon's own engine ID.
+ Own = 1,
+ }
+}
+
const PFALCON_REGION_SIZE: usize = SZ_4K;
const PFALCON2_REGION_SIZE: usize = SZ_4K;
@@ -482,6 +495,7 @@ fn dma_wr(
.update(regs::NV_PFALCON_FBIF_TRANSCFG::at(0), |v| {
v.with_target(fbif_target)
.with_mem_type(FalconFbifMemType::Physical)
+ .with_engine_id_flag(FalconFbifEngineIdFlag::Bar2Fn0)
});
for pos in (0..num_transfers).map(|i| i * DMA_LEN) {
diff --git a/drivers/gpu/nova-core/regs.rs b/drivers/gpu/nova-core/regs.rs
index dfe7944cf1e7..050054a2b23d 100644
--- a/drivers/gpu/nova-core/regs.rs
+++ b/drivers/gpu/nova-core/regs.rs
@@ -18,6 +18,7 @@
DmaTrfCmdSize,
FalconCoreRev,
FalconCoreRevSubversion,
+ FalconFbifEngineIdFlag,
FalconFbifMemType,
FalconFbifTarget,
FalconMem,
@@ -291,6 +292,7 @@ pub(crate) fn usable_fb_size(self) -> u64 {
}
pub(crate) NV_PFALCON_FBIF_TRANSCFG(u32)[8] @ 0x00000600 {
+ 16:16 engine_id_flag => FalconFbifEngineIdFlag;
2:2 mem_type => FalconFbifMemType;
1:0 target ?=> FalconFbifTarget;
}
--
2.56.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 5/7] gpu: nova-core: gsp: add the r000 load-and-execute HS binary handler
2026-12-02 12:06 [PATCH v2 0/7] gpu: nova-core: gsp: add r000 load+exec handlers Eliot Courtney
` (3 preceding siblings ...)
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 ` 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 ` [PATCH v2 7/7] gpu: nova-core: gsp: add the load-and-execute event dispatcher Eliot Courtney
6 siblings, 0 replies; 8+ messages in thread
From: Eliot Courtney @ 2026-12-02 12:06 UTC (permalink / raw)
To: Danilo Krummrich, Alice Ryhl, Alexandre Courbot, David Airlie,
Simona Vetter
Cc: John Hubbard, Alistair Popple, Timur Tabi, Zhi Wang, nova-gpu,
dri-devel, linux-kernel, Eliot Courtney
From: John Hubbard <jhubbard@nvidia.com>
The GSP falcon is a microcontroller with two cores, a falcon core and a
RISC-V core, and only one of the two is active at a time. GSP-RM runs on
the RISC-V core.
On GA102 and later, the r000 GSP-RM requires a Heavy-Secured (HS) binary
to run on the falcon core during boot. GSP-RM is suspended while the
binary runs.
The driver runs the binary on behalf of GSP-RM, in the following steps:
1. GSP-RM places the binary in the framebuffer.
2. GSP-RM raises a load-and-execute event.
3. GSP-RM suspends the RISC-V core.
4. The driver waits until the RISC-V core is suspended.
5. The driver resets the GSP falcon, which selects the falcon core.
6. The driver loads the binary from the framebuffer into the GSP falcon.
7. The driver starts the binary and 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 load-and-execute event.
Add the handler, which performs steps 4 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: boot HS binary with `Falcon::boot()`, keeping `dma_wr()` private]
[ecourtney: zerocopy derives for `HsBinaryParams`, no `unsafe impl`]
[ecourtney: move MAILBOX0 check and resume to `handle_load_exec_event()`]
[ecourtney: module doc's FBIF sentence moved here from the bootloader patch]
[ecourtney: move some methods to be impls of `GspBootContext`]
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Eliot Courtney <ecourtney@nvidia.com>
---
drivers/gpu/nova-core/falcon.rs | 1 -
drivers/gpu/nova-core/gsp/load_exec.rs | 228 ++++++++++++++++++++++++++++++++-
drivers/gpu/nova-core/sbuffer.rs | 1 -
3 files changed, 224 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/nova-core/falcon.rs b/drivers/gpu/nova-core/falcon.rs
index bd0885be3ffe..760ff9c18055 100644
--- a/drivers/gpu/nova-core/falcon.rs
+++ b/drivers/gpu/nova-core/falcon.rs
@@ -211,7 +211,6 @@ pub(crate) enum FalconSegmentSource<'a> {
/// Bytes in system memory.
Sysmem(&'a [u8]),
/// Bytes in the framebuffer.
- #[expect(dead_code)]
Framebuffer {
/// DMA base address in the framebuffer. The falcon adds the segment's
/// virtual address to it, so the actual segment may not start directly
diff --git a/drivers/gpu/nova-core/gsp/load_exec.rs b/drivers/gpu/nova-core/gsp/load_exec.rs
index 5148ea1c199f..6d832cb9ec24 100644
--- a/drivers/gpu/nova-core/gsp/load_exec.rs
+++ b/drivers/gpu/nova-core/gsp/load_exec.rs
@@ -1,19 +1,54 @@
// SPDX-License-Identifier: GPL-2.0
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+//! The load-and-execute events of the GSP boot.
+//!
+//! See `Documentation/gpu/nova/core/falcon.rst`:
+//!
+//! - "Falcon security levels" describes the Heavy-Secured (HS) mode of a falcon and the boot ROM
+//! that verifies an HS binary. The note in "Root of trust establishment" says why the GSP falcon
+//! stops running GSP-RM, runs an HS binary, and then resumes GSP-RM.
+//! - "Falcon memory subsystem and DMA engine" describes the instruction memory (IMEM) and the data
+//! memory (DMEM) of a falcon, and the DMA engine that loads a binary into them. The DMA engine
+//! accesses the framebuffer or system memory through the FBIF (Framebuffer Interface).
+
+use core::array;
+
use kernel::{
device,
dma::DmaAddress,
prelude::*,
time::Delta, //
};
+use zerocopy::FromZeros;
-use crate::falcon::{
- gsp::Gsp,
- sec2::Sec2,
- Falcon, //
+use crate::{
+ falcon::{
+ gsp::Gsp,
+ sec2::Sec2,
+ Falcon,
+ FalconBromParams,
+ FalconDmemSegment,
+ FalconFirmware,
+ FalconImage,
+ FalconImemSegment,
+ FalconSegmentSource, //
+ },
+ gsp::{
+ cmdq::gmc::MessageFromGsp,
+ GspBootContext, //
+ },
+ sbuffer::SBufferIter, //
};
+/// DMEM virtual address value that means "no virtual address assigned".
+const FLCN_DMEM_VA_INVALID: u32 = 0xffff_ffff;
+
+/// `MAILBOX0` value that means that a falcon binary has not started.
+///
+/// A binary that reports its status through `MAILBOX0` replaces it.
+const FLCN_ERR_BINARY_NOT_STARTED: u32 = 0xfe;
+
/// Resumes GSP-RM on the GSP falcon by starting the SEC2 falcon.
///
/// Resets the GSP falcon and writes `libos_dma_address` to its mailboxes before the start, and
@@ -71,3 +106,188 @@ pub(super) fn resume_gsp_rm(
}
Ok(())
}
+
+impl GspBootContext<'_, '_> {
+ /// Waits until GSP-RM has suspended the RISC-V core, and then resets the GSP
+ /// falcon.
+ fn reset_gsp_falcon_after_suspend(&self) -> Result {
+ let dev = self.dev();
+ let gsp_falcon = self.gsp_falcon;
+
+ gsp_falcon.wait_for_processor_suspend().inspect_err(|_| {
+ dev_err!(
+ dev,
+ "Timeout waiting for GSP-RM (RISC-V core) to suspend (mbox0={:#x})\n",
+ gsp_falcon.read_mailbox0()
+ );
+ })?;
+
+ gsp_falcon.reset()
+ }
+
+ /// Runs the Heavy-Secured (HS) binary of a `GMCAPI_CMD_EXEC_HS_BINARY` event
+ /// on the falcon core of the GSP falcon, and returns `MAILBOX0` once the
+ /// binary has halted.
+ ///
+ /// `params` describes the binary. The handler:
+ ///
+ /// 1. Waits until GSP-RM has suspended the RISC-V core, for up to five
+ /// seconds.
+ /// 2. Resets the GSP falcon, which selects the falcon core.
+ /// 3. Loads the code segment into IMEM and the data segment into DMEM, by
+ /// DMA from the framebuffer.
+ /// 4. Programs the boot ROM parameters and the boot vector, and writes
+ /// [`FLCN_ERR_BINARY_NOT_STARTED`] to `MAILBOX0`.
+ /// 5. Starts the falcon core, and waits until the falcon core halts, for up
+ /// to two seconds. The binary halts the falcon core when it is done, so
+ /// the handler learns from the halt that the binary has finished.
+ ///
+ /// # Errors
+ ///
+ /// - `EINVAL` if the engine ID mask or the ucode ID of `params` does not fit
+ /// its [`FalconBromParams`] field.
+ /// - `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 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;
+ let hs_binary = HsBinary::try_from(params)?;
+
+ self.reset_gsp_falcon_after_suspend()?;
+
+ gsp_falcon
+ .boot(&hs_binary, Some(FLCN_ERR_BINARY_NOT_STARTED), None)
+ .map(|(mbox0, _)| mbox0)
+ .inspect_err(|e| {
+ dev_err!(
+ dev,
+ "Failed to run the HS binary: {:?} (mbox0={:#x})\n",
+ e,
+ gsp_falcon.read_mailbox0()
+ );
+ })
+ }
+}
+
+/// Payload of a `GMCAPI_CMD_EXEC_HS_BINARY` event, which describes the HS binary to run.
+#[repr(C)]
+#[derive(FromBytes, IntoBytes)]
+struct HsBinaryParams {
+ /// DMA base of the code segment, a physical address in the framebuffer.
+ ///
+ /// The code segment starts at `imem_dma_base + imem_va`.
+ imem_dma_base: u64,
+ /// DMA base of the data segment, a physical address in the framebuffer.
+ ///
+ /// The data segment starts at `dmem_dma_base + dmem_va`, or at `dmem_dma_base`
+ /// when the data segment has no virtual address.
+ dmem_dma_base: u64,
+ _reserved64: [u64; 2],
+ /// Virtual address of the code segment.
+ ///
+ /// The binary starts executing at this address.
+ imem_va: u32,
+ /// Physical address in IMEM at which the code segment is loaded.
+ imem_pa: u32,
+ /// Size in bytes of the code segment.
+ imem_size: u32,
+ /// Virtual address of the data segment, or [`FLCN_DMEM_VA_INVALID`] if the data
+ /// segment has no virtual address.
+ ///
+ /// The DMA transfer writes no tags in that case.
+ dmem_va: u32,
+ /// Physical address in DMEM at which the data segment is loaded.
+ dmem_pa: u32,
+ /// Size in bytes of the data segment.
+ dmem_size: u32,
+ /// Physical address in DMEM of the signature of the binary.
+ hs_sig_dmem_addr: u32,
+ /// Mask of the falcon engines on which the binary can run, with one bit per engine.
+ engine_id_mask: u32,
+ /// ID number of the binary.
+ ///
+ /// Each ID has a fuse register that holds a version number. The boot ROM uses
+ /// the ID and that version number as inputs of the signature verification.
+ ucode_id: u32,
+ _reserved32: [u32; 3],
+}
+
+impl MessageFromGsp for HsBinaryParams {
+ 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)
+ }
+}
+
+/// HS binary of a `GMCAPI_CMD_EXEC_HS_BINARY` event, as a [`FalconFirmware`]
+/// loaded from the framebuffer.
+struct HsBinary {
+ /// Code segment, loaded into IMEM as secure code.
+ imem: FalconImemSegment<'static>,
+ /// Data segment, loaded into DMEM.
+ dmem: FalconDmemSegment<'static>,
+ /// Parameters that the boot ROM uses to check the signature of the binary.
+ brom_params: FalconBromParams,
+}
+
+impl TryFrom<&HsBinaryParams> for HsBinary {
+ type Error = Error;
+
+ fn try_from(params: &HsBinaryParams) -> Result<Self> {
+ Ok(Self {
+ imem: FalconImemSegment {
+ source: FalconSegmentSource::Framebuffer {
+ base: params.imem_dma_base,
+ len: params.imem_size,
+ },
+ dst_start: params.imem_pa,
+ va: params.imem_va,
+ },
+ dmem: FalconDmemSegment {
+ source: FalconSegmentSource::Framebuffer {
+ base: params.dmem_dma_base,
+ len: params.dmem_size,
+ },
+ dst_start: params.dmem_pa,
+ // A data segment with a virtual address is tagged with it. One without starts at
+ // the DMA base.
+ va: (params.dmem_va != FLCN_DMEM_VA_INVALID).then_some(params.dmem_va),
+ },
+ brom_params: FalconBromParams {
+ pkc_data_offset: params.hs_sig_dmem_addr,
+ engine_id_mask: u16::try_from(params.engine_id_mask)?,
+ ucode_id: u8::try_from(params.ucode_id)?,
+ },
+ })
+ }
+}
+
+impl FalconFirmware for HsBinary {
+ type Target = Gsp;
+
+ fn image(&self) -> Result<FalconImage<'_>> {
+ Ok(FalconImage {
+ imem_ns: None,
+ imem_sec: Some(self.imem.clone()),
+ dmem: self.dmem.clone(),
+ })
+ }
+
+ fn brom_params(&self) -> FalconBromParams {
+ self.brom_params.clone()
+ }
+
+ fn boot_addr(&self) -> u32 {
+ self.imem.va
+ }
+}
diff --git a/drivers/gpu/nova-core/sbuffer.rs b/drivers/gpu/nova-core/sbuffer.rs
index 3a41d224c77a..b8c01104c255 100644
--- a/drivers/gpu/nova-core/sbuffer.rs
+++ b/drivers/gpu/nova-core/sbuffer.rs
@@ -146,7 +146,6 @@ fn get_slice(&mut self, len: usize) -> Option<&'a [u8]> {
/// Ideally we would implement `Read`, but it is not available in `core`.
/// So mimic `std::io::Read::read_exact`.
- #[expect(unused)]
pub(crate) fn read_exact(&mut self, mut dst: &mut [u8]) -> Result {
while !dst.is_empty() {
match self.get_slice(dst.len()) {
--
2.56.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 6/7] gpu: nova-core: gsp: add the r000 load-and-execute bootloader handler
2026-12-02 12:06 [PATCH v2 0/7] gpu: nova-core: gsp: add r000 load+exec handlers Eliot Courtney
` (4 preceding siblings ...)
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 ` Eliot Courtney
2026-12-02 12:06 ` [PATCH v2 7/7] gpu: nova-core: gsp: add the load-and-execute event dispatcher Eliot Courtney
6 siblings, 0 replies; 8+ messages in thread
From: Eliot Courtney @ 2026-12-02 12:06 UTC (permalink / raw)
To: Danilo Krummrich, Alice Ryhl, Alexandre Courbot, David Airlie,
Simona Vetter
Cc: John Hubbard, Alistair Popple, Timur Tabi, Zhi Wang, nova-gpu,
dri-devel, linux-kernel, Eliot Courtney
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`]
[ecourtney: load the generic bootloader in the handler, don't pass it in]
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 | 131 +++++++++++++++++++++++
2 files changed, 132 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..1eab4c00e4d3 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,79 @@ 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. 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.
+ /// 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
+ /// image has finished.
+ ///
+ /// # Errors
+ ///
+ /// - `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 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>());
+
+ let dev = self.dev();
+ let gsp_falcon = self.gsp_falcon;
+
+ 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()?;
+ let bootloader = GenericBootloader::new(dev, self.chipset)?;
+
+ 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 +369,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
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 7/7] gpu: nova-core: gsp: add the load-and-execute event dispatcher
2026-12-02 12:06 [PATCH v2 0/7] gpu: nova-core: gsp: add r000 load+exec handlers Eliot Courtney
` (5 preceding siblings ...)
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
6 siblings, 0 replies; 8+ messages in thread
From: Eliot Courtney @ 2026-12-02 12:06 UTC (permalink / raw)
To: Danilo Krummrich, Alice Ryhl, Alexandre Courbot, David Airlie,
Simona Vetter
Cc: John Hubbard, Alistair Popple, Timur Tabi, Zhi Wang, nova-gpu,
dri-devel, linux-kernel, Eliot Courtney
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
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-12-02 12:08 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH v2 7/7] gpu: nova-core: gsp: add the load-and-execute event dispatcher Eliot Courtney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox