[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DCIZFT5QJ4DT.1XDNISKTQKK56@nvidia.com>
Date: Wed, 03 Sep 2025 16:21:48 +0900
From: "Alexandre Courbot" <acourbot@...dia.com>
To: "Alexandre Courbot" <acourbot@...dia.com>, "Danilo Krummrich"
<dakr@...nel.org>
Cc: "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>, "Joel
Fernandes" <joelagnelf@...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 v3 02/11] gpu: nova-core: move GSP boot code out of
`Gpu` constructor
On Wed Sep 3, 2025 at 4:08 PM JST, Alexandre Courbot wrote:
> On Wed Sep 3, 2025 at 4:53 AM JST, Danilo Krummrich wrote:
>> On Tue Sep 2, 2025 at 4:31 PM CEST, Alexandre Courbot wrote:
>>> diff --git a/drivers/gpu/nova-core/driver.rs b/drivers/gpu/nova-core/driver.rs
>>> index 274989ea1fb4a5e3e6678a08920ddc76d2809ab2..1062014c0a488e959379f009c2e8029ffaa1e2f8 100644
>>> --- a/drivers/gpu/nova-core/driver.rs
>>> +++ b/drivers/gpu/nova-core/driver.rs
>>> @@ -6,6 +6,8 @@
>>>
>>> #[pin_data]
>>> pub(crate) struct NovaCore {
>>> + // Placeholder for the real `Gsp` object once it is built.
>>> + pub(crate) gsp: (),
>>> #[pin]
>>> pub(crate) gpu: Gpu,
>>> _reg: auxiliary::Registration,
>>> @@ -40,8 +42,14 @@ fn probe(pdev: &pci::Device<Core>, _info: &Self::IdInfo) -> Result<Pin<KBox<Self
>>> )?;
>>>
>>> let this = KBox::pin_init(
>>> - try_pin_init!(Self {
>>> + try_pin_init!(&this in Self {
>>> gpu <- Gpu::new(pdev, bar)?,
>>> + gsp <- {
>>> + // SAFETY: `this.gpu` is initialized to a valid value.
>>> + let gpu = unsafe { &(*this.as_ptr()).gpu };
>>> +
>>> + gpu.start_gsp(pdev)?
>>> + },
>>
>> Please use pin_chain() [1] for this.
>
> Sorry, but I couldn't figure out how I can use pin_chain here (and
> couldn't find any relevant example in the kernel code either). Can you
> elaborate a bit?
To be more specific on what I don't get: I see how pin_chain could be
used to initialize a structure which dependent member can take a
temporary value (like a pointer set to `null`), but in this case `gsp`
must be initialized with the result of `start_gsp`, and there is no
"default" valid value for it meanwhile (I use `()` as its type, but it
is a temporary placeholder). But maybe I am just misunderstanding
something about how `pin_chain` can be used.
Powered by blists - more mailing lists