NVIDIA GPU driver infrastructure
 help / color / mirror / Atom feed
From: Timur Tabi <ttabi@nvidia.com>
To: Danilo Krummrich <dakr@kernel.org>,
	Alexandre Courbot <acourbot@nvidia.com>,
	John Hubbard <jhubbard@nvidia.com>,
	Eliot Courtney <ecourtney@nvidia.com>, <nova-gpu@lists.linux.dev>
Subject: [PATCH v2 5/7] gpu: nova-core: add TLV versions of WPR heap size functions
Date: Mon, 16 Nov 2026 13:54:39 -0600	[thread overview]
Message-ID: <20261116195441.940595-6-ttabi@nvidia.com> (raw)
In-Reply-To: <20261116195441.940595-1-ttabi@nvidia.com>

Add TLV versions of vgpu_wpr_heap_size() and wpr_heap_size() to
GspFwHeapParams.  These complement the same functions in LibosParams.
We add them to GspFwHeapParams because LibosParams will be removed
in a future commit, and the driver will use the GspFwHeapParams
version instead.

Signed-off-by: Timur Tabi <ttabi@nvidia.com>
---
 drivers/gpu/nova-core/gsp/fw.rs | 33 +++++++++++++++++++++++++++++----
 1 file changed, 29 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/nova-core/gsp/fw.rs b/drivers/gpu/nova-core/gsp/fw.rs
index 837f7a522429..a0277ba6dc88 100644
--- a/drivers/gpu/nova-core/gsp/fw.rs
+++ b/drivers/gpu/nova-core/gsp/fw.rs
@@ -68,13 +68,9 @@
 
 /// Heap memory requirements and constraints for booting GSP-RM.
 pub(crate) struct GspFwHeapParams {
-    #[expect(unused)]
     tlv_gsp_fw_heap_base_size: u64,
-    #[expect(unused)]
     tlv_gsp_hw_heap_size_per_gb: u64,
-    #[expect(unused)]
     tlv_gsp_fw_heap_base_size_vgpu: u64,
-    #[expect(unused)]
     tlv_gsp_fw_heap_size_per_vm: u64,
     pub(crate) tlv_pmu_reserved_size: u32,
     pub(crate) tlv_non_wpr_heap_size: u64,
@@ -127,6 +123,35 @@ fn management_overhead(fb_size: u64) -> Result<u64> {
             .align_up(GSP_HEAP_ALIGNMENT)
             .ok_or(EINVAL)
     }
+
+    /// Returns the WPR heap size to reserve when vGPU is enabled.
+    #[expect(unused)]
+    pub(crate) fn vgpu_wpr_heap_size(&self, total_vfs: u16) -> Result<u64> {
+        //u64::from(bindings::GSP_FW_HEAP_SIZE_VGPU_DEFAULT)
+        let vm_size = self
+            .tlv_gsp_fw_heap_size_per_vm
+            .saturating_mul(u64::from(total_vfs))
+            .align_up(GSP_HEAP_ALIGNMENT)
+            .ok_or(EINVAL)?;
+
+        Ok(self.tlv_gsp_fw_heap_base_size_vgpu.saturating_add(vm_size))
+    }
+
+    /// Returns the amount of memory (in bytes) to allocate for the WPR heap for a framebuffer size
+    /// of `fb_size` (in bytes).
+    #[expect(unused)]
+    pub(crate) fn wpr_heap_size(&self, fb_size: u64) -> Result<u64> {
+        let fb_size_gb = fb_size.div_ceil(u64::SZ_1G);
+        let management_overhead: u64 = self
+            .tlv_gsp_hw_heap_size_per_gb
+            .saturating_mul(fb_size_gb)
+            .align_up(GSP_HEAP_ALIGNMENT)
+            .ok_or(EINVAL)?;
+
+        Ok(self
+            .tlv_gsp_fw_heap_base_size
+            .saturating_add(management_overhead))
+    }
 }
 
 /// Heap memory requirements and constraints for a given version of the GSP LIBOS.
-- 
2.54.0


  parent reply	other threads:[~2026-11-16 19:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 19:54 [PATCH v2 0/7] Transition nova-core to use TLV variables for heap sizes Timur Tabi
2026-11-16 19:54 ` [PATCH v2 1/7] gpu: nova-core: add Tlv.get_u64 Timur Tabi
2026-11-16 19:54 ` [PATCH v2 2/7] gpu: nova-core: read GSP heap variables from TLV Timur Tabi
2026-11-16 19:54 ` [PATCH v2 3/7] gpu: nova-core: use the TLV heap sizes for pmu and non-wpr Timur Tabi
2026-11-16 19:54 ` [PATCH v2 4/7] gpu: nova-core: remove heap size related HAL functions Timur Tabi
2026-11-16 19:54 ` Timur Tabi [this message]
2026-11-16 19:54 ` [PATCH v2 6/7] gpu: nova-core: change wpr2_heap_params to use TLV values Timur Tabi
2026-11-16 19:54 ` [PATCH v2 7/7] gpu: nova-core: remove LibosParams Timur Tabi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261116195441.940595-6-ttabi@nvidia.com \
    --to=ttabi@nvidia.com \
    --cc=acourbot@nvidia.com \
    --cc=dakr@kernel.org \
    --cc=ecourtney@nvidia.com \
    --cc=jhubbard@nvidia.com \
    --cc=nova-gpu@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox