This combines my falcon `load`/`boot` rework (patches 1-6) with John's r000 load+exec handlers [1] (patches 8-14). Patch 7 is a small prep patch for John's patches.
Currently, loading the firmware and booting it is split into two separate steps. Load is always called in combination with boot. Rewrite the process to basically look like: falcon.boot(<the firmware you want>, ...) Additionally, add a segment source for firmware already in the framebuffer (this is for HS binaries). This simplifies running HS binaries in the r000 load+exec boot process [1], because they can be treated as falcon firmware binaries directly, without having to call into the guts of the boot process code + make fns like `dma_wr` public. This is not a pure refactor, with this `dma_load` uses two `Coherent`s (one for imem, one for dmem) instead of one. The extra `Coherent` is a consequence of splitting the storage vs transfer method more orthogonally. I don't think it's consequential but jfyi. Tested boot on TU104, GA104, AD106 and GB205. This is based on drm-rust-next. [1]: https://lore.kernel.org/[email protected] John's cover letter for patches 8-14, 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/[email protected]/ Signed-off-by: Eliot Courtney <[email protected]> --- 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/[email protected] --- Eliot Courtney (7): gpu: nova-core: falcon: program BROM and BOOTVEC in `boot` gpu: nova-core: use correct offset for imem in `BooterFirmware` gpu: nova-core: remove some dependencies on FalconDmaLoadTarget gpu: nova-core: falcon: separate staging data for DMA from its location gpu: nova-core: falcon: add `FalconImage` for `FalconFirmware` trait gpu: nova-core: falcon: load the firmware image in Falcon::boot gpu: nova-core: firmware: use `zerocopy` for `BootloaderDmemDescV2` 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 framebuffer DMA 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 | 451 ++++++++---------- drivers/gpu/nova-core/falcon/gsp.rs | 15 + drivers/gpu/nova-core/firmware.rs | 74 +-- drivers/gpu/nova-core/firmware/booter.rs | 120 ++--- drivers/gpu/nova-core/firmware/fwsec.rs | 57 ++- drivers/gpu/nova-core/firmware/fwsec/bootloader.rs | 50 +- drivers/gpu/nova-core/firmware/gen_bootloader.rs | 112 ++--- drivers/gpu/nova-core/gsp.rs | 1 + drivers/gpu/nova-core/gsp/boot.rs | 8 +- drivers/gpu/nova-core/gsp/hal/tu102.rs | 9 +- 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 - 14 files changed, 906 insertions(+), 547 deletions(-) --- base-commit: abfb640b2374e26de8ff81d488c39d8254db538e change-id: 20261130-falcon-adc42c387291 Best regards, -- Eliot Courtney <[email protected]>
