Skip to content

Commit a2a637f

Browse files
GnurouDanilo Krummrich
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Danilo Krummrich <[email protected]>
1 parent 44dda43 commit a2a637f

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

drivers/gpu/nova-core/gpu.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,8 @@ pub(crate) struct Spec {
134134
}
135135

136136
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);
140139

141140
Ok(Self {
142141
chipset: boot0.chipset().try_into()?,
@@ -183,8 +182,12 @@ pub(crate) struct Gpu {
183182
}
184183

185184
impl Gpu {
186-
pub(crate) fn new(pdev: &pci::Device, bar: Devres<Bar0>) -> Result<impl PinInit<Self>> {
187-
let spec = Spec::new(&bar)?;
185+
pub(crate) fn new(
186+
pdev: &pci::Device<device::Bound>,
187+
devres_bar: Devres<Bar0>,
188+
) -> Result<impl PinInit<Self>> {
189+
let bar = devres_bar.access(pdev.as_ref())?;
190+
let spec = Spec::new(bar)?;
188191
let fw = Firmware::new(pdev.as_ref(), &spec, "535.113.01")?;
189192

190193
dev_info!(
@@ -195,6 +198,10 @@ impl Gpu {
195198
spec.revision
196199
);
197200

198-
Ok(pin_init!(Self { spec, bar, fw }))
201+
Ok(pin_init!(Self {
202+
spec,
203+
bar: devres_bar,
204+
fw
205+
}))
199206
}
200207
}

0 commit comments

Comments
 (0)