Skip to content

Commit b72cb7b

Browse files
ttabiGnurou
authored andcommitted
gpu: nova-core: add ImemNonSecure section infrastructure
The GSP booter firmware in Turing and GA100 includes a third memory section called ImemNonSecure, which is non-secure IMEM. This section must be loaded separately from DMEM and secure IMEM, but only if it actually exists. 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-3-ttabi@nvidia.com [acourbot@nvidia.com: add `debug_assert`.] Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
1 parent 0975002 commit b72cb7b

3 files changed

Lines changed: 32 additions & 2 deletions

File tree

drivers/gpu/nova-core/falcon.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ impl From<PeregrineCoreSelect> for bool {
242242
pub(crate) enum FalconMem {
243243
/// Secure Instruction Memory.
244244
ImemSecure,
245+
/// Non-Secure Instruction Memory.
246+
#[expect(unused)]
247+
ImemNonSecure,
245248
/// Data Memory.
246249
Dmem,
247250
}
@@ -351,6 +354,10 @@ pub(crate) trait FalconLoadParams {
351354
/// Returns the load parameters for Secure `IMEM`.
352355
fn imem_sec_load_params(&self) -> FalconLoadTarget;
353356

357+
/// Returns the load parameters for Non-Secure `IMEM`,
358+
/// used only on Turing and GA100.
359+
fn imem_ns_load_params(&self) -> Option<FalconLoadTarget>;
360+
354361
/// Returns the load parameters for `DMEM`.
355362
fn dmem_load_params(&self) -> FalconLoadTarget;
356363

@@ -460,7 +467,9 @@ impl<E: FalconEngine + 'static> Falcon<E> {
460467
//
461468
// For DMEM we can fold the start offset into the DMA handle.
462469
let (src_start, dma_start) = match target_mem {
463-
FalconMem::ImemSecure => (load_offsets.src_start, fw.dma_handle()),
470+
FalconMem::ImemSecure | FalconMem::ImemNonSecure => {
471+
(load_offsets.src_start, fw.dma_handle())
472+
}
464473
FalconMem::Dmem => (
465474
0,
466475
fw.dma_handle_with_offset(load_offsets.src_start.into_safe_cast())?,
@@ -517,7 +526,7 @@ impl<E: FalconEngine + 'static> Falcon<E> {
517526

518527
let cmd = regs::NV_PFALCON_FALCON_DMATRFCMD::default()
519528
.set_size(DmaTrfCmdSize::Size256B)
520-
.set_imem(target_mem == FalconMem::ImemSecure)
529+
.set_imem(target_mem != FalconMem::Dmem)
521530
.set_sec(if sec { 1 } else { 0 });
522531

523532
for pos in (0..num_transfers).map(|i| i * DMA_LEN) {
@@ -546,6 +555,13 @@ impl<E: FalconEngine + 'static> Falcon<E> {
546555

547556
/// Perform a DMA load into `IMEM` and `DMEM` of `fw`, and prepare the falcon to run it.
548557
pub(crate) fn dma_load<F: FalconFirmware<Target = E>>(&self, bar: &Bar0, fw: &F) -> Result {
558+
// The Non-Secure section only exists on firmware used by Turing and GA100, and
559+
// those platforms do not use DMA.
560+
if fw.imem_ns_load_params().is_some() {
561+
debug_assert!(false);
562+
return Err(EINVAL);
563+
}
564+
549565
self.dma_reset(bar);
550566
regs::NV_PFALCON_FBIF_TRANSCFG::update(bar, &E::ID, 0, |v| {
551567
v.set_target(FalconFbifTarget::CoherentSysmem)

drivers/gpu/nova-core/firmware/booter.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,9 @@ impl<'a> FirmwareSignature<BooterFirmware> for BooterSignature<'a> {}
253253
pub(crate) struct BooterFirmware {
254254
// Load parameters for Secure `IMEM` falcon memory.
255255
imem_sec_load_target: FalconLoadTarget,
256+
// Load parameters for Non-Secure `IMEM` falcon memory,
257+
// used only on Turing and GA100
258+
imem_ns_load_target: Option<FalconLoadTarget>,
256259
// Load parameters for `DMEM` falcon memory.
257260
dmem_load_target: FalconLoadTarget,
258261
// BROM falcon parameters.
@@ -359,6 +362,8 @@ impl BooterFirmware {
359362
dst_start: 0,
360363
len: app0.len,
361364
},
365+
// Exists only in the booter image for Turing and GA100
366+
imem_ns_load_target: None,
362367
dmem_load_target: FalconLoadTarget {
363368
src_start: load_hdr.os_data_offset,
364369
dst_start: 0,
@@ -375,6 +380,10 @@ impl FalconLoadParams for BooterFirmware {
375380
self.imem_sec_load_target.clone()
376381
}
377382

383+
fn imem_ns_load_params(&self) -> Option<FalconLoadTarget> {
384+
self.imem_ns_load_target.clone()
385+
}
386+
378387
fn dmem_load_params(&self) -> FalconLoadTarget {
379388
self.dmem_load_target.clone()
380389
}

drivers/gpu/nova-core/firmware/fwsec.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,11 @@ impl FalconLoadParams for FwsecFirmware {
232232
}
233233
}
234234

235+
fn imem_ns_load_params(&self) -> Option<FalconLoadTarget> {
236+
// Only used on Turing and GA100, so return None for now
237+
None
238+
}
239+
235240
fn dmem_load_params(&self) -> FalconLoadTarget {
236241
FalconLoadTarget {
237242
src_start: self.desc.imem_load_size,

0 commit comments

Comments
 (0)