From: "Alexandre Courbot" <acourbot@nvidia.com>
To: "Danilo Krummrich" <dakr@kernel.org>
Cc: <aliceryhl@google.com>, <gary@garyguo.net>,
<nova-gpu@lists.linux.dev>, <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH] gpu: nova-core: use a single try_pin_init!() block in probe()
Date: Mon, 28 Sep 2026 09:23:18 +0900 [thread overview]
Message-ID: <DLQIRUGZ3L4S.2HUCTWWXHIDII@nvidia.com> (raw)
In-Reply-To: <20260927144417.1280385-1-dakr@kernel.org>
On Sun Sep 27, 2026 at 11:44 PM JST, Danilo Krummrich wrote:
> Just like in Gpu::new() a single try_pin_init!() block makes the code
> more readable.
>
> Besides that, it prepares the code for a proper PCI device enable guard
> that we will get soon.
>
> Signed-off-by: Danilo Krummrich <dakr@kernel.org>
> ---
> drivers/gpu/nova-core/driver.rs | 105 ++++++++++++++++----------------
> 1 file changed, 54 insertions(+), 51 deletions(-)
>
> diff --git a/drivers/gpu/nova-core/driver.rs b/drivers/gpu/nova-core/driver.rs
> index bdaed5408a00..623d59dcde6e 100644
> --- a/drivers/gpu/nova-core/driver.rs
> +++ b/drivers/gpu/nova-core/driver.rs
> @@ -100,57 +100,60 @@ fn probe<'bound>(
> pdev: &'bound pci::Device<Core<'_>>,
> _info: Option<&'bound Self::IdInfo>,
> ) -> impl PinInit<Self::Data<'bound>, Error> + 'bound {
> - pin_init::pin_init_scope(move || {
> - dev_dbg!(pdev, "Probe Nova Core GPU driver.\n");
> -
> - pdev.enable_device_mem()?;
> - pdev.set_master();
> -
> - Ok(try_pin_init!(NovaCore {
> - bar: pdev.iomap_region_sized::<BAR0_SIZE>(0, c"nova-core/bar0")?,
> - bar1: {
> - let bar1_idx = bar1_resource_index(pdev)?;
> - pdev.iomap_region(bar1_idx, c"nova-core/bar1")?
> - },
> - // TODO: Use self-referential pin-init syntax once available.
> - gpu <- Gpu::new(
> - pdev,
> - // SAFETY: `bar` is initialized above, pinned, and outlives `gpu`.
> - unsafe { &*core::ptr::from_ref(bar) },
> - // SAFETY: `bar1` is initialized above, pinned, and outlives `gpu`.
> - unsafe { &*core::ptr::from_ref(bar1) },
> - ).pin_chain(|_gpu| {
> - #[cfg(CONFIG_NOVA_CORE_SELFTESTS)]
> - _gpu.run_selftests(pdev);
> - Ok(())
> - }),
> - _reg: {
> - // TODO: Use `&gpu` self-referential pin-init syntax once available.
> - //
> - // SAFETY: `gpu` is initialized before this expression is evaluated
> - // (`try_pin_init!()` initializes fields in initializer order), lives at
> - // a pinned stable address, and is dropped after `_reg` (struct field
> - // drop order).
> - let gpu = unsafe {
> - Pin::new_unchecked(&*core::ptr::from_ref(gpu.as_ref().get_ref()))
> - };
> -
> - // SAFETY: `NovaCore` is dropped when the device is unbound;
> - // i.e. `mem::forget()` is never called on it.
> - unsafe {
> - auxiliary::Registration::new_with_lt(
> - pdev.as_ref(),
> - c"nova-drm",
> - // TODO[XARR]: Use XArray or perhaps IDA for proper ID
> - // allocation/recycling. For now, use a simple atomic counter that
> - // never recycles IDs.
> - AUXILIARY_ID_COUNTER.fetch_add(1, Relaxed),
> - crate::MODULE_NAME,
> - NovaCoreApi { gpu, pdev },
> - )?
> - }
> - },
> - }))
> + dev_dbg!(pdev, "Probe Nova Core GPU driver.\n");
Don't you want to put this in the `_:` block below, so it printed at the
actual initialization time instead of the time the initializer is created?
Not that it matters much, but it sounds slightly more consistent.
Regardless,
Acked-by: Alexandre Courbot <acourbot@nvidia.com>
next prev parent reply other threads:[~2026-09-28 0:23 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-27 14:44 [PATCH] gpu: nova-core: use a single try_pin_init!() block in probe() Danilo Krummrich
2026-09-28 0:23 ` Alexandre Courbot [this message]
2026-09-28 13:48 ` Danilo Krummrich
2026-09-29 20:31 ` John Hubbard
2026-09-29 20:43 ` Danilo Krummrich
2026-09-28 4:17 ` Eliot Courtney
2026-09-28 11:36 ` Gary Guo
2026-09-28 12:00 ` Danilo Krummrich
2026-09-28 12:10 ` Gary Guo
2026-09-28 12:15 ` Danilo Krummrich
2026-09-28 13:53 ` Gary Guo
2026-09-28 13:56 ` Danilo Krummrich
2026-09-29 19:12 ` 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=DLQIRUGZ3L4S.2HUCTWWXHIDII@nvidia.com \
--to=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=gary@garyguo.net \
--cc=nova-gpu@lists.linux.dev \
/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