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 <[email protected]> --- 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
