From: "Alexandre Courbot" <acourbot@nvidia.com>
To: "Gary Guo" <gary@garyguo.net>
Cc: "Danilo Krummrich" <dakr@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Benno Lossin" <lossin@kernel.org>, <nova-gpu@lists.linux.dev>,
<dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>,
<rust-for-linux@vger.kernel.org>,
"Joel Fernandes" <joelagnelf@nvidia.com>,
"John Hubbard" <jhubbard@nvidia.com>
Subject: Re: [PATCH 3/4] gpu: nova-core: gsp: Extract usable FB region from GSP
Date: Wed, 17 Jun 2026 15:20:11 +0900 [thread overview]
Message-ID: <DJB3UZLL1SNY.2Z2SW7140XNGK@nvidia.com> (raw)
In-Reply-To: <DJ5ANU6OL6X2.D8ZG3LV755I8@garyguo.net>
On Wed Jun 10, 2026 at 7:23 PM JST, Gary Guo wrote:
> On Tue Jun 9, 2026 at 9:04 AM BST, Alexandre Courbot wrote:
>> From: Joel Fernandes <joelagnelf@nvidia.com>
>>
>> Add usable_fb_regions_iter() to GspStaticConfigInfo to extract the first
>> usable FB region from GSP's fbRegionInfoParams. Usable regions are those
>> that are not reserved or protected.
>>
>> The extracted region is stored in GetGspStaticInfoReply and exposed as
>> usable_fb_region field for use by the memory subsystem.
>>
>> Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
>> Reviewed-by: John Hubbard <jhubbard@nvidia.com>
>> ---
>> drivers/gpu/nova-core/gsp/commands.rs | 9 +++++--
>> drivers/gpu/nova-core/gsp/fw/commands.rs | 40 +++++++++++++++++++++++++++++++-
>> 2 files changed, 46 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/gpu/nova-core/gsp/commands.rs b/drivers/gpu/nova-core/gsp/commands.rs
>> index f84de9f4f045..d955f52a93bb 100644
>> --- a/drivers/gpu/nova-core/gsp/commands.rs
>> +++ b/drivers/gpu/nova-core/gsp/commands.rs
>> @@ -5,6 +5,7 @@
>> array,
>> convert::Infallible,
>> ffi::FromBytesUntilNulError,
>> + ops::Range,
>> str::Utf8Error, //
>> };
>>
>> @@ -191,15 +192,18 @@ fn init(&self) -> impl Init<Self::Command, Self::InitError> {
>> }
>> }
>>
>> -/// The reply from the GSP to the [`GetGspInfo`] command.
>> +/// The reply from the GSP to the [`GetGspStaticInfo`] command.
>> pub(crate) struct GetGspStaticInfoReply {
>> gpu_name: [u8; 64],
>> + /// Usable FB (VRAM) region for driver memory allocation.
>> + #[expect(dead_code)]
>> + pub(crate) usable_fb_region: Range<u64>,
>> }
>>
>> impl MessageFromGsp for GetGspStaticInfoReply {
>> const FUNCTION: MsgFunction = MsgFunction::GetGspStaticInfo;
>> type Message = fw::commands::GspStaticConfigInfo;
>> - type InitError = Infallible;
>> + type InitError = Error;
>>
>> fn read(
>> msg: &Self::Message,
>> @@ -207,6 +211,7 @@ fn read(
>> ) -> Result<Self, Self::InitError> {
>> Ok(GetGspStaticInfoReply {
>> gpu_name: msg.gpu_name_str(),
>> + usable_fb_region: msg.usable_fb_regions_iter().next().ok_or(ENODEV)?,
>
> Does it just essentially require a FB to be present? What would happen to GPUs
> without display support like RTX PRO 4500 Blackwell Server Edition?
The naming is a bit unfortunate, but "FB" is generally accepted to be a
synonym for "VRAM" in NV-speak. Nouveau also uses this terminology to it
is not internal-only.
>
> I feel that this check should be done by the user of `GetGspStaticInfoReply`,
> the firmware doesn't reply with an error.
Indeed. Moving the check to the caller is difficult with the current
code since `GetGspStaticInfoReply` requires one region to be built.
But maybe we can collect all the regions into a `KVec`. This will let
the caller check that at least one is present, and also be more
useful as we will want to see all valid regions in the future anyway.
It will also let the caller compute the total amount of VRAM, rather
than having to store it in the message reply, despite that information
not technically being part of the message.
>
>> })
>> }
>> }
>> diff --git a/drivers/gpu/nova-core/gsp/fw/commands.rs b/drivers/gpu/nova-core/gsp/fw/commands.rs
>> index 7bcc41fc7fa0..d025167927df 100644
>> --- a/drivers/gpu/nova-core/gsp/fw/commands.rs
>> +++ b/drivers/gpu/nova-core/gsp/fw/commands.rs
>> @@ -1,6 +1,8 @@
>> // SPDX-License-Identifier: GPL-2.0
>> // SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
>>
>> +use core::ops::Range;
>> +
>> use kernel::{
>> device,
>> pci,
>> @@ -13,7 +15,8 @@
>>
>> use crate::{
>> gpu::Chipset,
>> - gsp::GSP_PAGE_SIZE, //
>> + gsp::GSP_PAGE_SIZE,
>> + num::IntoSafeCast, //
>> };
>>
>> use super::bindings;
>> @@ -129,6 +132,41 @@ impl GspStaticConfigInfo {
>> pub(crate) fn gpu_name_str(&self) -> [u8; 64] {
>> self.0.gpuNameString
>> }
>> +
>> + /// Returns an iterator over valid FB regions from GSP firmware data.
>> + fn fb_regions(
>> + &self,
>> + ) -> impl Iterator<Item = &bindings::NV2080_CTRL_CMD_FB_GET_FB_REGION_FB_REGION_INFO> {
>> + let fb_info = &self.0.fbRegionInfoParams;
>> + fb_info
>> + .fbRegion
>> + .iter()
>> + .take(fb_info.numFBRegions.into_safe_cast())
>> + .filter(|reg| reg.limit >= reg.base)
>> + }
>> +
>> + /// Iterates over usable FB regions from GSP firmware data.
>> + ///
>> + /// Each yielded region is a [`Range<u64>`] suitable for driver memory allocation.
>> + /// Usable regions are those that satisfy all the following properties:
>> + /// - Are not reserved for firmware internal use.
>> + /// - Are not protected (hardware-enforced access restrictions).
>> + /// - Support compression (can use GPU memory compression for bandwidth).
>> + /// - Support ISO (isochronous memory for display requiring guaranteed bandwidth).
>> + pub(crate) fn usable_fb_regions_iter(&self) -> impl Iterator<Item = Range<u64>> + '_ {
>
> I think this is a bit too verbose. `usable_fb_regions` should be okay.
Agreed.
next prev parent reply other threads:[~2026-06-17 6:20 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-09 8:03 [PATCH 0/4] gpu: nova-core: obtain and display VRAM amount Alexandre Courbot
2026-06-09 8:03 ` [PATCH 1/4] gpu: nova-core: move GSP unload state to a pinned Gpu subobject Alexandre Courbot
2026-06-10 3:52 ` Eliot Courtney
2026-06-10 11:18 ` Alexandre Courbot
2026-06-10 10:14 ` Gary Guo
2026-06-09 8:04 ` [PATCH 2/4] gpu: nova-core: move GPU static information acquisition to a GSP method Alexandre Courbot
2026-06-10 3:39 ` Eliot Courtney
2026-06-10 10:16 ` Gary Guo
2026-06-17 6:22 ` Alexandre Courbot
2026-06-09 8:04 ` [PATCH 3/4] gpu: nova-core: gsp: Extract usable FB region from GSP Alexandre Courbot
2026-06-10 3:35 ` Eliot Courtney
2026-06-17 6:20 ` Alexandre Courbot
2026-06-10 10:23 ` Gary Guo
2026-06-10 10:27 ` Gary Guo
2026-06-10 15:38 ` Timur Tabi
2026-06-17 6:20 ` Alexandre Courbot [this message]
2026-06-09 8:04 ` [PATCH 4/4] gpu: nova-core: gsp: Expose total physical VRAM end from FB region info Alexandre Courbot
2026-06-10 3:37 ` 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=DJB3UZLL1SNY.2Z2SW7140XNGK@nvidia.com \
--to=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=aliceryhl@google.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=gary@garyguo.net \
--cc=jhubbard@nvidia.com \
--cc=joelagnelf@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=nova-gpu@lists.linux.dev \
--cc=rust-for-linux@vger.kernel.org \
--cc=simona@ffwll.ch \
/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