mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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>,
	 nova-gpu@lists.linux.dev, dri-devel@lists.freedesktop.org,
	 linux-kernel@vger.kernel.org,
	Eliot Courtney <ecourtney@nvidia.com>
Subject: [PATCH 3/7] gpu: nova-core: falcon: program BROM and BOOTVEC in `boot`
Date: Thu, 26 Nov 2026 17:20:12 +0900	[thread overview]
Message-ID: <20261126-boot-rework2-v1-3-99a1dc6c7cc4@nvidia.com> (raw)
In-Reply-To: <20261126-boot-rework2-v1-0-99a1dc6c7cc4@nvidia.com>

Move the programming of BROM and BOOTVEC into `boot`. This is in
preparation to merge the `load` and `boot` calls in `Falcon`. To do this
requires passing the firmware to program to `boot`. A later change will
make the `load` related functions private and have `boot` call them.

Signed-off-by: Eliot Courtney <ecourtney@nvidia.com>
---
 drivers/gpu/nova-core/falcon.rs                  | 35 ++++++++++--------------
 drivers/gpu/nova-core/firmware/booter.rs         |  1 +
 drivers/gpu/nova-core/firmware/fwsec.rs          |  2 +-
 drivers/gpu/nova-core/firmware/gen_bootloader.rs |  7 +++--
 drivers/gpu/nova-core/gsp/hal/tu102.rs           |  8 ++++--
 5 files changed, 25 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/nova-core/falcon.rs b/drivers/gpu/nova-core/falcon.rs
index 8bcc9240d1bd..7dfe71e4cd49 100644
--- a/drivers/gpu/nova-core/falcon.rs
+++ b/drivers/gpu/nova-core/falcon.rs
@@ -494,7 +494,7 @@ fn pio_wr_dmem_slice(&self, load_offsets: FalconPioDmemLoadTarget<'_>) -> Result
         Ok(())
     }
 
-    /// Perform a PIO copy into `IMEM` and `DMEM` of `fw`, and prepare the falcon to run it.
+    /// Perform a PIO copy into `IMEM` and `DMEM` of `fw`.
     pub(crate) fn pio_load<F: FalconFirmware<Target = E> + FalconPioLoadable>(
         &self,
         fw: &F,
@@ -512,14 +512,7 @@ pub(crate) fn pio_load<F: FalconFirmware<Target = E> + FalconPioLoadable>(
         if let Some(imem_sec) = fw.imem_sec_load_params() {
             self.pio_wr_imem_slice(imem_sec)?;
         }
-        self.pio_wr_dmem_slice(fw.dmem_load_params())?;
-
-        self.hal.program_brom(self, &fw.brom_params());
-
-        self.pfalcon
-            .write_reg(regs::NV_PFALCON_FALCON_BOOTVEC::zeroed().with_value(fw.boot_addr()));
-
-        Ok(())
+        self.pio_wr_dmem_slice(fw.dmem_load_params())
     }
 
     /// Programs FBIF context DMA slot `ctx_dma` with the value that `configure` returns, runs `f`,
@@ -641,7 +634,7 @@ fn dma_wr(
         Ok(())
     }
 
-    /// Perform a DMA load into `IMEM` and `DMEM` of `fw`, and prepare the falcon to run it.
+    /// Perform a DMA load into `IMEM` and `DMEM` of `fw`.
     fn dma_load<F: FalconFirmware<Target = E> + FalconDmaLoadable>(&self, fw: &F) -> Result {
         // DMA object with firmware content as the source of the DMA engine.
         let dma_obj = {
@@ -673,15 +666,7 @@ fn dma_load<F: FalconFirmware<Target = E> + FalconDmaLoadable>(&self, fw: &F) ->
             FalconDmaSource::Sysmem(&dma_obj),
             FalconMem::Dmem { tag: false },
             fw.dmem_load_params(),
-        )?;
-
-        self.hal.program_brom(self, &fw.brom_params());
-
-        // Set `BootVec` to start of non-secure code.
-        self.pfalcon
-            .write_reg(regs::NV_PFALCON_FALCON_BOOTVEC::zeroed().with_value(fw.boot_addr()));
-
-        Ok(())
+        )
     }
 
     /// Wait until the falcon CPU is halted.
@@ -742,14 +727,22 @@ pub(crate) fn read_mailboxes(&self) -> (u32, u32) {
         (mbox0, mbox1)
     }
 
-    /// Start running the loaded firmware.
+    /// Start running `fw`, which must already be loaded into the falcon.
     ///
     /// `mbox0` and `mbox1` are optional parameters to write into the `MBOX0` and `MBOX1` registers
     /// prior to running.
     ///
     /// Wait up to two seconds for the firmware to complete, and return its exit status read from
     /// the `MBOX0` and `MBOX1` registers.
-    pub(crate) fn boot(&self, mbox0: Option<u32>, mbox1: Option<u32>) -> Result<(u32, u32)> {
+    pub(crate) fn boot<F: FalconFirmware<Target = E>>(
+        &self,
+        fw: &F,
+        mbox0: Option<u32>,
+        mbox1: Option<u32>,
+    ) -> Result<(u32, u32)> {
+        self.hal.program_brom(self, &fw.brom_params());
+        self.pfalcon
+            .write_reg(regs::NV_PFALCON_FALCON_BOOTVEC::zeroed().with_value(fw.boot_addr()));
         self.write_mailboxes(mbox0, mbox1);
         self.start()?;
         self.wait_till_halted()?;
diff --git a/drivers/gpu/nova-core/firmware/booter.rs b/drivers/gpu/nova-core/firmware/booter.rs
index aa4458bb3312..a52c965093c9 100644
--- a/drivers/gpu/nova-core/firmware/booter.rs
+++ b/drivers/gpu/nova-core/firmware/booter.rs
@@ -192,6 +192,7 @@ pub(crate) fn run<T>(
         sec2_falcon.load(self)?;
         let wpr_dma_address = wpr_meta.dma_address();
         let (mbox0, mbox1) = sec2_falcon.boot(
+            self,
             Some(wpr_dma_address as u32),
             Some((wpr_dma_address >> 32) as u32),
         )?;
diff --git a/drivers/gpu/nova-core/firmware/fwsec.rs b/drivers/gpu/nova-core/firmware/fwsec.rs
index 7a931f22f629..45b088f30b76 100644
--- a/drivers/gpu/nova-core/firmware/fwsec.rs
+++ b/drivers/gpu/nova-core/firmware/fwsec.rs
@@ -396,7 +396,7 @@ pub(crate) fn run(&self, dev: &Device<device::Bound>, falcon: &Falcon<'_, Gsp>)
             .load(self)
             .inspect_err(|e| dev_err!(dev, "Failed to load FWSEC firmware: {:?}\n", e))?;
         let (mbox0, _) = falcon
-            .boot(Some(0), None)
+            .boot(self, Some(0), None)
             .inspect_err(|e| dev_err!(dev, "Failed to boot FWSEC firmware: {:?}\n", e))?;
         if mbox0 != 0 {
             dev_err!(dev, "FWSEC firmware returned error {}\n", mbox0);
diff --git a/drivers/gpu/nova-core/firmware/gen_bootloader.rs b/drivers/gpu/nova-core/firmware/gen_bootloader.rs
index 751335c97e35..cfc1b99c015c 100644
--- a/drivers/gpu/nova-core/firmware/gen_bootloader.rs
+++ b/drivers/gpu/nova-core/firmware/gen_bootloader.rs
@@ -223,13 +223,14 @@ pub(crate) fn run(
                     .with_mem_type(FalconFbifMemType::Physical)
             },
             || {
-                falcon.pio_load(&GenericBootloaderLoad {
+                let fw = GenericBootloaderLoad {
                     bootloader: self,
                     imem_dst_start,
                     dmem_desc,
-                })?;
+                };
 
-                falcon.boot(Some(mbox0), None)
+                falcon.pio_load(&fw)?;
+                falcon.boot(&fw, Some(mbox0), None)
             },
         )
     }
diff --git a/drivers/gpu/nova-core/gsp/hal/tu102.rs b/drivers/gpu/nova-core/gsp/hal/tu102.rs
index 2139279d40c4..80936194806a 100644
--- a/drivers/gpu/nova-core/gsp/hal/tu102.rs
+++ b/drivers/gpu/nova-core/gsp/hal/tu102.rs
@@ -101,9 +101,11 @@ fn run(&self, ctx: &mut GspBootContext<'_, '_>) -> Result {
 
             // Sentinel value to confirm that Booter Unloader has run.
             const MAILBOX_SENTINEL: u32 = 0xff;
-            let (mbox0, _) = ctx
-                .sec2_falcon
-                .boot(Some(MAILBOX_SENTINEL), Some(MAILBOX_SENTINEL))?;
+            let (mbox0, _) = ctx.sec2_falcon.boot(
+                &self.booter_unloader,
+                Some(MAILBOX_SENTINEL),
+                Some(MAILBOX_SENTINEL),
+            )?;
             if mbox0 != 0 {
                 dev_err!(dev, "Booter Unloader returned error 0x{:x}\n", mbox0);
                 return Err(EINVAL);

-- 
2.56.1


  parent reply	other threads:[~2026-11-26  8:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  8:20 [PATCH 0/7] gpu: nova-core: merge `load` and `boot` for falcons Eliot Courtney
2026-11-26  8:20 ` [PATCH 1/7] gpu: nova-core: falcon: make pfalcon private Eliot Courtney
2026-11-26  8:20 ` [PATCH 2/7] gpu: nova-core: gsp: remove unnecessary start of `gsp_falcon` Eliot Courtney
2026-11-26  8:20 ` Eliot Courtney [this message]
2026-11-26  8:20 ` [PATCH 4/7] gpu: nova-core: falcon: separate staging data for DMA from its location Eliot Courtney
2026-11-26  8:20 ` [PATCH 5/7] gpu: nova-core: falcon: add `FalconImage` for `FalconFirmware` trait Eliot Courtney
2026-11-26  8:20 ` [PATCH 6/7] gpu: nova-core: falcon: rename FalconDmaLoadTarget to FalconLoadTarget Eliot Courtney
2026-11-26  8:20 ` [PATCH 7/7] gpu: nova-core: falcon: load the firmware image in Falcon::boot Eliot Courtney

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=20261126-boot-rework2-v1-3-99a1dc6c7cc4@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 \
    /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®