diff options
author | Alexandre Courbot <acourbot@nvidia.com> | 2025-05-07 22:52:31 +0900 |
---|---|---|
committer | Danilo Krummrich <dakr@kernel.org> | 2025-05-13 14:15:42 +0200 |
commit | a2a637ffdf8692e9a376383ca82a990036424fe0 (patch) | |
tree | f332c31752aa241436bfd97c31b684486e26b9c3 /drivers/gpu/nova-core/gpu.rs | |
parent | 44dda4353b9bd5dcc9cc30d97c0c3cfb00d8f987 (diff) |
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>
Diffstat (limited to 'drivers/gpu/nova-core/gpu.rs')
-rw-r--r-- | drivers/gpu/nova-core/gpu.rs | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/drivers/gpu/nova-core/gpu.rs b/drivers/gpu/nova-core/gpu.rs index 9fe6aedaa956..a64a306e0ec8 100644 --- a/drivers/gpu/nova-core/gpu.rs +++ b/drivers/gpu/nova-core/gpu.rs @@ -134,9 +134,8 @@ pub(crate) struct Spec { } impl Spec { - fn new(bar: &Devres<Bar0>) -> Result<Spec> { - let bar = bar.try_access().ok_or(ENXIO)?; - let boot0 = regs::Boot0::read(&bar); + fn new(bar: &Bar0) -> Result<Spec> { + let boot0 = regs::Boot0::read(bar); Ok(Self { chipset: boot0.chipset().try_into()?, @@ -183,8 +182,12 @@ pub(crate) struct Gpu { } impl Gpu { - pub(crate) fn new(pdev: &pci::Device, bar: Devres<Bar0>) -> Result<impl PinInit<Self>> { - let spec = Spec::new(&bar)?; + pub(crate) fn new( + pdev: &pci::Device<device::Bound>, + devres_bar: Devres<Bar0>, + ) -> Result<impl PinInit<Self>> { + let bar = devres_bar.access(pdev.as_ref())?; + let spec = Spec::new(bar)?; let fw = Firmware::new(pdev.as_ref(), &spec, "535.113.01")?; dev_info!( @@ -195,6 +198,10 @@ impl Gpu { spec.revision ); - Ok(pin_init!(Self { spec, bar, fw })) + Ok(pin_init!(Self { + spec, + bar: devres_bar, + fw + })) } } |