From: Zhi Wang <zhiw@nvidia.com>
To: John Hubbard <jhubbard@nvidia.com>
Cc: "Danilo Krummrich" <dakr@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Timur Tabi" <ttabi@nvidia.com>,
"Alistair Popple" <apopple@nvidia.com>,
"Eliot Courtney" <ecourtney@nvidia.com>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
nova-gpu@lists.linux.dev, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 20/27] gpu: nova-core: handle the r000 load-and-execute bootloader event
Date: Thu, 20 Aug 2026 19:24:15 +0300 [thread overview]
Message-ID: <20260820192415.4c9b9097@inno-dell> (raw)
In-Reply-To: <20260819035221.336390-21-jhubbard@nvidia.com>
On Tue, 18 Aug 2026 20:52:13 -0700
John Hubbard <jhubbard@nvidia.com> wrote:
snip
> + /// Handle a `GSP_LOAD_EXEC_GENERIC_BOOTLOADER` event.
> + ///
> + /// The driver does not copy the image the GSP asks for. It
> writes the descriptor the event
> + /// carries to DMEM offset 0, places the generic bootloader in
> IMEM, points the requested FBIF
> + /// aperture at wherever the image lives, and runs the
> bootloader, which does the copy from
> + /// the descriptor and jumps to the image. The aperture is
> restored afterwards.
> + ///
> + /// # Errors
> + ///
> + /// - `EINVAL` if the payload is shorter than the parameter
> block, the descriptor is not the
> + /// size this driver mirrors, or the event names a context DMA
> slot or an aperture that does
> + /// not exist.
> + /// - `ETIMEDOUT` if the GSP does not suspend, or the image does
> not halt, in time.
> + #[expect(dead_code)]
> + #[allow(clippy::too_many_arguments)]
> + fn handle_load_exec_bootloader(
> + payload: &[u8],
> + bootloader: &GenericBootloader,
> + gsp_falcon: &Falcon<'_, Gsp>,
> + sec2_falcon: &Falcon<'_, Sec2>,
> + bar: Bar0<'_>,
> + dev: &device::Device,
> + bootloader_app_version: u32,
> + libos_dma_handle: u64,
> + ) -> Result {
> + let params =
> LoadExecGenericBootloaderParams::from_bytes_prefix(payload)
> + .ok_or(EINVAL)?
> + .0;
> +
> + let desc_size =
> +
> u32::try_from(core::mem::size_of::<BootloaderDmemDescV2>()).map_err(|_|
> EOVERFLOW)?;
> + if params.dmem_desc_size != desc_size {
> + dev_err!(
> + dev,
> + "Load-exec descriptor is {} bytes, expected {}\n",
> + params.dmem_desc_size,
> + desc_size
> + );
> + return Err(EINVAL);
> + }
> +
> + let ctx_dma = params.ctx_dma()?;
> + let fbif_target = params.fbif_target()?;
> + let transcfg = || {
> + regs::NV_PFALCON_FBIF_TRANSCFG::of::<Gsp>()
> + .try_at(usize::from(ctx_dma))
> + .ok_or(EINVAL)
> + };
> +
> + gsp_falcon.wait_for_processor_suspend().inspect_err(|_| {
> + dev_err!(
> + dev,
> + "Timeout waiting for GSP suspend (mbox0={:#x})\n",
> + gsp_falcon.read_mailbox0()
> + );
> + })?;
> +
> + gsp_falcon.reset()?;
> + gsp_falcon.dma_reset();
> +
> + let saved_transcfg = bar.read(transcfg()?);
> + bar.update(transcfg()?, |v| {
> + v.with_target(fbif_target)
> + .with_mem_type(FalconFbifMemType::Physical)
> + });
> +
> + let run = (|| -> Result {
> +
> gsp_falcon.pio_load(&bootloader.with_descriptor(¶ms.dmem_desc))?;
> +
> + // Also clears the suspend bit that
> `wait_for_processor_suspend` polls, so the next
> + // load-and-execute event does not read this one's
> suspension.
> +
> gsp_falcon.write_mailboxes(Some(FLCN_ERR_BINARY_NOT_STARTED), None); +
> + gsp_falcon.start()?;
> + gsp_falcon.wait_till_halted().inspect_err(|_| {
> + dev_err!(
> + dev,
> + "Timeout waiting for the loaded image to halt
> (mbox0={:#x})\n",
> + gsp_falcon.read_mailbox0()
> + );
> + })
> + })();
> +
> + bar.update(transcfg()?, |_| saved_transcfg);
> + run?;
TRANSCFG was restored only when the transfer is successful in OpenRM [1]
(also r000 firmware), I think that is reasonable since if the HALT is
not received, the controller is in stale and might still be active on
memory read/write until it got reset.
I guess we should follow OpenRM's scheme, e.g.
run?;
bar.update(xxxx);
[1]
https://github.com/NVIDIA/open-gpu-kernel-modules/blob/main/src/nvidia/src/kernel/gpu/gsp/arch/turing/kernel_gsp_falcon_tu102.c#L556
> +
> + Self::core_resume(
> + gsp_falcon,
> + sec2_falcon,
> + dev,
> + bootloader_app_version,
> + libos_dma_handle,
> + )
> + }
> +
> /// Handle a `GSP_LOAD_EXEC_HS_BINARY` event.
> ///
> /// The GSP asks the driver to run a high-security binary that
> it has already placed in the @@ -347,6 +448,64 @@ pub(crate) fn
> unload( /// points it at local framebuffer.
> const HS_BINARY_CTX_DMA: u8 = 0;
>
> +/// Number of FBIF context DMA slots a falcon has.
> +const NUM_CTX_DMA: usize = 8;
> +
> +/// Parameters for loading and executing the generic bootloader.
> +///
> +/// Sent by GSP-RM as the payload of
> `GSP_LOAD_EXEC_GENERIC_BOOTLOADER`. The descriptor carries +/// the
> code and data addresses, while `addr_space` and `cpu_cache_attrib`
> say which FBIF aperture +/// reaches them. +#[repr(C)]
> +struct LoadExecGenericBootloaderParams {
> + dmem_desc: BootloaderDmemDescV2,
> + dmem_desc_size: u32,
> + addr_space: u32,
> + cpu_cache_attrib: u32,
> + _reserved: [u32; 4],
> +}
> +
> +impl LoadExecGenericBootloaderParams {
> + const ADDR_SYSMEM: u32 = 1;
> + const ADDR_FBMEM: u32 = 2;
> + const NV_MEMORY_CACHED: u32 = 0;
> + const NV_MEMORY_UNCACHED: u32 = 1;
> +
> + /// Returns the context DMA slot the bootloader is to fetch the
> image through.
> + ///
> + /// # Errors
> + ///
> + /// - `EINVAL` if the slot is outside the FBIF `TRANSCFG` array.
> + fn ctx_dma(&self) -> Result<u8> {
> + let ctx_dma = self.dmem_desc.ctx_dma;
> +
> + u8::try_from(ctx_dma)
> + .ok()
> + .filter(|slot| usize::from(*slot) < NUM_CTX_DMA)
> + .ok_or(EINVAL)
> + }
> +
> + /// Returns the FBIF aperture that reaches the image.
> + ///
> + /// # Errors
> + ///
> + /// - `EINVAL` if the address space and cache attribute pair is
> not one this driver maps.
> + 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),
> + }
> + }
> +}
> +
> +// SAFETY: The nested descriptor is `FromBytes`, and every other
> field is an integer type for +// which all bit patterns are valid.
> +unsafe impl FromBytes for LoadExecGenericBootloaderParams {}
> +
> /// Parameters for loading and executing an HS (High-Security)
> binary. ///
> /// Sent by GSP-RM as the payload of `GSP_LOAD_EXEC_HS_BINARY`. The
> firmware
next prev parent reply other threads:[~2026-08-20 16:25 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-19 3:51 [PATCH 00/27] gpu: nova-core: boot on the r000 GSP firmware John Hubbard
2026-08-19 3:51 ` [PATCH 01/27] gpu: nova-core: firmware: add r000 bindings John Hubbard
2026-08-19 3:51 ` [PATCH 02/27] gpu: nova-core: extract radix3 page table into its own module John Hubbard
2026-08-19 17:37 ` Timur Tabi
2026-08-20 1:05 ` John Hubbard
2026-08-19 3:51 ` [PATCH 03/27] gpu: nova-core: set MCTP transport header version to 1 John Hubbard
2026-08-20 9:38 ` Zhi Wang
2026-08-19 3:51 ` [PATCH 04/27] gpu: nova-core: add Falcon helpers for r000 LOAD_EXEC events John Hubbard
2026-08-20 9:53 ` Zhi Wang
2026-08-19 3:51 ` [PATCH 05/27] gpu: nova-core: zero-pad radix3 page table levels to page boundary John Hubbard
2026-08-19 17:41 ` Timur Tabi
2026-08-20 2:18 ` John Hubbard
2026-08-19 3:51 ` [PATCH 06/27] gpu: nova-core: distinguish async GSP RPC traffic in debug logs John Hubbard
2026-08-20 10:26 ` Zhi Wang
2026-08-19 3:52 ` [PATCH 07/27] gpu: nova-core: add optional ucodes firmware loading John Hubbard
2026-08-19 17:55 ` Timur Tabi
2026-08-20 2:22 ` John Hubbard
2026-08-19 18:41 ` Timur Tabi
2026-08-20 2:31 ` John Hubbard
2026-08-19 3:52 ` [PATCH 08/27] gpu: nova-core: add LIBOS3 log buffers and state monitor buffer John Hubbard
2026-08-19 18:12 ` Timur Tabi
2026-08-20 2:26 ` John Hubbard
2026-08-19 3:52 ` [PATCH 09/27] gpu: nova-core: add build ID headers to debugfs log buffer dumps John Hubbard
2026-08-19 18:20 ` Timur Tabi
2026-08-20 1:00 ` John Hubbard
2026-08-20 1:30 ` Timur Tabi
2026-08-20 2:03 ` John Hubbard
2026-08-19 3:52 ` [PATCH 10/27] gpu: nova-core: rename the FbRanges elf field to fw_image John Hubbard
2026-08-19 18:21 ` Timur Tabi
2026-08-20 1:01 ` John Hubbard
2026-08-19 3:52 ` [PATCH 11/27] gpu: nova-core: regs: add msgq v2 BAR0 register declarations John Hubbard
2026-08-20 10:39 ` Zhi Wang
2026-08-19 3:52 ` [PATCH 12/27] gpu: nova-core: gsp: add msgq v2 internals John Hubbard
2026-08-19 3:52 ` [PATCH 13/27] gpu: nova-core: generalize allocate_command() for variable headers John Hubbard
2026-08-20 12:47 ` Zhi Wang
2026-08-19 3:52 ` [PATCH 14/27] gpu: nova-core: add GMC API message types John Hubbard
2026-08-20 10:53 ` Zhi Wang
2026-08-19 3:52 ` [PATCH 15/27] gpu: nova-core: add GMC send path John Hubbard
2026-08-20 11:12 ` Zhi Wang
2026-08-19 3:52 ` [PATCH 16/27] gpu: nova-core: add GMC transport receive path John Hubbard
2026-08-20 12:00 ` Zhi Wang
2026-08-19 3:52 ` [PATCH 17/27] gpu: nova-core: gsp: add GMC dispatch on receive John Hubbard
2026-08-20 12:30 ` Zhi Wang
2026-08-19 3:52 ` [PATCH 18/27] gpu: nova-core: separate the generic falcon bootloader from FWSEC John Hubbard
2026-08-20 13:02 ` Zhi Wang
2026-08-19 3:52 ` [PATCH 19/27] gpu: nova-core: handle the r000 load-and-execute HS binary event John Hubbard
2026-08-19 3:52 ` [PATCH 20/27] gpu: nova-core: handle the r000 load-and-execute bootloader event John Hubbard
2026-08-20 16:24 ` Zhi Wang [this message]
2026-08-19 3:52 ` [PATCH 21/27] gpu: nova-core: gsp: add the GMC boot event dispatcher John Hubbard
2026-08-20 17:28 ` Zhi Wang
2026-08-19 3:52 ` [PATCH 22/27] gpu: nova-core: gsp: add the GSP_INIT request builder John Hubbard
2026-08-19 3:52 ` [PATCH 23/27] gpu: nova-core: gsp: send GSP_INIT and decode its reply John Hubbard
2026-08-19 3:52 ` [PATCH 24/27] gpu: nova-core: gsp: pass the remaining log buffers to GSP-RM John Hubbard
2026-08-19 3:52 ` [PATCH 25/27] gpu: nova-core: switch to the r000 GSP firmware John Hubbard
2026-08-19 18:58 ` Timur Tabi
2026-08-20 1:02 ` John Hubbard
2026-08-19 3:52 ` [PATCH 26/27] gpu: nova-core: gsp: remove the retired system-info and static-info RPCs John Hubbard
2026-08-19 3:52 ` [PATCH 27/27] gpu: nova-core: firmware: delete the r570 bindings John Hubbard
2026-08-19 19:25 ` [PATCH 00/27] gpu: nova-core: boot on the r000 GSP firmware Timur Tabi
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=20260820192415.4c9b9097@inno-dell \
--to=zhiw@nvidia.com \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=apopple@nvidia.com \
--cc=bhelgaas@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=ecourtney@nvidia.com \
--cc=gary@garyguo.net \
--cc=jhubbard@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=nova-gpu@lists.linux.dev \
--cc=ojeda@kernel.org \
--cc=simona@ffwll.ch \
--cc=tmgross@umich.edu \
--cc=ttabi@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