gpu: nova-core: separate driver type from driver data

Introduce NovaCoreDriver as the driver type implementing pci::Driver,
keeping NovaCore as the per-device data type. This prepares for making
NovaCore lifetime-parameterized once auxiliary::Registration requires a
lifetime for the binding scope.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Reviewed-by: Eliot Courtney <ecourtney@nvidia.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Link: https://patch.msgid.link/20260525202921.124698-22-dakr@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
This commit is contained in:
Danilo Krummrich 2026-05-25 22:21:08 +02:00
parent e397d405c4
commit bb1cf43f2f
2 changed files with 9 additions and 7 deletions

View File

@ -35,6 +35,8 @@ pub(crate) struct NovaCore {
_reg: Devres<auxiliary::Registration<()>>,
}
pub(crate) struct NovaCoreDriver;
const BAR0_SIZE: usize = SZ_16M;
// For now we only support Ampere which can use up to 47-bit DMA addresses.
@ -50,7 +52,7 @@ pub(crate) struct NovaCore {
kernel::pci_device_table!(
PCI_TABLE,
MODULE_PCI_TABLE,
<NovaCore as pci::Driver>::IdInfo,
<NovaCoreDriver as pci::Driver>::IdInfo,
[
// Modern NVIDIA GPUs will show up as either VGA or 3D controllers.
(
@ -72,15 +74,15 @@ pub(crate) struct NovaCore {
]
);
impl pci::Driver for NovaCore {
impl pci::Driver for NovaCoreDriver {
type IdInfo = ();
type Data<'bound> = Self;
type Data<'bound> = NovaCore;
const ID_TABLE: pci::IdTable<Self::IdInfo> = &PCI_TABLE;
fn probe<'bound>(
pdev: &'bound pci::Device<Core<'_>>,
_info: &'bound Self::IdInfo,
) -> impl PinInit<Self, Error> + 'bound {
) -> impl PinInit<NovaCore, Error> + 'bound {
pin_init::pin_init_scope(move || {
dev_dbg!(pdev, "Probe Nova Core GPU driver.\n");
@ -98,7 +100,7 @@ fn probe<'bound>(
GFP_KERNEL,
)?;
Ok(try_pin_init!(Self {
Ok(try_pin_init!(NovaCore {
gpu <- Gpu::new(pdev, bar.clone(), bar.access(pdev.as_ref())?),
_reg: auxiliary::Registration::new(
pdev.as_ref(),
@ -113,7 +115,7 @@ fn probe<'bound>(
})
}
fn unbind<'bound>(pdev: &'bound pci::Device<Core<'_>>, this: Pin<&Self>) {
fn unbind<'bound>(pdev: &'bound pci::Device<Core<'_>>, this: Pin<&NovaCore>) {
this.gpu.unbind(pdev.as_ref());
}
}

View File

@ -47,7 +47,7 @@ struct NovaCoreModule {
// Fields are dropped in declaration order, so `_driver` is dropped first,
// then `_debugfs_guard` clears `DEBUGFS_ROOT`.
#[pin]
_driver: Registration<pci::Adapter<driver::NovaCore>>,
_driver: Registration<pci::Adapter<driver::NovaCoreDriver>>,
_debugfs_guard: DebugfsRootGuard,
}