From: John Hubbard Date: Sat, 11 Apr 2026 02:49:27 +0000 (-0700) Subject: gpu: nova-core: use GPU Architecture to simplify HAL selections X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b3bdb42619c8fce6d6d5feb36ad33d184aaa4e3d;p=thirdparty%2Fkernel%2Flinux.git gpu: nova-core: use GPU Architecture to simplify HAL selections Replace per-chipset match arms with Architecture-based matching in the falcon and FB HAL selection functions. This reduces the number of match arms that need updating when new chipsets are added within an existing architecture. Signed-off-by: John Hubbard Acked-by: Danilo Krummrich Reviewed-by: Gary Guo Link: https://patch.msgid.link/20260411024953.473149-3-jhubbard@nvidia.com Signed-off-by: Alexandre Courbot --- diff --git a/drivers/gpu/nova-core/falcon/hal.rs b/drivers/gpu/nova-core/falcon/hal.rs index f82087df49369..f75b5c315d62d 100644 --- a/drivers/gpu/nova-core/falcon/hal.rs +++ b/drivers/gpu/nova-core/falcon/hal.rs @@ -9,7 +9,10 @@ use crate::{ FalconBromParams, FalconEngine, // }, - gpu::Chipset, + gpu::{ + Architecture, + Chipset, // + }, }; mod ga102; @@ -74,14 +77,15 @@ pub(crate) trait FalconHal: Send + Sync { pub(super) fn falcon_hal( chipset: Chipset, ) -> Result>> { - use Chipset::*; - - let hal = match chipset { - GA100 | // GA100 boots like Turing so use Turing HAL - TU102 | TU104 | TU106 | TU116 | TU117 => { + let hal = match chipset.arch() { + Architecture::Turing => { + KBox::new(tu102::Tu102::::new(), GFP_KERNEL)? as KBox> + } + // GA100 boots like Turing so use Turing HAL + Architecture::Ampere if chipset == Chipset::GA100 => { KBox::new(tu102::Tu102::::new(), GFP_KERNEL)? as KBox> } - GA102 | GA103 | GA104 | GA106 | GA107 | AD102 | AD103 | AD104 | AD106 | AD107 => { + Architecture::Ampere | Architecture::Ada => { KBox::new(ga102::Ga102::::new(), GFP_KERNEL)? as KBox> } }; diff --git a/drivers/gpu/nova-core/fb/hal.rs b/drivers/gpu/nova-core/fb/hal.rs index 1c01a6cbed652..6f928052d0c06 100644 --- a/drivers/gpu/nova-core/fb/hal.rs +++ b/drivers/gpu/nova-core/fb/hal.rs @@ -4,7 +4,10 @@ use kernel::prelude::*; use crate::{ driver::Bar0, - gpu::Chipset, // + gpu::{ + Architecture, + Chipset, // + }, }; mod ga100; @@ -32,13 +35,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 | AD102 | AD103 | AD104 | AD106 | AD107 => { - 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::Ada => ga102::GA102_HAL, } }