* [PATCH] gpu: nova-core: use a single try_pin_init!() block in probe()
@ 2026-09-27 14:44 Danilo Krummrich
2026-09-28 0:23 ` Alexandre Courbot
` (3 more replies)
0 siblings, 4 replies; 13+ messages in thread
From: Danilo Krummrich @ 2026-09-27 14:44 UTC (permalink / raw)
To: dakr, acourbot, aliceryhl, gary; +Cc: nova-gpu, dri-devel
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");
+
+ try_pin_init!(NovaCore {
+ _: {
+ pdev.enable_device_mem()?;
+ pdev.set_master();
+ },
+
+ 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 },
+ )?
+ }
+ },
})
}
}
base-commit: 10a6623a24a85708650efad7be15182289403cd7
--
2.55.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH] gpu: nova-core: use a single try_pin_init!() block in probe()
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
2026-09-28 13:48 ` Danilo Krummrich
2026-09-28 4:17 ` Eliot Courtney
` (2 subsequent siblings)
3 siblings, 1 reply; 13+ messages in thread
From: Alexandre Courbot @ 2026-09-28 0:23 UTC (permalink / raw)
To: Danilo Krummrich; +Cc: aliceryhl, gary, nova-gpu, dri-devel
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>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] gpu: nova-core: use a single try_pin_init!() block in probe()
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
@ 2026-09-28 4:17 ` Eliot Courtney
2026-09-28 11:36 ` Gary Guo
2026-09-29 19:12 ` Danilo Krummrich
3 siblings, 0 replies; 13+ messages in thread
From: Eliot Courtney @ 2026-09-28 4:17 UTC (permalink / raw)
To: Danilo Krummrich, acourbot, aliceryhl, gary
Cc: nova-gpu, dri-devel, dri-devel
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>
> ---
Reviewed-by: Eliot Courtney <ecourtney@nvidia.com>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] gpu: nova-core: use a single try_pin_init!() block in probe()
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
2026-09-28 4:17 ` Eliot Courtney
@ 2026-09-28 11:36 ` Gary Guo
2026-09-28 12:00 ` Danilo Krummrich
2026-09-29 19:12 ` Danilo Krummrich
3 siblings, 1 reply; 13+ messages in thread
From: Gary Guo @ 2026-09-28 11:36 UTC (permalink / raw)
To: Danilo Krummrich, acourbot, aliceryhl, gary; +Cc: nova-gpu, dri-devel
On Sun Sep 27, 2026 at 3:44 PM BST, 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");
> +
> + try_pin_init!(NovaCore {
> + _: {
> + pdev.enable_device_mem()?;
> + pdev.set_master();
> + },
> +
> + 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(())
> + }),
I think this doesn't need to use `pin_chain`? You can do
gpu <- ...,
_: {
#[cfg(...)]
gpu.run_self_tests(pdev);
}
I know this is pre-existing but given that you're tidying it up this might do as
well.
Best,
Gary
> +
> + _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 },
> + )?
> + }
> + },
> })
> }
> }
>
> base-commit: 10a6623a24a85708650efad7be15182289403cd7
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] gpu: nova-core: use a single try_pin_init!() block in probe()
2026-09-28 11:36 ` Gary Guo
@ 2026-09-28 12:00 ` Danilo Krummrich
2026-09-28 12:10 ` Gary Guo
0 siblings, 1 reply; 13+ messages in thread
From: Danilo Krummrich @ 2026-09-28 12:00 UTC (permalink / raw)
To: Gary Guo; +Cc: acourbot, aliceryhl, nova-gpu, dri-devel
On Mon Sep 28, 2026 at 1:36 PM CEST, Gary Guo wrote:
> I think this doesn't need to use `pin_chain`? You can do
>
> gpu <- ...,
>
> _: {
> #[cfg(...)]
> gpu.run_self_tests(pdev);
> }
Unfortunately, this produces the following error.
error[E0382]: borrow of moved value: `gpu`
--> drivers/gpu/nova-core/driver.rs:140:62
|
119 | gpu <- Gpu::new(
| --- move occurs because `gpu` has type `core::pin::Pin<&mut gpu::Gpu<'_>>`, which does not implement the `Copy` trait
...
129 | gpu.run_selftests(pdev);
| --- value moved here
...
140 | Pin::new_unchecked(&*core::ptr::from_ref(gpu.as_ref().get_ref()))
| ^^^ value borrowed here after move
error: aborting due to 1 previous error
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] gpu: nova-core: use a single try_pin_init!() block in probe()
2026-09-28 12:00 ` Danilo Krummrich
@ 2026-09-28 12:10 ` Gary Guo
2026-09-28 12:15 ` Danilo Krummrich
0 siblings, 1 reply; 13+ messages in thread
From: Gary Guo @ 2026-09-28 12:10 UTC (permalink / raw)
To: Danilo Krummrich, Gary Guo; +Cc: acourbot, aliceryhl, nova-gpu, dri-devel
On Mon Sep 28, 2026 at 1:00 PM BST, Danilo Krummrich wrote:
> On Mon Sep 28, 2026 at 1:36 PM CEST, Gary Guo wrote:
>> I think this doesn't need to use `pin_chain`? You can do
>>
>> gpu <- ...,
>>
>> _: {
>> #[cfg(...)]
>> gpu.run_self_tests(pdev);
>> }
>
> Unfortunately, this produces the following error.
>
> error[E0382]: borrow of moved value: `gpu`
> --> drivers/gpu/nova-core/driver.rs:140:62
> |
> 119 | gpu <- Gpu::new(
> | --- move occurs because `gpu` has type `core::pin::Pin<&mut gpu::Gpu<'_>>`, which does not implement the `Copy` trait
> ...
> 129 | gpu.run_selftests(pdev);
> | --- value moved here
gpu.as_mut().run_selftests(pdev);
should work?
Best,
Gary
> ...
> 140 | Pin::new_unchecked(&*core::ptr::from_ref(gpu.as_ref().get_ref()))
> | ^^^ value borrowed here after move
>
> error: aborting due to 1 previous error
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] gpu: nova-core: use a single try_pin_init!() block in probe()
2026-09-28 12:10 ` Gary Guo
@ 2026-09-28 12:15 ` Danilo Krummrich
2026-09-28 13:53 ` Gary Guo
0 siblings, 1 reply; 13+ messages in thread
From: Danilo Krummrich @ 2026-09-28 12:15 UTC (permalink / raw)
To: Gary Guo; +Cc: acourbot, aliceryhl, nova-gpu, dri-devel
On Mon Sep 28, 2026 at 2:10 PM CEST, Gary Guo wrote:
> On Mon Sep 28, 2026 at 1:00 PM BST, Danilo Krummrich wrote:
>> On Mon Sep 28, 2026 at 1:36 PM CEST, Gary Guo wrote:
>>> I think this doesn't need to use `pin_chain`? You can do
>>>
>>> gpu <- ...,
>>>
>>> _: {
>>> #[cfg(...)]
>>> gpu.run_self_tests(pdev);
>>> }
>>
>> Unfortunately, this produces the following error.
>>
>> error[E0382]: borrow of moved value: `gpu`
>> --> drivers/gpu/nova-core/driver.rs:140:62
>> |
>> 119 | gpu <- Gpu::new(
>> | --- move occurs because `gpu` has type `core::pin::Pin<&mut gpu::Gpu<'_>>`, which does not implement the `Copy` trait
>> ...
>> 129 | gpu.run_selftests(pdev);
>> | --- value moved here
>
> gpu.as_mut().run_selftests(pdev);
>
> should work?
I tried that previously, that gives another error. I didn't dig in further
though.
error[E0596]: cannot borrow `gpu` as mutable, as it is not declared as mutable
--> drivers/gpu/nova-core/driver.rs:129:17
|
129 | gpu.as_mut().run_selftests(pdev);
| ^^^ cannot borrow as mutable
|
help: consider changing this to be mutable
|
119 | mut gpu <- Gpu::new(
| +++
error: aborting due to 1 previous error
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] gpu: nova-core: use a single try_pin_init!() block in probe()
2026-09-28 0:23 ` Alexandre Courbot
@ 2026-09-28 13:48 ` Danilo Krummrich
2026-09-29 20:31 ` John Hubbard
0 siblings, 1 reply; 13+ messages in thread
From: Danilo Krummrich @ 2026-09-28 13:48 UTC (permalink / raw)
To: Alexandre Courbot; +Cc: aliceryhl, gary, nova-gpu, dri-devel
On Mon Sep 28, 2026 at 2:23 AM CEST, Alexandre Courbot wrote:
>> + 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?
No, because the :_ block below will become the PCI device enable guard soon. We
could put it in a separate :_ block, but that seemed odd to me.
In any case, we probably should drop this dev_dbg!() entirely, as its value is
quite limited.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] gpu: nova-core: use a single try_pin_init!() block in probe()
2026-09-28 12:15 ` Danilo Krummrich
@ 2026-09-28 13:53 ` Gary Guo
2026-09-28 13:56 ` Danilo Krummrich
0 siblings, 1 reply; 13+ messages in thread
From: Gary Guo @ 2026-09-28 13:53 UTC (permalink / raw)
To: Danilo Krummrich, Gary Guo; +Cc: acourbot, aliceryhl, nova-gpu, dri-devel
On Mon Sep 28, 2026 at 1:15 PM BST, Danilo Krummrich wrote:
> On Mon Sep 28, 2026 at 2:10 PM CEST, Gary Guo wrote:
>> On Mon Sep 28, 2026 at 1:00 PM BST, Danilo Krummrich wrote:
>>> On Mon Sep 28, 2026 at 1:36 PM CEST, Gary Guo wrote:
>>>> I think this doesn't need to use `pin_chain`? You can do
>>>>
>>>> gpu <- ...,
>>>>
>>>> _: {
>>>> #[cfg(...)]
>>>> gpu.run_self_tests(pdev);
>>>> }
>>>
>>> Unfortunately, this produces the following error.
>>>
>>> error[E0382]: borrow of moved value: `gpu`
>>> --> drivers/gpu/nova-core/driver.rs:140:62
>>> |
>>> 119 | gpu <- Gpu::new(
>>> | --- move occurs because `gpu` has type `core::pin::Pin<&mut gpu::Gpu<'_>>`, which does not implement the `Copy` trait
>>> ...
>>> 129 | gpu.run_selftests(pdev);
>>> | --- value moved here
>>
>> gpu.as_mut().run_selftests(pdev);
>>
>> should work?
>
> I tried that previously, that gives another error. I didn't dig in further
> though.
>
> error[E0596]: cannot borrow `gpu` as mutable, as it is not declared as mutable
> --> drivers/gpu/nova-core/driver.rs:129:17
> |
> 129 | gpu.as_mut().run_selftests(pdev);
> | ^^^ cannot borrow as mutable
> |
> help: consider changing this to be mutable
> |
> 119 | mut gpu <- Gpu::new(
> | +++
>
> error: aborting due to 1 previous error
Right, we didn't create the let binding with `mut`.
Does this fix it for you?
diff --git a/rust/pin-init/internal/src/init.rs b/rust/pin-init/internal/src/init.rs
index c5b5a0ce5c4e..031adb46cefe 100644
--- a/rust/pin-init/internal/src/init.rs
+++ b/rust/pin-init/internal/src/init.rs
@@ -446,7 +446,7 @@ fn init_fields(fields: &Punctuated<InitializerField, Token![,]>, pinned: bool) -
// Allow `non_snake_case` since the same warning is going to be reported for the
// struct field.
#[allow(unused_variables, non_snake_case)]
- let #ident = #guard.let_binding();
+ let mut #ident = #guard.let_binding();
},
Member::Unnamed(_) => quote!(),
};
Best,
Gary
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH] gpu: nova-core: use a single try_pin_init!() block in probe()
2026-09-28 13:53 ` Gary Guo
@ 2026-09-28 13:56 ` Danilo Krummrich
0 siblings, 0 replies; 13+ messages in thread
From: Danilo Krummrich @ 2026-09-28 13:56 UTC (permalink / raw)
To: Gary Guo; +Cc: acourbot, aliceryhl, nova-gpu, dri-devel
On Mon Sep 28, 2026 at 3:53 PM CEST, Gary Guo wrote:
> Does this fix it for you?
Yes, it does, thanks!
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] gpu: nova-core: use a single try_pin_init!() block in probe()
2026-09-27 14:44 [PATCH] gpu: nova-core: use a single try_pin_init!() block in probe() Danilo Krummrich
` (2 preceding siblings ...)
2026-09-28 11:36 ` Gary Guo
@ 2026-09-29 19:12 ` Danilo Krummrich
3 siblings, 0 replies; 13+ messages in thread
From: Danilo Krummrich @ 2026-09-29 19:12 UTC (permalink / raw)
To: Danilo Krummrich; +Cc: acourbot, aliceryhl, gary, nova-gpu, dri-devel
On Sun, 27 Sep 2026 16:44:03 +0200, Danilo Krummrich wrote:
> [PATCH] gpu: nova-core: use a single try_pin_init!() block in probe()
Applied, thanks!
Branch: drm-rust-next
Tree: https://gitlab.freedesktop.org/drm/rust/kernel.git
[1/1] gpu: nova-core: use a single try_pin_init!() block in probe()
commit: 658c5f0042e6
[ Drop useless dev_dbg!() in probe(). - Danilo ]
The patch will appear in the next linux-next integration (typically within 24
hours on weekdays).
The patch is queued up for the upcoming merge window for the next major kernel
release.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] gpu: nova-core: use a single try_pin_init!() block in probe()
2026-09-28 13:48 ` Danilo Krummrich
@ 2026-09-29 20:31 ` John Hubbard
2026-09-29 20:43 ` Danilo Krummrich
0 siblings, 1 reply; 13+ messages in thread
From: John Hubbard @ 2026-09-29 20:31 UTC (permalink / raw)
To: Danilo Krummrich, Alexandre Courbot; +Cc: aliceryhl, gary, nova-gpu, dri-devel
On 9/28/26 6:48 AM, Danilo Krummrich wrote:
> On Mon Sep 28, 2026 at 2:23 AM CEST, Alexandre Courbot wrote:
>>> + 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?
>
> No, because the :_ block below will become the PCI device enable guard soon. We
> could put it in a separate :_ block, but that seemed odd to me.
>
> In any case, we probably should drop this dev_dbg!() entirely, as its value is
> quite limited.
I missed this comment until just now, when I went to test with the final
merged patch, and the "Probe..." debug print for each GPU was missing.
I really would like this restored. This is a high value thing to
print, because it acts as kind of a bookend, showing the beginning of
trying to boot up.
In fact, we even have some local scripts that look for it (not that
that matters, but just to indicate how we think about its usefulness).
I can post a trivial patch to restore it, if desired.
thanks,
--
John Hubbard
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] gpu: nova-core: use a single try_pin_init!() block in probe()
2026-09-29 20:31 ` John Hubbard
@ 2026-09-29 20:43 ` Danilo Krummrich
0 siblings, 0 replies; 13+ messages in thread
From: Danilo Krummrich @ 2026-09-29 20:43 UTC (permalink / raw)
To: John Hubbard; +Cc: Alexandre Courbot, aliceryhl, gary, nova-gpu, dri-devel
On Tue Sep 29, 2026 at 10:31 PM CEST, John Hubbard wrote:
> I really would like this restored. This is a high value thing to
> print, because it acts as kind of a bookend, showing the beginning of
> trying to boot up.
Hm...the next print in the boot process is
nova-core 0000:01:00.0: NVIDIA (Chipset: GA106, Architecture: Ampere, Revision: a.1)
which is at the very beginning of probe and to me seems sufficient.
But a debug print doesn't hurt, so if you prefer to keep it, no concerns from my
end.
> I can post a trivial patch to restore it, if desired.
That'd be great, thanks!
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2026-09-29 20:43 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox