NVIDIA GPU driver infrastructure
 help / color / mirror / Atom feed
* [PATCH] gpu: nova-core: falcon: make pfalcon field private
@ 2026-11-18 10:55 Deepak Pandey
  0 siblings, 0 replies; only message in thread
From: Deepak Pandey @ 2026-11-18 10:55 UTC (permalink / raw)
  To: Danilo Krummrich, Alexandre Courbot
  Cc: nova-gpu, rust-for-linux, Deepak Pandey

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`.

Signed-off-by: Deepak Pandey <deepak.os.system@gmail.com>
---
 drivers/gpu/nova-core/falcon.rs               | 27 ++++++++++++++-----
 .../nova-core/firmware/fwsec/bootloader.rs    | 18 ++++---------
 2 files changed, 25 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/nova-core/falcon.rs b/drivers/gpu/nova-core/falcon.rs
index 9015de965a53..507f638e8936 100644
--- a/drivers/gpu/nova-core/falcon.rs
+++ b/drivers/gpu/nova-core/falcon.rs
@@ -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())?;
diff --git a/drivers/gpu/nova-core/firmware/fwsec/bootloader.rs b/drivers/gpu/nova-core/firmware/fwsec/bootloader.rs
index a87878fe2aec..db1cb4498acd 100644
--- a/drivers/gpu/nova-core/firmware/fwsec/bootloader.rs
+++ b/drivers/gpu/nova-core/firmware/fwsec/bootloader.rs
@@ -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)
-- 
2.56.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-18 10:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 10:55 [PATCH] gpu: nova-core: falcon: make pfalcon field private Deepak Pandey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox