Skip to content

Commit ab2aad2

Browse files
ttabiGnurou
authored andcommitted
gpu: nova-core: add Falcon HAL method load_method()
Some GPUs do not support using DMA to transfer code/data from system memory to Falcon memory, and instead must use programmed I/O (PIO). Add a function to the Falcon HAL to indicate whether a given GPU's Falcons support DMA for this purpose. Signed-off-by: Timur Tabi <ttabi@nvidia.com> Reviewed-by: Gary Guo <gary@garyguo.net> Acked-by: Danilo Krummrich <dakr@kernel.org> Link: https://patch.msgid.link/20260122222848.2555890-10-ttabi@nvidia.com [acourbot@nvidia.com: add short code to call into the HAL.] [acourbot@nvidia.com: make `dma_load` private as per feedback.] Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
1 parent a75718a commit ab2aad2

6 files changed

Lines changed: 34 additions & 3 deletions

File tree

drivers/gpu/nova-core/falcon.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use kernel::{
2323
use crate::{
2424
dma::DmaObject,
2525
driver::Bar0,
26+
falcon::hal::LoadMethod,
2627
gpu::Chipset,
2728
num::{
2829
FromSafeCast,
@@ -514,7 +515,7 @@ impl<E: FalconEngine + 'static> Falcon<E> {
514515
}
515516

516517
/// Perform a DMA load into `IMEM` and `DMEM` of `fw`, and prepare the falcon to run it.
517-
pub(crate) fn dma_load<F: FalconFirmware<Target = E>>(&self, bar: &Bar0, fw: &F) -> Result {
518+
fn dma_load<F: FalconFirmware<Target = E>>(&self, bar: &Bar0, fw: &F) -> Result {
518519
// The Non-Secure section only exists on firmware used by Turing and GA100, and
519520
// those platforms do not use DMA.
520521
if fw.imem_ns_load_params().is_some() {
@@ -639,6 +640,14 @@ impl<E: FalconEngine + 'static> Falcon<E> {
639640
self.hal.is_riscv_active(bar)
640641
}
641642

643+
// Load a firmware image into Falcon memory
644+
pub(crate) fn load<F: FalconFirmware<Target = E>>(&self, bar: &Bar0, fw: &F) -> Result {
645+
match self.hal.load_method() {
646+
LoadMethod::Dma => self.dma_load(bar, fw),
647+
LoadMethod::Pio => Err(ENOTSUPP),
648+
}
649+
}
650+
642651
/// Write the application version to the OS register.
643652
pub(crate) fn write_os_version(&self, bar: &Bar0, app_version: u32) {
644653
regs::NV_PFALCON_FALCON_OS::default()

drivers/gpu/nova-core/falcon/hal.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ use crate::{
1515
mod ga102;
1616
mod tu102;
1717

18+
/// Method used to load data into falcon memory. Some GPU architectures need
19+
/// PIO and others can use DMA.
20+
pub(crate) enum LoadMethod {
21+
/// Programmed I/O
22+
Pio,
23+
/// Direct Memory Access
24+
Dma,
25+
}
26+
1827
/// Hardware Abstraction Layer for Falcon cores.
1928
///
2029
/// Implements chipset-specific low-level operations. The trait is generic against [`FalconEngine`]
@@ -48,6 +57,9 @@ pub(crate) trait FalconHal<E: FalconEngine>: Send + Sync {
4857

4958
/// Reset the falcon engine.
5059
fn reset_eng(&self, bar: &Bar0) -> Result;
60+
61+
/// returns the method needed to load data into Falcon memory
62+
fn load_method(&self) -> LoadMethod;
5163
}
5264

5365
/// Returns a boxed falcon HAL adequate for `chipset`.

drivers/gpu/nova-core/falcon/hal/ga102.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use kernel::{
1212
use crate::{
1313
driver::Bar0,
1414
falcon::{
15+
hal::LoadMethod,
1516
Falcon,
1617
FalconBromParams,
1718
FalconEngine,
@@ -151,4 +152,8 @@ impl<E: FalconEngine> FalconHal<E> for Ga102<E> {
151152

152153
Ok(())
153154
}
155+
156+
fn load_method(&self) -> LoadMethod {
157+
LoadMethod::Dma
158+
}
154159
}

drivers/gpu/nova-core/falcon/hal/tu102.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use kernel::{
1111
use crate::{
1212
driver::Bar0,
1313
falcon::{
14+
hal::LoadMethod,
1415
Falcon,
1516
FalconBromParams,
1617
FalconEngine, //
@@ -69,4 +70,8 @@ impl<E: FalconEngine> FalconHal<E> for Tu102<E> {
6970

7071
Ok(())
7172
}
73+
74+
fn load_method(&self) -> LoadMethod {
75+
LoadMethod::Pio
76+
}
7277
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ impl FwsecFirmware {
428428
.reset(bar)
429429
.inspect_err(|e| dev_err!(dev, "Failed to reset GSP falcon: {:?}\n", e))?;
430430
falcon
431-
.dma_load(bar, self)
431+
.load(bar, self)
432432
.inspect_err(|e| dev_err!(dev, "Failed to load FWSEC firmware: {:?}\n", e))?;
433433
let (mbox0, _) = falcon
434434
.boot(bar, Some(0), None)

drivers/gpu/nova-core/gsp/boot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl super::Gsp {
183183
);
184184

185185
sec2_falcon.reset(bar)?;
186-
sec2_falcon.dma_load(bar, &booter_loader)?;
186+
sec2_falcon.load(bar, &booter_loader)?;
187187
let wpr_handle = wpr_meta.dma_handle();
188188
let (mbox0, mbox1) = sec2_falcon.boot(
189189
bar,

0 commit comments

Comments
 (0)