Skip to content

Commit 954b38f

Browse files
ttabiGnurou
authored andcommitted
gpu: nova-core: Add basic Turing HAL
Add the basic HAL for recognizing Turing GPUs. This isn't enough to support booting GSP-RM on Turing, but it's a start. Note that GA100, which boots using the same method as Turing, is not supported yet. 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-8-ttabi@nvidia.com Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
1 parent 82ed324 commit 954b38f

3 files changed

Lines changed: 97 additions & 0 deletions

File tree

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use crate::{
1313
};
1414

1515
mod ga102;
16+
mod tu102;
1617

1718
/// Hardware Abstraction Layer for Falcon cores.
1819
///
@@ -60,6 +61,9 @@ pub(super) fn falcon_hal<E: FalconEngine + 'static>(
6061
use Chipset::*;
6162

6263
let hal = match chipset {
64+
TU102 | TU104 | TU106 | TU116 | TU117 => {
65+
KBox::new(tu102::Tu102::<E>::new(), GFP_KERNEL)? as KBox<dyn FalconHal<E>>
66+
}
6367
GA102 | GA103 | GA104 | GA106 | GA107 | AD102 | AD103 | AD104 | AD106 | AD107 => {
6468
KBox::new(ga102::Ga102::<E>::new(), GFP_KERNEL)? as KBox<dyn FalconHal<E>>
6569
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
3+
use core::marker::PhantomData;
4+
5+
use kernel::{
6+
io::poll::read_poll_timeout,
7+
prelude::*,
8+
time::delay::fsleep,
9+
time::Delta, //
10+
};
11+
12+
use crate::{
13+
driver::Bar0,
14+
falcon::{
15+
Falcon,
16+
FalconBromParams,
17+
FalconEngine, //
18+
},
19+
regs, //
20+
};
21+
22+
use super::FalconHal;
23+
24+
pub(super) struct Tu102<E: FalconEngine>(PhantomData<E>);
25+
26+
impl<E: FalconEngine> Tu102<E> {
27+
pub(super) fn new() -> Self {
28+
Self(PhantomData)
29+
}
30+
}
31+
32+
impl<E: FalconEngine> FalconHal<E> for Tu102<E> {
33+
fn select_core(&self, _falcon: &Falcon<E>, _bar: &Bar0) -> Result {
34+
Ok(())
35+
}
36+
37+
fn signature_reg_fuse_version(
38+
&self,
39+
_falcon: &Falcon<E>,
40+
_bar: &Bar0,
41+
_engine_id_mask: u16,
42+
_ucode_id: u8,
43+
) -> Result<u32> {
44+
Ok(0)
45+
}
46+
47+
fn program_brom(&self, _falcon: &Falcon<E>, _bar: &Bar0, _params: &FalconBromParams) -> Result {
48+
Ok(())
49+
}
50+
51+
fn is_riscv_active(&self, bar: &Bar0) -> bool {
52+
let cpuctl = regs::NV_PRISCV_RISCV_CORE_SWITCH_RISCV_STATUS::read(bar, &E::ID);
53+
cpuctl.active_stat()
54+
}
55+
56+
fn reset_wait_mem_scrubbing(&self, bar: &Bar0) -> Result {
57+
// TIMEOUT: memory scrubbing should complete in less than 10ms.
58+
read_poll_timeout(
59+
|| Ok(regs::NV_PFALCON_FALCON_DMACTL::read(bar, &E::ID)),
60+
|r| r.mem_scrubbing_done(),
61+
Delta::ZERO,
62+
Delta::from_millis(10),
63+
)
64+
.map(|_| ())
65+
}
66+
67+
fn reset_eng(&self, bar: &Bar0) -> Result {
68+
regs::NV_PFALCON_FALCON_ENGINE::update(bar, &E::ID, |v| v.set_reset(true));
69+
70+
// TIMEOUT: falcon engine should not take more than 10us to reset.
71+
fsleep(Delta::from_micros(10));
72+
73+
regs::NV_PFALCON_FALCON_ENGINE::update(bar, &E::ID, |v| v.set_reset(false));
74+
75+
self.reset_wait_mem_scrubbing(bar)?;
76+
77+
Ok(())
78+
}
79+
}

drivers/gpu/nova-core/regs.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,13 @@ register!(NV_PFALCON_FALCON_DMACTL @ PFalconBase[0x0000010c] {
307307
7:7 secure_stat as bool;
308308
});
309309

310+
impl NV_PFALCON_FALCON_DMACTL {
311+
/// Returns `true` if memory scrubbing is completed.
312+
pub(crate) fn mem_scrubbing_done(self) -> bool {
313+
!self.dmem_scrubbing() && !self.imem_scrubbing()
314+
}
315+
}
316+
310317
register!(NV_PFALCON_FALCON_DMATRFBASE @ PFalconBase[0x00000110] {
311318
31:0 base as u32;
312319
});
@@ -389,6 +396,13 @@ register!(NV_PFALCON2_FALCON_BROM_PARAADDR @ PFalcon2Base[0x00000210[1]] {
389396

390397
// PRISCV
391398

399+
// RISC-V status register for debug (Turing and GA100 only).
400+
// Reflects current RISC-V core status.
401+
register!(NV_PRISCV_RISCV_CORE_SWITCH_RISCV_STATUS @ PFalcon2Base[0x00000240] {
402+
0:0 active_stat as bool, "RISC-V core active/inactive status";
403+
});
404+
405+
// GA102 and later
392406
register!(NV_PRISCV_RISCV_CPUCTL @ PFalcon2Base[0x00000388] {
393407
0:0 halted as bool;
394408
7:7 active_stat as bool;

0 commit comments

Comments
 (0)