[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DCRPJKD0UHDQ.IOWSOB2IK06E@kernel.org>
Date: Sat, 13 Sep 2025 15:30:31 +0200
From: "Danilo Krummrich" <dakr@...nel.org>
To: "Joel Fernandes" <joelagnelf@...dia.com>
Cc: "Alexandre Courbot" <acourbot@...dia.com>, "Miguel Ojeda"
<ojeda@...nel.org>, "Alex Gaynor" <alex.gaynor@...il.com>, "Boqun Feng"
<boqun.feng@...il.com>, "Gary Guo" <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>, "Benno Lossin"
<lossin@...nel.org>, "Andreas Hindborg" <a.hindborg@...nel.org>, "Alice
Ryhl" <aliceryhl@...gle.com>, "Trevor Gross" <tmgross@...ch.edu>, "David
Airlie" <airlied@...il.com>, "Simona Vetter" <simona@...ll.ch>, "Maarten
Lankhorst" <maarten.lankhorst@...ux.intel.com>, "Maxime Ripard"
<mripard@...nel.org>, "Thomas Zimmermann" <tzimmermann@...e.de>, "John
Hubbard" <jhubbard@...dia.com>, "Alistair Popple" <apopple@...dia.com>,
"Timur Tabi" <ttabi@...dia.com>, <rust-for-linux@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <nouveau@...ts.freedesktop.org>,
<dri-devel@...ts.freedesktop.org>
Subject: Re: [PATCH v5 02/12] gpu: nova-core: move GSP boot code to a
dedicated method
On Sat Sep 13, 2025 at 3:02 AM CEST, Joel Fernandes wrote:
> Any chance we can initialize the locks later? We don't need locking until
> after the boot process is completed, and if there's a way we can dynamically
> "pin", where we hypothetically pin after the boot process completed, that
> might also work. Though I am not sure if that's something possible in
> Rust/rust4linux or if it makes sense.
We can't partially initialize structures and then rely on accessing initialized
data only. This is one of the sources for memory bugs that Rust tries to solve.
You can wrap fields into Option types and initialize them later, which would
defer pin-init calls for the price of having Option fields around.
However, we should never do such things. If there's the necessity to do
something like that, it indicates a design issue.
In this case, there's no problem, we can use pin-init without any issues right
away, and should do so.
pin-init is going to be an essential part of *every* Rust driver given that a
lot of the C infrastruture that we abstract requires pinned initialization, such
as locks and other synchronization primitives.
Powered by blists - more mailing lists