gpu: nova-core: fix aux device registration for multi-GPU systems
Subsystems (4)
PATCH 1/1 gpu: nova-core: fix aux device registration for multi-GPU systems
The auxiliary device registration was using a hardcoded ID of 0, which caused probe() to fail on multi-GPU systems with:
sysfs: cannot create duplicate filename '/bus/auxiliary/devices/NovaCore.nova-drm.0'
Fix this by using an atomic counter to generate unique IDs for each GPU's aux device registration. The TODO item to eventually use XArray for recycling aux device IDs is retained, but for now, this works very nicely.
This has the side effect of making debugfs[1] work on multi-GPU systems.
[1] https://lore.kernel.org/[email protected]
--- drivers/gpu/nova-core/driver.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
Hi,
This is based on today's (Feb 4, 2026) linux-next/master branch.
thanks,
John Hubbard
drivers/gpu/nova-core/driver.rs +11 -1
@@ -1,5 +1,7 @@// SPDX-License-Identifier: GPL-2.0 +use core::sync::atomic::{AtomicU32 ,Ordering }; +use kernel::{ auxiliary, device::Core ,
@@ -19,6 +21,9 @@use crate ::gpu::Gpu ; +/// Counter for generating unique auxiliary device IDs. +static AUXILIARY_ID_COUNTER :AtomicU32 =AtomicU32 ::new (0 ); +#[pin_data] pub (crate )struct NovaCore { #[pin]
@@ -85,12 +90,17 @@ fn probe(pdev: &pci::Device<Core>, _info: &Self::IdInfo) -> impl PinInit<Self, E GFP_KERNEL, )?; +// TODO[XARR]: Use XArray for proper ID allocation/recycling; for now we use a simple +// atomic counter which never recycles IDs. A unique ID is required for multi-GPU +// systems; without it, probe() fails for all but the first GPU. +let aux_id =AUXILIARY_ID_COUNTER .fetch_add (1 ,Ordering ::Relaxed ); +Ok (try_pin_init! (Self { gpu <-Gpu ::new (pdev, bar.clone (), bar.access (pdev.as_ref ())?), _reg <- auxiliary::Registration ::new ( pdev.as_ref (),c"nova-drm" , -0 ,// TODO[XARR]: Once it lands, use XArray; for now we don't use the ID. + aux_id,crate ::MODULE_NAME ), }))
base-commit: 0f8a890c4524d6e4013ff225e70de2aed7e6d726
Signature · 1 line
2.53.0
Quoted 31 lines · John Hubbard
The auxiliary device registration was using a hardcoded ID of 0, which caused
probe()to fail on multi-GPU systems with:sysfs: cannot create duplicate filename '/bus/auxiliary/devices/NovaCore.nova-drm.0'
Fix this by using an atomic counter to generate unique IDs for each GPU's aux device registration. The TODO item to eventually use XArray for recycling aux device IDs is retained, but for now, this works very nicely.
This has the side effect of making debugfs[1] work on multi-GPU systems.
[1] https://lore.kernel.org/[email protected]
Signed-off-by John Hubbard <[email protected]>--- drivers/gpu/nova-core/driver.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)Hi,
This is based on today's (Feb 4, 2026) linux-next/master branch.
thanks,
John Hubbarddrivers/gpu/nova-core/driver.rs +0
-0
drivers/gpu/nova-core/driver.rs line 3
Quoted 3 lines
drivers/gpu/nova-core/driver.rs +1
-0@@ -1,5 +1,7 @@// SPDX-License-Identifier: GPL-2.0 +use core::sync::atomic::{AtomicU32 ,Ordering };
Somehow the wrong (non-vertical) formatting snuck back into my patch! Arggh. I'll be glad when rustfmt support for this can help me catch this.
Quoted 15 lines
drivers/gpu/nova-core/driver.rs +4
-0+use kernel::{ auxiliary, device::Core ,@@ -19,6 +21,9 @@use crate ::gpu::Gpu ; +/// Counter for generating unique auxiliary device IDs. +static AUXILIARY_ID_COUNTER :AtomicU32 =AtomicU32 ::new (0 ); +#[pin_data] pub (crate )struct NovaCore { #[pin]
drivers/gpu/nova-core/driver.rs fn probe(pdev: &pci::Device<Core>, _info: &Self::IdInfo) -> impl PinInit<Self, E · line 93
Quoted 4 lines
drivers/gpu/nova-core/driver.rs +1
-0@@ -85,12 +90,17 @@ fn probe(pdev: &pci::Device<Core>, _info: &Self::IdInfo) -> impl PinInit<Self, E GFP_KERNEL, )?; +// TODO[XARR]: Use XArray for proper ID allocation/recycling; for now we use a simple
I also did *not* mean to leave the word "we" in there.
Lots of little glitches tonight, sorry about those.
thanks,
Signature · 1 line
John Hubbard
Quoted 16 lines
drivers/gpu/nova-core/driver.rs +5
-1+// atomic counter which never recycles IDs. A unique ID is required for multi-GPU +// systems; without it, probe() fails for all but the first GPU. +let aux_id =AUXILIARY_ID_COUNTER .fetch_add (1 ,Ordering ::Relaxed ); +Ok (try_pin_init! (Self { gpu <-Gpu ::new (pdev, bar.clone (), bar.access (pdev.as_ref ())?), _reg <- auxiliary::Registration ::new ( pdev.as_ref (),c"nova-drm" , -0 ,// TODO[XARR]: Once it lands, use XArray; for now we don't use the ID. + aux_id,crate ::MODULE_NAME ), }))base-commit:
0f8a890c4524d6e4013ff225e70de2aed7e6d726
Gary Guo
reviewerQuoted 11 lines · John Hubbard
The auxiliary device registration was using a hardcoded ID of 0, which caused
probe()to fail on multi-GPU systems with:sysfs: cannot create duplicate filename '/bus/auxiliary/devices/NovaCore.nova-drm.0'
Fix this by using an atomic counter to generate unique IDs for each GPU's aux device registration. The TODO item to eventually use XArray for recycling aux device IDs is retained, but for now, this works very nicely.
This has the side effect of making debugfs[1] work on multi-GPU systems.
Hi John,
Looks like this is something that should be achieved via IDA?
Quoted 20 lines
[1] https://lore.kernel.org/[email protected]
Signed-off-by John Hubbard <[email protected]>--- drivers/gpu/nova-core/driver.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)Hi,
This is based on today's (Feb 4, 2026) linux-next/master branch.
thanks,
John Hubbarddrivers/gpu/nova-core/driver.rs +0
-0
drivers/gpu/nova-core/driver.rs line 3
Quoted 3 lines
drivers/gpu/nova-core/driver.rs +1
-0@@ -1,5 +1,7 @@// SPDX-License-Identifier: GPL-2.0 +use core::sync::atomic::{AtomicU32 ,Ordering };
We're stopping the use of Rust atomics. Please use LKMM atomics available from kernel::sync::atomic.
Best,
Gary
Quoted 35 lines
drivers/gpu/nova-core/driver.rs +10
-1+use kernel::{ auxiliary, device::Core ,@@ -19,6 +21,9 @@use crate ::gpu::Gpu ; +/// Counter for generating unique auxiliary device IDs. +static AUXILIARY_ID_COUNTER :AtomicU32 =AtomicU32 ::new (0 ); +#[pin_data] pub (crate )struct NovaCore { #[pin]@@ -85,12 +90,17 @@ fn probe(pdev: &pci::Device<Core>, _info: &Self::IdInfo) -> impl PinInit<Self, E GFP_KERNEL, )?; +// TODO[XARR]: Use XArray for proper ID allocation/recycling; for now we use a simple +// atomic counter which never recycles IDs. A unique ID is required for multi-GPU +// systems; without it, probe() fails for all but the first GPU. +let aux_id =AUXILIARY_ID_COUNTER .fetch_add (1 ,Ordering ::Relaxed ); +Ok (try_pin_init! (Self { gpu <-Gpu ::new (pdev, bar.clone (), bar.access (pdev.as_ref ())?), _reg <- auxiliary::Registration ::new ( pdev.as_ref (),c"nova-drm" , -0 ,// TODO[XARR]: Once it lands, use XArray; for now we don't use the ID. + aux_id,crate ::MODULE_NAME ), }))base-commit:
0f8a890c4524d6e4013ff225e70de2aed7e6d726
Quoted 10 lines · Gary Guo
Quoted 6 lines
Fix this by using an atomic counter to generate unique IDs for each GPU's aux device registration. The TODO item to eventually use XArray for recycling aux device IDs is retained, but for now, this works very nicely.
This has the side effect of making debugfs[1] work on multi-GPU systems.
Hi John,
Looks like this is something that should be achieved via IDA?
Yes, if you have no need to go from ID to pointer, an IDA is better. That said, as far as I understand what this code is doing, an atomic_t solves the problem just fine and is cheaper.
Danilo Krummrich
maintainerQuoted 8 lines · Matthew Wilcox
Quoted 7 lines · Gary Guo
Quoted 6 lines
Fix this by using an atomic counter to generate unique IDs for each GPU's aux device registration. The TODO item to eventually use XArray for recycling aux device IDs is retained, but for now, this works very nicely.
This has the side effect of making debugfs[1] work on multi-GPU systems.
Quoted 7 lines
Quoted 3 lines
Hi John,
Looks like this is something that should be achieved via IDA?
Yes, if you have no need to go from ID to pointer, an IDA is better. That said, as far as I understand what this code is doing, an
atomic_tsolves the problem just fine and is cheaper.
I agree, for now an atomic should be perfectly fine. Though, with enough patience binding/unbinding the driver from sysfs you can probably make this overflow. :)
The reason for the Xarray TODO is that it is one option for a place where nova-core can store nova-drm / vGPU specific data, once either vGPU or nova-drm attaches to the auxiliary device. But I think there may be better alternatives.
Quoted 17 lines · Danilo Krummrich
Quoted 8 lines · Matthew Wilcox
Quoted 7 lines · Gary Guo
Quoted 6 lines
Fix this by using an atomic counter to generate unique IDs for each GPU's aux device registration. The TODO item to eventually use XArray for recycling aux device IDs is retained, but for now, this works very nicely.
This has the side effect of making debugfs[1] work on multi-GPU systems.
Quoted 7 lines
Quoted 3 lines
Hi John,
Looks like this is something that should be achieved via IDA?
Yes, if you have no need to go from ID to pointer, an IDA is better. That said, as far as I understand what this code is doing, an
atomic_tsolves the problem just fine and is cheaper.
Quoted 7 lines
I agree, for now an atomic should be perfectly fine. Though, with enough patience binding/unbinding the driver from sysfs you can probably make this overflow. :)
The reason for the Xarray TODO is that it is one option for a place where nova-core can store nova-drm / vGPU specific data, once either vGPU or nova-drm attaches to the auxiliary device. But I think there may be better alternatives.
OK, this seems like enough information to post a v2, thanks!
thanks,
Signature · 1 line
John Hubbard