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

gpu: nova-core: take bound device in Gpu::new

We will need to perform things like allocating DMA memory during device
creation, so make sure to take the device context that will allow us to
perform these actions. This also allows us to use Devres::access to
obtain the BAR without holding a RCU lock.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Link: https://lore.kernel.org/r/20250507-nova-frts-v3-4-fcb02749754d@nvidia.com
Signed-off-by: Danilo Krummrich <dakr@kernel.org>

authored by

Alexandre Courbot and committed by
Danilo Krummrich
a2a637ff 44dda435

+13 -6
+13 -6
drivers/gpu/nova-core/gpu.rs
··· 134 134 } 135 135 136 136 impl Spec { 137 - fn new(bar: &Devres<Bar0>) -> Result<Spec> { 138 - let bar = bar.try_access().ok_or(ENXIO)?; 139 - let boot0 = regs::Boot0::read(&bar); 137 + fn new(bar: &Bar0) -> Result<Spec> { 138 + let boot0 = regs::Boot0::read(bar); 140 139 141 140 Ok(Self { 142 141 chipset: boot0.chipset().try_into()?, ··· 182 183 } 183 184 184 185 impl Gpu { 185 - pub(crate) fn new(pdev: &pci::Device, bar: Devres<Bar0>) -> Result<impl PinInit<Self>> { 186 - let spec = Spec::new(&bar)?; 186 + pub(crate) fn new( 187 + pdev: &pci::Device<device::Bound>, 188 + devres_bar: Devres<Bar0>, 189 + ) -> Result<impl PinInit<Self>> { 190 + let bar = devres_bar.access(pdev.as_ref())?; 191 + let spec = Spec::new(bar)?; 187 192 let fw = Firmware::new(pdev.as_ref(), &spec, "535.113.01")?; 188 193 189 194 dev_info!( ··· 198 195 spec.revision 199 196 ); 200 197 201 - Ok(pin_init!(Self { spec, bar, fw })) 198 + Ok(pin_init!(Self { 199 + spec, 200 + bar: devres_bar, 201 + fw 202 + })) 202 203 } 203 204 }