Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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/20260203224757.871729-1-ttabi@nvidia.com

Reviewed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
Link: https://patch.msgid.link/20260221020952.412352-2-jhubbard@nvidia.com
[ Use LKMM atomics; inline and slightly reword TODO comment. - Danilo ]
Signed-off-by: Danilo Krummrich <dakr@kernel.org>

authored by

John Hubbard and committed by
Danilo Krummrich
d3f36fa5 8d1a65c2

+13 -2
+13 -2
drivers/gpu/nova-core/driver.rs
··· 14 14 }, 15 15 prelude::*, 16 16 sizes::SZ_16M, 17 - sync::Arc, // 17 + sync::{ 18 + atomic::{ 19 + Atomic, 20 + Relaxed, // 21 + }, 22 + Arc, 23 + }, 18 24 }; 19 25 20 26 use crate::gpu::Gpu; 27 + 28 + /// Counter for generating unique auxiliary device IDs. 29 + static AUXILIARY_ID_COUNTER: Atomic<u32> = Atomic::new(0); 21 30 22 31 #[pin_data] 23 32 pub(crate) struct NovaCore { ··· 99 90 _reg <- auxiliary::Registration::new( 100 91 pdev.as_ref(), 101 92 c"nova-drm", 102 - 0, // TODO[XARR]: Once it lands, use XArray; for now we don't use the ID. 93 + // TODO[XARR]: Use XArray or perhaps IDA for proper ID allocation/recycling. For 94 + // now, use a simple atomic counter that never recycles IDs. 95 + AUXILIARY_ID_COUNTER.fetch_add(1, Relaxed), 103 96 crate::MODULE_NAME 104 97 ), 105 98 }))