Re: [PATCH v2 07/12] gpu: nova-core: falcon: introduce and use with_fbif_transcfg

From: Eliot Courtney

Date: Mon Nov 09 2026 - 00:36:44 EST


On Sat Nov 7, 2026 at 6:48 PM JST, Alexandre Courbot wrote:
> From: John Hubbard <jhubbard@xxxxxxxxxx>
>
> The generic bootloader programs the FBIF aperture of its context DMA
> slot and leaves it set after the bootloader has run. The r000
> load-and-execute events will need to do the same with apertures that
> GSP-RM chooses, and should not leave them behind.
>
> Add a falcon method that programs an FBIF context DMA slot, runs a
> closure, and restores the slot's previous value once the closure has
> succeeded, and use it to run the generic bootloader. The slot used by
> FWSEC is now restored after FWSEC has halted.
>
> Signed-off-by: John Hubbard <jhubbard@xxxxxxxxxx>
> [acourbot: extract from later patch of the r000 series, convert unneeded
> call to `update` into a `write`, only check the validity of the DMA
> context once.]
> Co-developed-by: Alexandre Courbot <acourbot@xxxxxxxxxx>
> Signed-off-by: Alexandre Courbot <acourbot@xxxxxxxxxx>
> ---
> drivers/gpu/nova-core/falcon.rs | 30 ++++++++++++++++++++++++
> drivers/gpu/nova-core/firmware/gen_bootloader.rs | 28 +++++++++-------------
> 2 files changed, 41 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/gpu/nova-core/falcon.rs b/drivers/gpu/nova-core/falcon.rs
> index b17a997860ef..ad497a5704ec 100644
> --- a/drivers/gpu/nova-core/falcon.rs
> +++ b/drivers/gpu/nova-core/falcon.rs
> @@ -513,6 +513,36 @@ pub(crate) fn pio_load<F: FalconFirmware<Target = E> + FalconPioLoadable>(
> Ok(())
> }
>
> + /// Programs FBIF context DMA slot `ctx_dma` with the value that `configure` returns, runs `f`,
> + /// and restores the slot once `f` has returned `Ok`.
> + ///
> + /// The slot keeps the programmed value if `f` fails, since a falcon that `f` started and that
> + /// has not halted may still be reading through the aperture.
> + ///
> + /// # Errors
> + ///
> + /// - `EINVAL` if `ctx_dma` is not a context DMA slot that the falcon has.
> + ///
> + /// Errors from `f` are propagated as-is.
> + pub(crate) fn with_fbif_transcfg<R>(
> + &self,
> + ctx_dma: u32,
> + configure: impl FnOnce(regs::NV_PFALCON_FBIF_TRANSCFG) -> regs::NV_PFALCON_FBIF_TRANSCFG,
> + f: impl FnOnce() -> Result<R>,
> + ) -> Result<R> {
> + let transcfg =
> + regs::NV_PFALCON_FBIF_TRANSCFG::try_at(usize::from_safe_cast(ctx_dma)).ok_or(EINVAL)?;
> +
> + let saved = self.pfalcon.read(transcfg);
> + self.pfalcon.update(transcfg, configure);

optional nit: this performs an extra read of the register (can just call
`configure` on `saved`)

Reviewed-by: Eliot Courtney <ecourtney@xxxxxxxxxx>