Skip to content

Commit f650764

Browse files
ttabiGnurou
authored andcommitted
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: Timur Tabi <ttabi@nvidia.com> Reviewed-by: John Hubbard <jhubbard@nvidia.com> Reviewed-by: Gary Guo <gary@garyguo.net> Acked-by: Danilo Krummrich <dakr@kernel.org> Link: https://patch.msgid.link/20260122222848.2555890-6-ttabi@nvidia.com Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
1 parent 121ea04 commit f650764

2 files changed

Lines changed: 12 additions & 11 deletions

File tree

drivers/gpu/nova-core/falcon.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,6 @@ impl<E: FalconEngine + 'static> Falcon<E> {
458458
fw: &F,
459459
target_mem: FalconMem,
460460
load_offsets: FalconLoadTarget,
461-
sec: bool,
462461
) -> Result {
463462
const DMA_LEN: u32 = 256;
464463

@@ -526,8 +525,7 @@ impl<E: FalconEngine + 'static> Falcon<E> {
526525

527526
let cmd = regs::NV_PFALCON_FALCON_DMATRFCMD::default()
528527
.set_size(DmaTrfCmdSize::Size256B)
529-
.set_imem(target_mem != FalconMem::Dmem)
530-
.set_sec(if sec { 1 } else { 0 });
528+
.with_falcon_mem(target_mem);
531529

532530
for pos in (0..num_transfers).map(|i| i * DMA_LEN) {
533531
// Perform a transfer of size `DMA_LEN`.
@@ -568,14 +566,8 @@ impl<E: FalconEngine + 'static> Falcon<E> {
568566
.set_mem_type(FalconFbifMemType::Physical)
569567
});
570568

571-
self.dma_wr(
572-
bar,
573-
fw,
574-
FalconMem::ImemSecure,
575-
fw.imem_sec_load_params(),
576-
true,
577-
)?;
578-
self.dma_wr(bar, fw, FalconMem::Dmem, fw.dmem_load_params(), true)?;
569+
self.dma_wr(bar, fw, FalconMem::ImemSecure, fw.imem_sec_load_params())?;
570+
self.dma_wr(bar, fw, FalconMem::Dmem, fw.dmem_load_params())?;
579571

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

drivers/gpu/nova-core/regs.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use crate::{
1616
FalconCoreRevSubversion,
1717
FalconFbifMemType,
1818
FalconFbifTarget,
19+
FalconMem,
1920
FalconModSelAlgo,
2021
FalconSecurityModel,
2122
PFalcon2Base,
@@ -325,6 +326,14 @@ register!(NV_PFALCON_FALCON_DMATRFCMD @ PFalconBase[0x00000118] {
325326
16:16 set_dmtag as u8;
326327
});
327328

329+
impl NV_PFALCON_FALCON_DMATRFCMD {
330+
/// Programs the `imem` and `sec` fields for the given FalconMem
331+
pub(crate) fn with_falcon_mem(self, mem: FalconMem) -> Self {
332+
self.set_imem(mem != FalconMem::Dmem)
333+
.set_sec(if mem == FalconMem::ImemSecure { 1 } else { 0 })
334+
}
335+
}
336+
328337
register!(NV_PFALCON_FALCON_DMATRFFBOFFS @ PFalconBase[0x0000011c] {
329338
31:0 offs as u32;
330339
});

0 commit comments

Comments
 (0)