rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joel Fernandes <joelagnelf@nvidia.com>
To: Danilo Krummrich <dakr@kernel.org>
Cc: "Alexandre Courbot" <acourbot@nvidia.com>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Alex Gaynor" <alex.gaynor@gmail.com>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"John Hubbard" <jhubbard@nvidia.com>,
	"Alistair Popple" <apopple@nvidia.com>,
	"Timur Tabi" <ttabi@nvidia.com>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
	nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 02/11] gpu: nova-core: move GSP boot code out of `Gpu` constructor
Date: Thu, 4 Sep 2025 11:28:06 -0400	[thread overview]
Message-ID: <20250904152646.GA1967049@joelbox2> (raw)
In-Reply-To: <DCJ9206YBEV2.1ICN4VILLM09J@kernel.org>

Hi Danilo,

On Wed, Sep 03, 2025 at 04:53:57PM +0200, Danilo Krummrich wrote:
> On Wed Sep 3, 2025 at 2:29 PM CEST, Alexandre Courbot wrote:
> > To be honest I am not completely sure about the best layout yet and will
> > need more visibility to understand whether this is optimal. But
> > considering that we want to run the GSP boot process over a built `Gpu`
> > instance, we cannot store the result of said process inside `Gpu` unless
> > we put it inside e.g. an `Option`. But then the variant will always be
> > `Some` after `probe` returns, and yet we will have to perform a match
> > every time we want to access it.
> >
> > The current separation sounds reasonable to me for the time being, with
> > `Gpu` containing purely hardware resources obtained without help from
> > user-space, while `Gsp` is the result of running a bunch of firmwares.
> > An alternative design would be to store `Gpu` inside `Gsp`, but `Gsp`
> > inside `Gpu` is trickier due to the build order. No matter what we do,
> > switching the layout later should be trivial if we don't choose the
> > best one now.
> 
> Gsp should be part of the Gpu object.

Just checking, if Gsp is a part of Gpu as you mentioned, and start_gsp() is
called from within Gpu::new(), does that not avoid the problem of referring
to fields of pin-initialized structs entirely, at least for this usecase for
nova?  Or is there any nova-related usecase where this is problematic?

thanks,

 - Joel



[...]

> The Gpu object represents the entire
> instance of the Gpu, including hardware ressources, firmware runtime state, etc.
> 
> The initialization of the Gsp structure doesn't really need a Gpu structure to
> be constructed, it needs certain members of the Gpu structure, i.e. order of
> initialization of the members does matter.
> 
> If it makes things more obvious we can always create new types and increase the
> hierarchy within the Gpu struct itself.
> 
> The technical limitation you're facing is always the same, no matter the layout
> we choose: we need pin-init to provide us references to already initialized
> members.
> 
> I will check with Benno in today's Rust call what's the best way to address
> this.
> 
> > There is also an easy workaround to the sibling initialization issue,
> > which is to store `Gpu` and `Gsp` behind `Pin<KBox>` - that way we can
> > initialize both outside `try_pin_init!`, at the cost of two more heap
> > allocations over the whole lifetime of the device. If we don't have a
> > proper solution to the problem now, this might be better than using
> > `unsafe` as a temporary solution.
> 
> Yeah, this workaround is much easier to implement when they're siblings (less
> allocations temporarily), but let's not design things this way because of that.
> 
> As mentioned above, I will check with Benno today.
> 
> > The same workaround could also be used for to `GspFirmware` and its page
> > tables - since `GspFirmware` is temporary and can apparently be
> > discarded after the GSP is booted, this shouldn't be a big issue. This
> > will allow the driver to probe, and we can add TODO items to fix that
> > later if a solution is in sight.
> >
> >>
> >> I thought the intent was to keep temporary values local to start_gsp() and not
> >> store them next to Gpu in the same allocation?
> >
> > It is not visible in the current patchset, but `start_gsp` will
> > eventually return the runtime data of the GSP - notably its log buffers
> > and command queue, which are needed to operate it. All the rest (notably
> > the loaded firmwares) will be local to `start_gsp` and discarded upon
> > its return.
> 
> Ok, that makes sense, but it should really be part of the Gpu structure.

  reply	other threads:[~2025-09-04 15:28 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-02 14:31 [PATCH v3 00/11] gpu: nova-core: process and prepare more firmwares to boot GSP Alexandre Courbot
2025-09-02 14:31 ` [PATCH v3 01/11] gpu: nova-core: require `Send` on `FalconEngine` and `FalconHal` Alexandre Courbot
2025-09-02 14:31 ` [PATCH v3 02/11] gpu: nova-core: move GSP boot code out of `Gpu` constructor Alexandre Courbot
2025-09-02 19:53   ` Danilo Krummrich
2025-09-03  7:08     ` Alexandre Courbot
2025-09-03  7:21       ` Alexandre Courbot
2025-09-03  8:26       ` Danilo Krummrich
2025-09-03 10:44         ` Alexandre Courbot
2025-09-03 11:05           ` Danilo Krummrich
2025-09-03 12:29             ` Alexandre Courbot
2025-09-03 14:53               ` Danilo Krummrich
2025-09-04 15:28                 ` Joel Fernandes [this message]
2025-09-02 23:12   ` Danilo Krummrich
2025-09-03  7:10     ` Alexandre Courbot
2025-09-03  8:27       ` Danilo Krummrich
2025-09-02 14:31 ` [PATCH v3 03/11] gpu: nova-core: add Chipset::name() method Alexandre Courbot
2025-09-02 14:31 ` [PATCH v3 04/11] gpu: nova-core: firmware: move firmware request code into a function Alexandre Courbot
2025-09-02 14:31 ` [PATCH v3 05/11] gpu: nova-core: firmware: add support for common firmware header Alexandre Courbot
2025-09-02 14:32 ` [PATCH v3 06/11] gpu: nova-core: firmware: process Booter and patch its signature Alexandre Courbot
2025-09-02 14:32 ` [PATCH v3 07/11] gpu: nova-core: firmware: process and prepare the GSP firmware Alexandre Courbot
2025-09-02 14:32 ` [PATCH v3 08/11] gpu: nova-core: firmware: process the GSP bootloader Alexandre Courbot
2025-09-02 14:32 ` [PATCH v3 09/11] gpu: nova-core: firmware: use 570.144 firmware Alexandre Courbot
2025-09-02 14:32 ` [PATCH v3 10/11] gpu: nova-core: Add base files for r570.144 firmware bindings Alexandre Courbot
2025-09-02 14:32 ` [PATCH v3 11/11] gpu: nova-core: compute layout of more framebuffer regions required for GSP 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=20250904152646.GA1967049@joelbox2 \
    --to=joelagnelf@nvidia.com \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=airlied@gmail.com \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=apopple@nvidia.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@kernel.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=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=nouveau@lists.freedesktop.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tmgross@umich.edu \
    --cc=ttabi@nvidia.com \
    --cc=tzimmermann@suse.de \
    /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;
as well as URLs for NNTP newsgroup(s).