NVIDIA GPU driver infrastructure
 help / color / mirror / Atom feed
From: "Eliot Courtney" <ecourtney@nvidia.com>
To: "Timur Tabi" <ttabi@nvidia.com>,
	"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: Re: [PATCH v2 5/7] gpu: nova-core: add TLV versions of WPR heap size functions
Date: Fri, 20 Nov 2026 16:01:53 +0900	[thread overview]
Message-ID: <DMZUFWHFA4V8.I8OXAFEOY9I1@nvidia.com> (raw)
In-Reply-To: <20261116195441.940595-6-ttabi@nvidia.com>

On Tue Nov 17, 2026 at 4:54 AM JST, Timur Tabi wrote:
> 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))

What about using checked_mul here (and other locations)? We already
return a `Result` from these functions anyway.

> +            .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

nit: unneccessary u64 type specified

> +            .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.



  reply	other threads:[~2026-11-20  7:02 UTC|newest]

Thread overview: 14+ 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-18  4:51   ` Eliot Courtney
2026-11-16 19:54 ` [PATCH v2 2/7] gpu: nova-core: read GSP heap variables from TLV Timur Tabi
2026-11-20  5:23   ` Eliot Courtney
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-20  6:47   ` Eliot Courtney
2026-11-16 19:54 ` [PATCH v2 4/7] gpu: nova-core: remove heap size related HAL functions Timur Tabi
2026-11-20  6:47   ` Eliot Courtney
2026-11-16 19:54 ` [PATCH v2 5/7] gpu: nova-core: add TLV versions of WPR heap size functions Timur Tabi
2026-11-20  7:01   ` Eliot Courtney [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
2026-11-20  6:53   ` Eliot Courtney

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=DMZUFWHFA4V8.I8OXAFEOY9I1@nvidia.com \
    --to=ecourtney@nvidia.com \
    --cc=acourbot@nvidia.com \
    --cc=dakr@kernel.org \
    --cc=jhubbard@nvidia.com \
    --cc=nova-gpu@lists.linux.dev \
    --cc=ttabi@nvidia.com \
    /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