[PATCH v8 02/31] gpu: nova-core: factor .fwsignature* selection into a new find_gsp_sigs_section()

John Hubbard posted 31 patches 1 week, 1 day ago
There is a newer version of this series
[PATCH v8 02/31] gpu: nova-core: factor .fwsignature* selection into a new find_gsp_sigs_section()
Posted by John Hubbard 1 week, 1 day ago
Keep Gsp::new() from getting too cluttered, by factoring out the
selection of .fwsignature* items. This will continue to grow as we add
GPUs.

Reviewed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
 drivers/gpu/nova-core/firmware/gsp.rs | 36 ++++++++++++++-------------
 1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/nova-core/firmware/gsp.rs b/drivers/gpu/nova-core/firmware/gsp.rs
index c1f0a606f5c0..8bbc3809c640 100644
--- a/drivers/gpu/nova-core/firmware/gsp.rs
+++ b/drivers/gpu/nova-core/firmware/gsp.rs
@@ -146,6 +146,24 @@ pub(crate) struct GspFirmware {
 }
 
 impl GspFirmware {
+    fn find_gsp_sigs_section(chipset: Chipset) -> Option<&'static str> {
+        match chipset.arch() {
+            Architecture::Turing if matches!(chipset, Chipset::TU116 | Chipset::TU117) => {
+                Some(".fwsignature_tu11x")
+            }
+            Architecture::Turing => Some(".fwsignature_tu10x"),
+            // GA100 uses the same firmware as Turing
+            Architecture::Ampere if chipset == Chipset::GA100 => Some(".fwsignature_tu10x"),
+            Architecture::Ampere => Some(".fwsignature_ga10x"),
+            Architecture::Ada => Some(".fwsignature_ad10x"),
+            Architecture::Hopper => Some(".fwsignature_gh10x"),
+            Architecture::Blackwell if matches!(chipset, Chipset::GB100 | Chipset::GB102) => {
+                Some(".fwsignature_gb10x")
+            }
+            Architecture::Blackwell => Some(".fwsignature_gb20x"),
+        }
+    }
+
     /// Loads the GSP firmware binaries, map them into `dev`'s address-space, and creates the page
     /// tables expected by the GSP bootloader to load it.
     pub(crate) fn new<'a>(
@@ -211,23 +229,7 @@ pub(crate) fn new<'a>(
                 },
                 size,
                 signatures: {
-                    let sigs_section = match chipset.arch() {
-                        Architecture::Turing
-                            if matches!(chipset, Chipset::TU116 | Chipset::TU117) => {
-                            ".fwsignature_tu11x"
-                        }
-                        Architecture::Turing => ".fwsignature_tu10x",
-                        // GA100 uses the same firmware as Turing
-                        Architecture::Ampere if chipset == Chipset::GA100 => ".fwsignature_tu10x",
-                        Architecture::Ampere => ".fwsignature_ga10x",
-                        Architecture::Ada => ".fwsignature_ad10x",
-                        Architecture::Hopper => ".fwsignature_gh10x",
-                        Architecture::Blackwell
-                            if matches!(chipset, Chipset::GB100 | Chipset::GB102) => {
-                            ".fwsignature_gb10x"
-                        }
-                        Architecture::Blackwell => ".fwsignature_gb20x",
-                    };
+                    let sigs_section = Self::find_gsp_sigs_section(chipset).ok_or(ENOTSUPP)?;
 
                     elf::elf64_section(firmware.data(), sigs_section)
                         .ok_or(EINVAL)
-- 
2.53.0
Re: [PATCH v8 02/31] gpu: nova-core: factor .fwsignature* selection into a new find_gsp_sigs_section()
Posted by Alexandre Courbot 1 week, 1 day ago
On Tue, 24 Mar 2026 20:52:13 -0700, John Hubbard <jhubbard@nvidia.com> wrote:
> diff --git a/drivers/gpu/nova-core/firmware/gsp.rs b/drivers/gpu/nova-core/firmware/gsp.rs
> index c1f0a606f5c0..8bbc3809c640 100644
> --- a/drivers/gpu/nova-core/firmware/gsp.rs
> +++ b/drivers/gpu/nova-core/firmware/gsp.rs
> @@ -146,6 +146,24 @@ pub(crate) struct GspFirmware {
> [ ... skip 14 lines ... ]
> +            Architecture::Blackwell if matches!(chipset, Chipset::GB100 | Chipset::GB102) => {
> +                Some(".fwsignature_gb10x")
> +            }
> +            Architecture::Blackwell => Some(".fwsignature_gb20x"),
> +        }
> +    }

The match statement is exhaustive and we never return `None` here, so
there is no need to return an `Option`.

-- 
Alexandre Courbot <acourbot@nvidia.com>
Re: [PATCH v8 02/31] gpu: nova-core: factor .fwsignature* selection into a new find_gsp_sigs_section()
Posted by John Hubbard 1 week, 1 day ago
On 3/25/26 3:45 AM, Alexandre Courbot wrote:
> On Tue, 24 Mar 2026 20:52:13 -0700, John Hubbard <jhubbard@nvidia.com> wrote:
>> diff --git a/drivers/gpu/nova-core/firmware/gsp.rs b/drivers/gpu/nova-core/firmware/gsp.rs
>> index c1f0a606f5c0..8bbc3809c640 100644
>> --- a/drivers/gpu/nova-core/firmware/gsp.rs
>> +++ b/drivers/gpu/nova-core/firmware/gsp.rs
>> @@ -146,6 +146,24 @@ pub(crate) struct GspFirmware {
>> [ ... skip 14 lines ... ]
>> +            Architecture::Blackwell if matches!(chipset, Chipset::GB100 | Chipset::GB102) => {
>> +                Some(".fwsignature_gb10x")
>> +            }
>> +            Architecture::Blackwell => Some(".fwsignature_gb20x"),
>> +        }
>> +    }
> 
> The match statement is exhaustive and we never return `None` here, so
> there is no need to return an `Option`.
> 

Right, and also true even after splitting Blackwell into two arches.
(There has been a lot of churn in this Arch/chipset area, and clippy
doesn't really cover this, so it's one of those things that an
actual review really helps find.)

Fixed for v9.

thanks,
-- 
John Hubbard