On 2/6/26 11:03 AM, Timur Tabi wrote:
On Thu, 2026-02-05 at 20:21 -0800, John Hubbard wrote:
+    fn client_alloc_size(chipset: Chipset) -> u64 {
+        if crate::fb::hal::fb_hal(chipset)
+            .non_wpr_heap_size()
+            .is_some()
+        {
+            GSP_FW_HEAP_PARAM_CLIENT_ALLOC_SIZE_GH100
+        } else {
+            u64::from(bindings::GSP_FW_HEAP_PARAM_CLIENT_ALLOC_SIZE)
+        }
+        .align_up(GSP_HEAP_ALIGNMENT)
+        .unwrap_or(u64::MAX)

I understand not wanting to return a Result<> for impossible situations, but I 
don't know if this is
the answer.  For one thing, there is no way we can allocate a heap that large.

Maybe we need to have some kind of infallible align_up() variant, but in this 
case, I would say a
panic is warranted.

You are right. And that agrees with Miguel Ojeda's overall philosophy
about handling this type of error, too.

I'll change it to this for the next version:

diff --git a/drivers/gpu/nova-core/gsp/fw.rs b/drivers/gpu/nova-core/gsp/fw.rs
index 0d1d9eecd77c..927bcee6a5a5 100644
--- a/drivers/gpu/nova-core/gsp/fw.rs
+++ b/drivers/gpu/nova-core/gsp/fw.rs
@@ -83,7 +83,7 @@ fn client_alloc_size(chipset: Chipset) -> u64 {
             u64::from(bindings::GSP_FW_HEAP_PARAM_CLIENT_ALLOC_SIZE)
         }
         .align_up(GSP_HEAP_ALIGNMENT)
-        .unwrap_or(u64::MAX)
+        .expect("client_alloc_size alignment overflow")
     }
/// Returns the amount of memory to reserve for management purposes for a framebuffer of size
@@ -94,7 +94,7 @@ fn management_overhead(fb_size: u64) -> u64 {
         u64::from(bindings::GSP_FW_HEAP_PARAM_SIZE_PER_GB_FB)
             .saturating_mul(fb_size_gb)
             .align_up(GSP_HEAP_ALIGNMENT)
-            .unwrap_or(u64::MAX)
+            .expect("management_overhead alignment overflow")
     }
 }


thanks,
--
John Hubbard

Reply via email to