Instead of long, exhaustive lists of GPUs ("Chipsets"), use entire
GPU Architectures, such as "Blackwell" or "Turing", to make HAL choices.Note: Left a // TODO for GA100, hinting at the remaining work in order to bring up that chipset. A tiny side effect: moved a "use" statement out of function scope, in each file, up to the top of the file, as per Rust for Linux conventions. Signed-off-by: John Hubbard <[email protected]> --- drivers/gpu/nova-core/falcon/hal.rs | 21 +++++++++++++-------- drivers/gpu/nova-core/fb/hal.rs | 17 +++++++++-------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/nova-core/falcon/hal.rs b/drivers/gpu/nova-core/falcon/hal.rs index 444c95fd4ece..edf4d27d54f7 100644 --- a/drivers/gpu/nova-core/falcon/hal.rs +++ b/drivers/gpu/nova-core/falcon/hal.rs @@ -9,7 +9,10 @@ FalconBromParams, FalconEngine, // }, - gpu::Chipset, + gpu::{ + Architecture, + Chipset, // + }, }; mod ga102; @@ -70,17 +73,19 @@ fn signature_reg_fuse_version( pub(super) fn falcon_hal<E: FalconEngine + 'static>( chipset: Chipset, ) -> Result<KBox<dyn FalconHal<E>>> { - use Chipset::*; - - let hal = match chipset { - TU102 | TU104 | TU106 | TU116 | TU117 => { + let hal = match chipset.arch() { + Architecture::Turing => { KBox::new(tu102::Tu102::<E>::new(), GFP_KERNEL)? as KBox<dyn FalconHal<E>> } - GA102 | GA103 | GA104 | GA106 | GA107 | AD102 | AD103 | AD104 | AD106 | AD107 | GH100 - | GB100 | GB102 | GB202 | GB203 | GB205 | GB206 | GB207 => { + // TODO: support GA100. Its boot sequence is a lot like Turing, except that it handles the + // FRTS steps differently (specifically, it skips FWSEC-FRTS). + Architecture::Ampere if chipset == Chipset::GA100 => return Err(ENOTSUPP), + Architecture::Ampere + | Architecture::Hopper + | Architecture::Ada + | Architecture::Blackwell => { KBox::new(ga102::Ga102::<E>::new(), GFP_KERNEL)? as KBox<dyn FalconHal<E>> } - _ => return Err(ENOTSUPP), }; Ok(hal) diff --git a/drivers/gpu/nova-core/fb/hal.rs b/drivers/gpu/nova-core/fb/hal.rs index 71fa92d1b709..d795ef7ee65d 100644 --- a/drivers/gpu/nova-core/fb/hal.rs +++ b/drivers/gpu/nova-core/fb/hal.rs @@ -4,7 +4,10 @@ use crate::{ driver::Bar0, - gpu::Chipset, // + gpu::{ + Architecture, + Chipset, // + }, }; mod ga100; @@ -29,12 +32,10 @@ pub(crate) trait FbHal { /// Returns the HAL corresponding to `chipset`. pub(super) fn fb_hal(chipset: Chipset) -> &'static dyn FbHal { - use Chipset::*; - - match chipset { - TU102 | TU104 | TU106 | TU117 | TU116 => tu102::TU102_HAL, - GA100 => ga100::GA100_HAL, - GA102 | GA103 | GA104 | GA106 | GA107 | GH100 | AD102 | AD103 | AD104 | AD106 | AD107 - | GB100 | GB102 | GB202 | GB203 | GB205 | GB206 | GB207 => ga102::GA102_HAL, + match chipset.arch() { + Architecture::Turing => tu102::TU102_HAL, + Architecture::Ampere if chipset == Chipset::GA100 => ga100::GA100_HAL, + Architecture::Ampere => ga102::GA102_HAL, + Architecture::Hopper | Architecture::Ada | Architecture::Blackwell => ga102::GA102_HAL, } } -- 2.52.0
