Commit f6507640 authored by Timur Tabi's avatar Timur Tabi Committed by Alexandre Courbot
Browse files

gpu: nova-core: add NV_PFALCON_FALCON_DMATRFCMD::with_falcon_mem()



The with_falcon_mem() method initializes the 'imem' and 'sec' fields of
the NV_PFALCON_FALCON_DMATRFCMD register based on the value of
the FalconMem type.

Signed-off-by: default avatarTimur Tabi <ttabi@nvidia.com>
Reviewed-by: default avatarJohn Hubbard <jhubbard@nvidia.com>
Reviewed-by: default avatarGary Guo <gary@garyguo.net>
Acked-by: default avatarDanilo Krummrich <dakr@kernel.org>
Link: https://patch.msgid.link/20260122222848.2555890-6-ttabi@nvidia.com


Signed-off-by: default avatarAlexandre Courbot <acourbot@nvidia.com>
parent 121ea04c
Loading
Loading
Loading
Loading
+3 −11
Original line number Diff line number Diff line
@@ -458,7 +458,6 @@ fn dma_wr<F: FalconFirmware<Target = E>>(
        fw: &F,
        target_mem: FalconMem,
        load_offsets: FalconLoadTarget,
        sec: bool,
    ) -> Result {
        const DMA_LEN: u32 = 256;

@@ -526,8 +525,7 @@ fn dma_wr<F: FalconFirmware<Target = E>>(

        let cmd = regs::NV_PFALCON_FALCON_DMATRFCMD::default()
            .set_size(DmaTrfCmdSize::Size256B)
            .set_imem(target_mem != FalconMem::Dmem)
            .set_sec(if sec { 1 } else { 0 });
            .with_falcon_mem(target_mem);

        for pos in (0..num_transfers).map(|i| i * DMA_LEN) {
            // Perform a transfer of size `DMA_LEN`.
@@ -568,14 +566,8 @@ pub(crate) fn dma_load<F: FalconFirmware<Target = E>>(&self, bar: &Bar0, fw: &F)
                .set_mem_type(FalconFbifMemType::Physical)
        });

        self.dma_wr(
            bar,
            fw,
            FalconMem::ImemSecure,
            fw.imem_sec_load_params(),
            true,
        )?;
        self.dma_wr(bar, fw, FalconMem::Dmem, fw.dmem_load_params(), true)?;
        self.dma_wr(bar, fw, FalconMem::ImemSecure, fw.imem_sec_load_params())?;
        self.dma_wr(bar, fw, FalconMem::Dmem, fw.dmem_load_params())?;

        self.hal.program_brom(self, bar, &fw.brom_params())?;

+9 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
        FalconCoreRevSubversion,
        FalconFbifMemType,
        FalconFbifTarget,
        FalconMem,
        FalconModSelAlgo,
        FalconSecurityModel,
        PFalcon2Base,
@@ -325,6 +326,14 @@ pub(crate) fn mem_scrubbing_done(self) -> bool {
    16:16   set_dmtag as u8;
});

impl NV_PFALCON_FALCON_DMATRFCMD {
    /// Programs the `imem` and `sec` fields for the given FalconMem
    pub(crate) fn with_falcon_mem(self, mem: FalconMem) -> Self {
        self.set_imem(mem != FalconMem::Dmem)
            .set_sec(if mem == FalconMem::ImemSecure { 1 } else { 0 })
    }
}

register!(NV_PFALCON_FALCON_DMATRFFBOFFS @ PFalconBase[0x0000011c] {
    31:0    offs as u32;
});