From: "Eliot Courtney" <ecourtney@nvidia.com>
To: "Alexandre Courbot" <acourbot@nvidia.com>,
"Eliot Courtney" <ecourtney@nvidia.com>
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>, "Gary Guo" <gary@garyguo.net>,
"John Hubbard" <jhubbard@nvidia.com>,
"Alistair Popple" <apopple@nvidia.com>,
"Timur Tabi" <ttabi@nvidia.com>, <nova-gpu@lists.linux.dev>,
<dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>,
<rust-for-linux@vger.kernel.org>,
"dri-devel" <dri-devel-bounces@lists.freedesktop.org>
Subject: Re: [PATCH v2 06/10] gpu: nova-core: correct FRTS vidmem offset calculation
Date: Fri, 24 Jul 2026 15:58:05 +0900 [thread overview]
Message-ID: <DK6LU60L9ORM.3QRGRG81VJZO1@nvidia.com> (raw)
In-Reply-To: <DK60G8GDS2V9.T0LEJKNA2JJA@nvidia.com>
On Thu Jul 23, 2026 at 11:12 PM JST, Alexandre Courbot wrote:
> On Fri Jul 3, 2026 at 7:22 PM JST, Eliot Courtney wrote:
>> Currently, the frts vidmem offset is calculated based on the non-wpr
>> heap size and pmu reservation size, but this is not right. The layout
>> actually looks like this:
>>
>> | non-wpr heap | WPR2 .. FRTS | PMU reserved | ... | VGA workspace |
>>
>> It's just by coincidence + generous alignment that the values happened
>> to match. Instead, define a per-architecture reserved size at the end of
>> the framebuffer and use this plus the PMU reserved size to calculate the
>> frts vidmem offset.
>>
>> Fixes: d317e4585fa3 ("gpu: nova-core: Hopper/Blackwell: add FSP Chain of Trust boot")
>> Signed-off-by: Eliot Courtney <ecourtney@nvidia.com>
>> ---
>> drivers/gpu/nova-core/fb.rs | 4 ++++
>> drivers/gpu/nova-core/fb/hal.rs | 3 +++
>> drivers/gpu/nova-core/fb/hal/ga100.rs | 4 ++++
>> drivers/gpu/nova-core/fb/hal/ga102.rs | 4 ++++
>> drivers/gpu/nova-core/fb/hal/gb100.rs | 5 +++++
>> drivers/gpu/nova-core/fb/hal/gb202.rs | 5 +++++
>> drivers/gpu/nova-core/fb/hal/gh100.rs | 4 ++++
>> drivers/gpu/nova-core/fb/hal/tu102.rs | 8 ++++++++
>> drivers/gpu/nova-core/fsp.rs | 25 ++++++++++++++++++-------
>> 9 files changed, 55 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/gpu/nova-core/fb.rs b/drivers/gpu/nova-core/fb.rs
>> index fd60f93258a9..5ffe66af282f 100644
>> --- a/drivers/gpu/nova-core/fb.rs
>> +++ b/drivers/gpu/nova-core/fb.rs
>> @@ -305,6 +305,9 @@ pub(crate) struct FbSizes {
>> pub(crate) heap_size: u64,
>> /// PMU reserved memory size, in bytes.
>> pub(crate) pmu_reserved_size: u32,
>> + /// Size reserved at the end of the framebuffer. This is architecture dependent and used to
>> + /// compute the FRTS offset for the FSP CoT message.
>> + pub(crate) fb_end_reserved_size: u32,
>> /// Number of VF partitions.
>> pub(crate) vf_partition_count: u8,
>> }
>> @@ -322,6 +325,7 @@ fn new(chipset: Chipset, bar: Bar0<'_>) -> Result<Self> {
>> .wpr_heap_size(chipset, fb_size)?,
>> heap_size: u64::from(hal.non_wpr_heap_size()),
>> pmu_reserved_size: hal.pmu_reserved_size(),
>> + fb_end_reserved_size: hal.fb_end_reserved_size(),
>> vf_partition_count: 0,
>> })
>> }
>> diff --git a/drivers/gpu/nova-core/fb/hal.rs b/drivers/gpu/nova-core/fb/hal.rs
>> index 714f0b51cd8f..aa50534550eb 100644
>> --- a/drivers/gpu/nova-core/fb/hal.rs
>> +++ b/drivers/gpu/nova-core/fb/hal.rs
>> @@ -41,6 +41,9 @@ pub(crate) trait FbHal {
>>
>> /// Returns the FRTS size, in bytes.
>> fn frts_size(&self) -> u64;
>> +
>> + /// Returns the size reserved at the end of the framebuffer, in bytes.
>> + fn fb_end_reserved_size(&self) -> u32;
>
> This connects to my comments on the previous patch, but this HAL method
> is only ever used on the FSP path, yet we have to provide values (that
> will remain unused), for all chipsets. This really strenghen the case
> for making FbLayout/FbRanges/FbSizes local to the boot method they
> belong to.
>
> Since `fb_end_reserved_size` is only ever used by `fsp.rs`, it would
> make sense (from an architectural point of view at least) to have it
> defined as a HAL method - even though its name screams "fb". Since they
> are firmware-dependent, I'm even tempted to place their definition as
> constants into `firmware/fw.rs` to make that fact unmistakable (and keep
> all firmware-dependent data in the same place, as missing these upon
> update is a source for headaches). It's not perfectly clean but there is
> precedent for that: `fb.rs` uses `LibosParams` for instance, and
> `GspFwWprMeta` also comes from there.
There's two values used, so a standalone constant in firmware/fw.rs
isn't a good fit IMO. I think putting it in FSP HAL for now makes sense
but we should move it to TLV firmware at some point. Sent a respin of
these remaining patches and I think it addresses your points so PTAL.
Thanks!
>
> <snip>
>> diff --git a/drivers/gpu/nova-core/fsp.rs b/drivers/gpu/nova-core/fsp.rs
>> index 533fb95573ab..a38ba66626d8 100644
>> --- a/drivers/gpu/nova-core/fsp.rs
>> +++ b/drivers/gpu/nova-core/fsp.rs
>> @@ -134,20 +134,31 @@ struct FspCotMessage {
>> }
>>
>> impl FspCotMessage {
>> + /// Computes the FRTS vidmem offset for the Chain-of-Trust message. It is measured from the end
>> + /// of the framebuffer.
>> + fn frts_vidmem_offset(fb_info: &FbSizes) -> Result<u64> {
>> + let mut offset = u64::from(fb_info.fb_end_reserved_size);
>> +
>> + if fb_info.pmu_reserved_size != 0 {
>> + offset = offset
>> + .checked_add(u64::from(fb_info.pmu_reserved_size))
>> + .ok_or(EINVAL)?
>> + // The 2 MiB alignment is r570-specific.
>> + .align_up(Alignment::new::<SZ_2M>())
>> + .ok_or(EINVAL)?;
>
> Note that we are adding two `u32`s and aligning to 2M - so there is no
> risk of overflow. I think we can just document this, use unfallible
> operators, and return a `u64` directly. Although `align_up` will still
> return `Result`, so maybe we need to keep it after all - but the initial
> addition can be unchecked.
next prev parent reply other threads:[~2026-07-24 6:58 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-03 10:22 [PATCH v2 00/10] gpu: nova-core: blackwell follow-ups and fixes Eliot Courtney
2026-07-03 10:22 ` [PATCH v2 01/10] gpu: nova-core: fsp: limit FSP receive message allocation size Eliot Courtney
2026-07-23 2:55 ` Alexandre Courbot
2026-07-03 10:22 ` [PATCH v2 02/10] gpu: nova-core: fsp: catch bogus queue pointer issues Eliot Courtney
2026-07-23 2:55 ` Alexandre Courbot
2026-07-03 10:22 ` [PATCH v2 03/10] gpu: nova-core: gsp: ensure lifetime for FMC boot DMA allocations Eliot Courtney
2026-07-23 2:56 ` Alexandre Courbot
2026-07-03 10:22 ` [PATCH v2 04/10] gpu: nova-core: gsp: ensure LibOS DMA allocation lives long enough Eliot Courtney
2026-07-23 2:56 ` Alexandre Courbot
2026-07-03 10:22 ` [PATCH v2 05/10] gpu: nova-core: split FbLayout into FSP and non-FSP versions Eliot Courtney
2026-07-23 5:02 ` Alexandre Courbot
2026-07-23 6:34 ` Eliot Courtney
2026-07-03 10:22 ` [PATCH v2 06/10] gpu: nova-core: correct FRTS vidmem offset calculation Eliot Courtney
2026-07-23 14:12 ` Alexandre Courbot
2026-07-24 6:58 ` Eliot Courtney [this message]
2026-07-03 10:22 ` [PATCH v2 07/10] gpu: nova-core: rename heap size field Eliot Courtney
2026-07-03 10:22 ` [PATCH v2 08/10] gpu: nova-core: return non-WPR heap size as u64 from HALs Eliot Courtney
2026-07-03 10:22 ` [PATCH v2 09/10] gpu: nova-core: correct RISC-V HALTED field Eliot Courtney
2026-07-23 2:56 ` Alexandre Courbot
2026-07-03 10:22 ` [PATCH v2 10/10] gpu: nova-core: wait for RISC-V HALTED on FSP unload Eliot Courtney
2026-07-23 3:28 ` Alexandre Courbot
2026-07-23 3:59 ` Eliot Courtney
2026-07-23 4:29 ` Alexandre Courbot
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=DK6LU60L9ORM.3QRGRG81VJZO1@nvidia.com \
--to=ecourtney@nvidia.com \
--cc=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=aliceryhl@google.com \
--cc=apopple@nvidia.com \
--cc=dakr@kernel.org \
--cc=dri-devel-bounces@lists.freedesktop.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=gary@garyguo.net \
--cc=jhubbard@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 \
--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