rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Alexandre Courbot" <acourbot@nvidia.com>
To: "Benno Lossin" <lossin@kernel.org>,
	"Alexandre Courbot" <acourbot@nvidia.com>,
	"Joel Fernandes" <joelagnelf@nvidia.com>,
	"John Hubbard" <jhubbard@nvidia.com>
Cc: "Miguel Ojeda" <miguel.ojeda.sandonis@gmail.com>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"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>,
	"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>,
	"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 v5 02/12] gpu: nova-core: move GSP boot code to a dedicated method
Date: Mon, 15 Sep 2025 13:59:53 +0900	[thread overview]
Message-ID: <DCT3XP3PVHJZ.2T0L221T3HW5R@nvidia.com> (raw)
In-Reply-To: <DCSLPCSQRYOY.3BX3008H5CVQP@kernel.org>

On Sun Sep 14, 2025 at 11:42 PM JST, Benno Lossin wrote:
> On Sun Sep 14, 2025 at 3:49 AM CEST, Alexandre Courbot wrote:
>> On Sun Sep 14, 2025 at 7:06 AM JST, Joel Fernandes wrote:
>>> On Sat, Sep 13, 2025 at 02:29:54PM -0700, John Hubbard wrote:
>>>> Yes. It's only "paranoia" if the code is bug-free. So Rust itself
>>>> naturally will look "a little" paranoid, that's core to its mission. :)
>>>
>>> This seems to be taken out-of-context, I said "paranoia" mainly because I am
>>> not sure if excessive use of pinning may tend to cause other problems. The
>>> "paranoia" is about over-usage of pinning. Personally, I don't prefer to pin
>>> stuff in my code until I absolutely need to, or when I start having needs for
>>> pinning, like using spinlocks. Maybe I am wrong, but the way I learnt Rust,
>>> data movement is baked into it. I am not yet confident pinning will not
>>> constraint Rust code gen -- but that could just be a part of my learning
>>> journey that I have to convince myself it is Ok to do so in advance of
>>> actually requiring it even if you simply hypothetically anticipate needing it
>>> (as Danilo pointed out that in practice this is not an issue and I do tend to
>>> agree with Miguel and Danilo because they are usually right :-D). I am
>>> researching counter examples :-)
>>
>> You can look at the definition for `Pin` in [1], but it is so short we
>> can paste it here:
>>
>>     #[repr(transparent)]
>>     #[derive(Copy, Clone)]
>>     pub struct Pin<Ptr> {
>>         pointer: Ptr,
>>     }
>>
>> There isn't much getting in the way of optimized code generation - its
>> purpose is simply to constraint the acquisition of mutable references to
>> prevent moving the pointee out.
>>
>> I started this patchset a little bit skeptical about the need to pin so
>> many things, but after seeing the recent additions to `pin_init` and
>> rewriting the code as Danilo suggested, it starteds to click. The
>> supposed restrictions are in practice avoided by embracing the concept
>> fully, and in the end I got that feeling (familiar when writing Rust) of
>> being guided towards the right design - a bit like playing bowling with
>> gutter guards.
>
> That's a great way to put it -- I had a similar experience when writing
> pin-init and thinking about it purely theoretically. Good to see that it
> works out in practice (and continues to do so :).
>
>> Yes, that means redesigning and rebasing our code, but that's also the
>> cost of learning a new language.
>>
>> And yes, things can still be a little bit rough around the edges, but
>> there is awareness and action taken to address these issues, at the
>> compiler level when relevant. This makes me confident for the future.
>
> If you have an issue that you cannot work around, or something that
> looks off, let me know. Maybe that's something that pin-init can deal
> better with or we can have another library that helps with it. After all
> pin-init is specially tailored for the kernel to work :)

I was thinking about the lack of access to already-initialized fields in
the initializer when writing this, which has been covered so thanks for
that. :)

One more thing I still don't know how to do without unsafe code is
accessing structurally-pinned members of a pinned object. I had expected
that projection methods would be generated for such members marked
`#[pin]`, but I haven't found anything yet. For instance, we need to
call mutable methods on a pinned member of a pinned object, and the only
way I have found to do this is to use unsafe code. Is there a better
way?


  reply	other threads:[~2025-09-15  5:00 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-11 11:04 [PATCH v5 00/12] gpu: nova-core: process and prepare more firmwares to boot GSP Alexandre Courbot
2025-09-11 11:04 ` [PATCH v5 01/12] gpu: nova-core: require `Send` on `FalconEngine` and `FalconHal` Alexandre Courbot
2025-09-11 11:04 ` [PATCH v5 02/12] gpu: nova-core: move GSP boot code to a dedicated method Alexandre Courbot
2025-09-11 11:22   ` Danilo Krummrich
2025-09-11 12:17     ` Alexandre Courbot
2025-09-11 12:46       ` Danilo Krummrich
2025-09-11 13:26         ` Alexandre Courbot
2025-09-11 14:22           ` Benno Lossin
2025-09-13  1:02           ` Joel Fernandes
2025-09-13 13:30             ` Danilo Krummrich
2025-09-13 17:13               ` Joel Fernandes
2025-09-13 19:53                 ` Danilo Krummrich
2025-09-13 23:02                   ` Joel Fernandes
2025-09-14  7:58                     ` Benno Lossin
2025-09-13 20:37                 ` Miguel Ojeda
2025-09-13 21:16                   ` Joel Fernandes
2025-09-13 21:29                   ` John Hubbard
2025-09-13 22:06                     ` Joel Fernandes
2025-09-14  1:49                       ` Alexandre Courbot
2025-09-14 14:42                         ` Benno Lossin
2025-09-15  4:59                           ` Alexandre Courbot [this message]
2025-09-15  6:44                             ` Benno Lossin
2025-09-11 11:04 ` [PATCH v5 03/12] gpu: nova-core: initialize Gpu structure fully in-place Alexandre Courbot
2025-09-11 11:04 ` [PATCH v5 04/12] gpu: nova-core: add Chipset::name() method Alexandre Courbot
2025-09-11 11:04 ` [PATCH v5 05/12] gpu: nova-core: firmware: move firmware request code into a function Alexandre Courbot
2025-09-11 11:23   ` Danilo Krummrich
2025-09-11 12:18     ` Alexandre Courbot
2025-09-11 11:04 ` [PATCH v5 06/12] gpu: nova-core: firmware: add support for common firmware header Alexandre Courbot
2025-09-11 11:04 ` [PATCH v5 07/12] gpu: nova-core: firmware: process Booter and patch its signature Alexandre Courbot
2025-09-11 11:04 ` [PATCH v5 08/12] gpu: nova-core: firmware: process and prepare the GSP firmware Alexandre Courbot
2025-09-11 11:27   ` Danilo Krummrich
2025-09-11 12:29     ` Alexandre Courbot
2025-09-11 12:31       ` Danilo Krummrich
2025-09-11 11:04 ` [PATCH v5 09/12] gpu: nova-core: firmware: process the GSP bootloader Alexandre Courbot
2025-09-11 11:04 ` [PATCH v5 10/12] gpu: nova-core: firmware: use 570.144 firmware Alexandre Courbot
2025-09-11 11:04 ` [PATCH v5 11/12] gpu: nova-core: Add base files for r570.144 firmware bindings Alexandre Courbot
2025-09-11 11:04 ` [PATCH v5 12/12] gpu: nova-core: compute layout of more framebuffer regions required for GSP Alexandre Courbot
2025-09-11 11:28 ` [PATCH v5 00/12] gpu: nova-core: process and prepare more firmwares to boot GSP Danilo Krummrich

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=DCT3XP3PVHJZ.2T0L221T3HW5R@nvidia.com \
    --to=acourbot@nvidia.com \
    --cc=a.hindborg@kernel.org \
    --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=joelagnelf@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=miguel.ojeda.sandonis@gmail.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).