public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: "Gary Guo" <gary@garyguo.net>
To: "Timur Tabi" <ttabi@nvidia.com>,
	"gary@garyguo.net" <gary@garyguo.net>,
	"Alexandre Courbot" <acourbot@nvidia.com>
Cc: "Joel Fernandes" <joelagnelf@nvidia.com>,
	"dakr@kernel.org" <dakr@kernel.org>,
	"Eliot Courtney" <ecourtney@nvidia.com>,
	"John Hubbard" <jhubbard@nvidia.com>,
	"rust-for-linux@vger.kernel.org" <rust-for-linux@vger.kernel.org>
Subject: Re: [PATCH v5 4/6] gpu: nova-core: add FbHal::frts_size() for GA100 support
Date: Mon, 20 Apr 2026 21:27:29 +0100	[thread overview]
Message-ID: <DHY9K4KOTNP3.1DU2132JVNLJU@garyguo.net> (raw)
In-Reply-To: <a2bb46f8cb312643ea5997ab4b58042850554a0c.camel@nvidia.com>

On Mon Apr 20, 2026 at 6:51 PM BST, Timur Tabi wrote:
> On Mon, 2026-04-20 at 21:50 +0900, Alexandre Courbot wrote:
>> > Or better, use a boolean, I find Nouveau's C code clearer in this regard:
>> > 
>> >      /*
>> >  	 * Calculate FB layout. FRTS is a memory region created by the FWSEC-FRTS firmware.
>> >  	 * FWSEC comes from VBIOS.  So on systems with no VBIOS (e.g. GA100), the FRTS does
>> >  	 * not exist.  Therefore, use the existence of VBIOS to determine whether to reserve
>> >  	 * an FRTS region.
>> >  	 */
>> >  	gsp->fb.wpr2.frts.size = device->bios ? 0x100000 : 0;
>
> So first, this code in Nouveau is actually wrong, and I have a patchset pending upstream that fixes
> it.  This is the new version:

Ah, I see, so this is what the "supports_display" refers to in the commit
message?

It's not instinctively the same concept in my mind, but it makes sense now you
explained it.

>
> 	gsp->fb.wpr2.frts.size = device->chipset == 0x170 ? 0 : 0x100000;
>
> So this really needs to be a HAL-specific implementation.  For better or worse, we're actively
> trying to avoid code like this in Nova:
>
> 	if chipset is X or Y
> 	{
> 		// do this
> 	} else {
> 		// do that
> 	}
>
>> > 
>> > so we could simiarly do
>> > 
>> >      fn has_frts(&self) -> bool;
>> > 
>> > Or
>> > 
>> >      fn has_vbios(&self) -> bool;
>> > 
>> 
>> The boolean-based approach might make more sense if there is really no
>> other possible size for the FRTS (which the Nouveau code seems to
>> suggest). I'll let Timur answer that one.
>
> I think there is something that everyone needs to understand.  99% of this stuff is completely
> arbitrary.  Someone, somewhere decided that FRTS is normally 1MB, but for some reason on GA100 it's
> 0.  It's not because GA100 doesn't have display hardware, because there are other GPUs that also
> don't have it but the FRTS is still 1MB.  
>
> So there's no reason to believe that in some future version of hardware and/or software, there might
> be a bigger or smaller FRTS.  If it really were an either-or thing, then it would have been defined
> as a boolean in our firmware data structures.
>
> The other thing to keep in mind is that a lot of this code is based on OpenRM.  One thing you need
> to understand is that RM is GPU HAL-happy.  We have this weird in-house object-oriented C variant
> that makes it trivial to HAL-ify any code.  So as soon as there is even the slightest difference
> between any two GPUs -- boom! make it a HAL!  There are a bunch of places in RM that are implemented
> as HALs that could be implemented more abstractly, but just aren't.  So if that's how RM does it,
> then that's how Nova is going to do it.
>
>> > (BTW, I suppose the FRTS region really does not exist, but the start address
>> > matters because firmware does some checks on the start address to ensure it's
>> > within a specific region regardless whether the size is 0?)
>> 
>> And that one as well. :)
>
> The FRTS region *does* exist, but its size is zero.  This is because the start address is still
> needed.  
>
> Some parts of GSP-RM will look at frts_size, see that it's zero, and then bail early.  For example,
> here's one code snippet from GSP-RM:
>
>     if (size == 0)
>     {
>         return NV_TRUE;
>     }
>
> But elsewhere in the same file is this:
>
>     rmLibosConfigInfo.gfwSrMem.pa = wprApertureStart + pWprMeta->frtsOffset + pWprMeta->frtsSize;
>
> So I guess what I'm really trying to say is that I've done a lot of research into how this code
> works, and it's written the way I wrote it for a reason.
>
> As for using a Trait to define a default value that is just overridden by GA100, that would be okay,
> but it wouldn't be any clearer or more accurate.
>
> I personally don't like `super::tu102::frts_size_tu102()` and I think both tu102::frts_size() and
> ga102::frts_size() should just return u64::SZ_1M, but I don't care enough to make a stink about it.

Thanks, that's a very good explanation how the reason the code is written as is.
With the information above, I'm happy with current approach.

Acked-by: Gary Guo <gary@garyguo.net>

I think it's important to note that not all of us have knowledge (or even
access) to some of the context that you have, so something that may seem obvious
to you could require some additional background or reasons to be added in commit
message or comment.

Also, in the commit message you mentioned

> Introduce FbHal method frts_size() to return the size of the FRTS
> window.  GA100 is a special case in that there is no FRTS, and so
> the size must be set to 0.

and this probably should be corrected.

Thanks,
Gary

  reply	other threads:[~2026-04-20 20:27 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-17 19:13 [PATCH v5 0/6] gpu: nova-core: add GA100 support Timur Tabi
2026-04-17 19:13 ` [PATCH v5 1/6] gpu: nova-core: use correct fwsignature for GA100 Timur Tabi
2026-04-19 19:34   ` Gary Guo
2026-04-17 19:13 ` [PATCH v5 2/6] gpu: nova-core: do not consider 0xBB77 as a valid PCI ROM header signature Timur Tabi
2026-04-19 19:36   ` Gary Guo
2026-04-17 19:13 ` [PATCH v5 3/6] gpu: nova-core: only boot FRTS if its region is allocated Timur Tabi
2026-04-19 19:36   ` Gary Guo
2026-04-17 19:13 ` [PATCH v5 4/6] gpu: nova-core: add FbHal::frts_size() for GA100 support Timur Tabi
2026-04-19 19:47   ` Gary Guo
2026-04-20  1:28     ` Alexandre Courbot
2026-04-20 10:23       ` Gary Guo
2026-04-20 12:50         ` Alexandre Courbot
2026-04-20 17:51           ` Timur Tabi
2026-04-20 20:27             ` Gary Guo [this message]
2026-04-20 21:15               ` Timur Tabi
2026-04-21  1:22                 ` Alexandre Courbot
2026-04-17 19:13 ` [PATCH v5 5/6] gpu: nova-core: skip the IFR header if present Timur Tabi
2026-04-20  6:37   ` Eliot Courtney
2026-04-17 19:13 ` [PATCH v5 6/6] gpu: nova-core: enable GA100 Timur Tabi
2026-04-19 19:36   ` Gary Guo

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=DHY9K4KOTNP3.1DU2132JVNLJU@garyguo.net \
    --to=gary@garyguo.net \
    --cc=acourbot@nvidia.com \
    --cc=dakr@kernel.org \
    --cc=ecourtney@nvidia.com \
    --cc=jhubbard@nvidia.com \
    --cc=joelagnelf@nvidia.com \
    --cc=rust-for-linux@vger.kernel.org \
    --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