Remove the separate `load` step for booting falcons. This `load` step
was always paired with `boot` right after. It is simpler to merge these
steps and also statically prevents trying to boot a falcon without
loading the firmware first.

Signed-off-by: Eliot Courtney <[email protected]>
---
 drivers/gpu/nova-core/falcon.rs                  | 9 +++++----
 drivers/gpu/nova-core/firmware/booter.rs         | 1 -
 drivers/gpu/nova-core/firmware/fwsec.rs          | 3 ---
 drivers/gpu/nova-core/firmware/gen_bootloader.rs | 1 -
 drivers/gpu/nova-core/gsp/hal/tu102.rs           | 1 -
 5 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/nova-core/falcon.rs b/drivers/gpu/nova-core/falcon.rs
index c2fdb9e0f123..0a375394f71a 100644
--- a/drivers/gpu/nova-core/falcon.rs
+++ b/drivers/gpu/nova-core/falcon.rs
@@ -577,9 +577,7 @@ fn load_dmem(&self, segment: &FalconDmemSegment<'_>) -> 
Result {
 
     /// Load a firmware image into Falcon memory, using the preferred method 
for the current
     /// chipset.
-    pub(crate) fn load<F: FalconFirmware<Target = E>>(&self, fw: &F) -> Result 
{
-        let image = fw.image()?;
-
+    fn load(&self, image: &FalconImage<'_>) -> Result {
         self.dma_reset();
 
         if let Some(segment) = &image.imem_ns {
@@ -649,7 +647,7 @@ pub(crate) fn read_mailboxes(&self) -> (u32, u32) {
         (mbox0, mbox1)
     }
 
-    /// Start running `fw`, which must already be loaded into the falcon.
+    /// Load `fw` into the falcon and start running it.
     ///
     /// `mbox0` and `mbox1` are optional parameters to write into the `MBOX0` 
and `MBOX1` registers
     /// prior to running.
@@ -662,6 +660,9 @@ pub(crate) fn boot<F: FalconFirmware<Target = E>>(
         mbox0: Option<u32>,
         mbox1: Option<u32>,
     ) -> Result<(u32, u32)> {
+        fw.image()
+            .and_then(|image| self.load(&image))
+            .inspect_err(|e| dev_err!(self.dev, "Failed to load falcon 
firmware: {:?}\n", e))?;
         self.hal.program_brom(self, &fw.brom_params());
         self.pfalcon
             
.write_reg(regs::NV_PFALCON_FALCON_BOOTVEC::zeroed().with_value(fw.boot_addr()));
diff --git a/drivers/gpu/nova-core/firmware/booter.rs 
b/drivers/gpu/nova-core/firmware/booter.rs
index 159d647e4293..20935e4de9d1 100644
--- a/drivers/gpu/nova-core/firmware/booter.rs
+++ b/drivers/gpu/nova-core/firmware/booter.rs
@@ -187,7 +187,6 @@ pub(crate) fn run<T>(
         wpr_meta: &Coherent<'_, T>,
     ) -> Result {
         sec2_falcon.reset()?;
-        sec2_falcon.load(self)?;
         let wpr_dma_address = wpr_meta.dma_address();
         let (mbox0, mbox1) = sec2_falcon.boot(
             self,
diff --git a/drivers/gpu/nova-core/firmware/fwsec.rs 
b/drivers/gpu/nova-core/firmware/fwsec.rs
index 143f79a559ee..e267ed77d158 100644
--- a/drivers/gpu/nova-core/firmware/fwsec.rs
+++ b/drivers/gpu/nova-core/firmware/fwsec.rs
@@ -402,9 +402,6 @@ pub(crate) fn run(&self, dev: &Device<device::Bound>, 
falcon: &Falcon<'_, Gsp>)
         falcon
             .reset()
             .inspect_err(|e| dev_err!(dev, "Failed to reset GSP falcon: 
{:?}\n", e))?;
-        falcon
-            .load(self)
-            .inspect_err(|e| dev_err!(dev, "Failed to load FWSEC firmware: 
{:?}\n", e))?;
         let (mbox0, _) = falcon
             .boot(self, Some(0), None)
             .inspect_err(|e| dev_err!(dev, "Failed to boot FWSEC firmware: 
{:?}\n", e))?;
diff --git a/drivers/gpu/nova-core/firmware/gen_bootloader.rs 
b/drivers/gpu/nova-core/firmware/gen_bootloader.rs
index 1095b8acfa78..a598eb451665 100644
--- a/drivers/gpu/nova-core/firmware/gen_bootloader.rs
+++ b/drivers/gpu/nova-core/firmware/gen_bootloader.rs
@@ -221,7 +221,6 @@ pub(crate) fn run(
                     dmem_desc,
                 };
 
-                falcon.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 80936194806a..2c95d178b020 100644
--- a/drivers/gpu/nova-core/gsp/hal/tu102.rs
+++ b/drivers/gpu/nova-core/gsp/hal/tu102.rs
@@ -97,7 +97,6 @@ fn run(&self, ctx: &mut GspBootContext<'_, '_>) -> Result {
             }
 
             ctx.sec2_falcon.reset()?;
-            ctx.sec2_falcon.load(&self.booter_unloader)?;
 
             // Sentinel value to confirm that Booter Unloader has run.
             const MAILBOX_SENTINEL: u32 = 0xff;

-- 
2.56.1

Reply via email to