Skip to contentSkip to conversation

gpu: nova-core: falcon: make pfalcon field private

PATCH New Deepak Pandey 1 participant 1 message Nov 18

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpu: nova-core: falcon: make pfalcon field private

Currently, Falcon::pfalcon is marked as pub(crate) with a TODO: make private comment. The only use of pfalcon outside of the falcon module hierarchy is in fwsec::bootloader, which updates the FBIF transaction configuration register (NV_PFALCON_FBIF_TRANSCFG) during firmware DMA setup.

Introduce a dedicated helper method Falcon::set_fbif_transcfg() to encapsulate configuring FBIF transaction parameters for a DMA context, use it in Falcon::dma_load() and fwsec::bootloader, and make pfalcon private. In addition, clean up unused register and I/O imports in bootloader.rs.

---
 drivers/gpu/nova-core/falcon.rs               | 27 ++++++++++++++-----
 .../nova-core/firmware/fwsec/bootloader.rs    | 18 ++++---------
 2 files changed, 25 insertions(+), 20 deletions(-)
drivers/gpu/nova-core/falcon.rs +20 -7
index 9015de965a53..507f638e8936 100644
@@ -364,8 +364,7 @@ pub(crate) struct Falcon<'a, E: FalconEngine> {
     hal: KBox<dyn FalconHal<E>>,
     dev: &'a device::Device<device::Bound>,
     bar: Bar0<'a>,
-    // TODO: make private
-    pub(crate) pfalcon: Mmio<'a, PFalconRegisters>,
+    pfalcon: Mmio<'a, PFalconRegisters>,
     pfalcon2: Mmio<'a, PFalcon2Registers>,
 }
 
@@ -395,6 +394,24 @@ pub(crate) fn dma_reset(&self) {
             .write_reg(regs::NV_PFALCON_FALCON_DMACTL::zeroed());
     }
 
+    /// Configures FBIF transaction parameters for a DMA context.
+    pub(crate) fn set_fbif_transcfg(
+        &self,
+        ctx_dma: usize,
+        target: FalconFbifTarget,
+        mem_type: FalconFbifMemType,
+    ) -> Result {
+        self.pfalcon.update(
+            regs::NV_PFALCON_FBIF_TRANSCFG::try_at(ctx_dma).ok_or(EINVAL)?,
+            |v| {
+                v.with_target(target)
+                    .with_mem_type(mem_type)
+            },
+        );
+
+        Ok(())
+    }
+
     /// Reset the controller, select the falcon core, and wait for memory scrubbing to complete.
     pub(crate) fn reset(&self) -> Result {
         self.hal.reset_eng(self)?;
@@ -614,11 +631,7 @@ fn dma_load<F: FalconFirmware<Target = E> + FalconDmaLoadable>(&self, fw: &F) ->
         };
 
         self.dma_reset();
-        self.pfalcon
-            .update(regs::NV_PFALCON_FBIF_TRANSCFG::at(0), |v| {
-                v.with_target(FalconFbifTarget::CoherentSysmem)
-                    .with_mem_type(FalconFbifMemType::Physical)
-            });
+        self.set_fbif_transcfg(0, FalconFbifTarget::CoherentSysmem, FalconFbifMemType::Physical)?;
 
         self.dma_wr(&dma_obj, FalconMem::ImemSecure, fw.imem_sec_load_params())?;
         self.dma_wr(&dma_obj, FalconMem::Dmem, fw.dmem_load_params())?;
drivers/gpu/nova-core/firmware/fwsec/bootloader.rs +5 -13
index a87878fe2aec..db1cb4498acd 100644
@@ -12,10 +12,6 @@
         Device, //
     },
     dma::Coherent,
-    io::{
-        register::Array,
-        Io, //
-    },
     prelude::*,
     ptr::{
         Alignable,
@@ -48,7 +44,6 @@
     },
     gpu::Chipset,
     num::FromSafeCast, //
-    regs,
 };
 
 /// Structure used by the boot-loader to load the rest of the code.
@@ -247,14 +242,11 @@ pub(crate) fn run(&self, dev: &Device<device::Bound>, falcon: &Falcon<'_, Gsp>)
             .inspect_err(|e| dev_err!(dev, "Failed to load FWSEC firmware: {:?}\n", e))?;
 
         // Configure DMA index for the bootloader to fetch the FWSEC firmware from system memory.
-        falcon.pfalcon.update(
-            regs::NV_PFALCON_FBIF_TRANSCFG::try_at(usize::from_safe_cast(self.dmem_desc.ctx_dma))
-                .ok_or(EINVAL)?,
-            |v| {
-                v.with_target(FalconFbifTarget::CoherentSysmem)
-                    .with_mem_type(FalconFbifMemType::Physical)
-            },
-        );
+        falcon.set_fbif_transcfg(
+            usize::from_safe_cast(self.dmem_desc.ctx_dma),
+            FalconFbifTarget::CoherentSysmem,
+            FalconFbifMemType::Physical,
+        )?;
 
         let (mbox0, _) = falcon
             .boot(Some(0), None)
Signature · 1 line
2.56.1