Commit 54e6baf1 authored by Danilo Krummrich's avatar Danilo Krummrich
Browse files

gpu: nova-core: add initial driver stub

Add the initial nova-core driver stub.

nova-core is intended to serve as a common base for nova-drm (the
corresponding DRM driver) and the vGPU manager VFIO driver, serving as a
hard- and firmware abstraction layer for GSP-based NVIDIA GPUs.

The Nova project, including nova-core and nova-drm, in the long term,
is intended to serve as the successor of Nouveau for all GSP-based GPUs.

The motivation for both, starting a successor project for Nouveau and
doing so using the Rust programming language, is documented in detail
through a previous post on the mailing list [1], an LWN article [2] and a
talk from LPC '24.

In order to avoid the chicken and egg problem to require a user to
upstream Rust abstractions, but at the same time require the Rust
abstractions to implement the driver, nova-core kicks off as a driver
stub and is subsequently developed upstream.

Link: https://lore.kernel.org/dri-devel/Zfsj0_tb-0-tNrJy@cassiopeiae/T/#u [1]
Link: https://lwn.net/Articles/990736/ [2]
Link: https://youtu.be/3Igmx28B3BQ?si=sBdSEer4tAPKGpOs

 [3]
Reviewed-by: default avatarAlexandre Courbot <acourbot@nvidia.com>
Link: https://lore.kernel.org/r/20250306222336.23482-5-dakr@kernel.org


Signed-off-by: default avatarDanilo Krummrich <dakr@kernel.org>
parent 1d121a33
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -7449,6 +7449,16 @@ T: git https://gitlab.freedesktop.org/drm/nouveau.git
F:	drivers/gpu/drm/nouveau/
F:	include/uapi/drm/nouveau_drm.h
CORE DRIVER FOR NVIDIA GPUS [RUST]
M:	Danilo Krummrich <dakr@kernel.org>
L:	nouveau@lists.freedesktop.org
S:	Supported
Q:	https://patchwork.freedesktop.org/project/nouveau/
B:	https://gitlab.freedesktop.org/drm/nova/-/issues
C:	irc://irc.oftc.net/nouveau
T:	git https://gitlab.freedesktop.org/drm/nova.git nova-next
F:	drivers/gpu/nova-core/
DRM DRIVER FOR OLIMEX LCD-OLINUXINO PANELS
M:	Stefan Mavrodiev <stefan@olimex.com>
S:	Maintained
+1 −0
Original line number Diff line number Diff line
@@ -5,3 +5,4 @@
obj-y			+= host1x/ drm/ vga/
obj-$(CONFIG_IMX_IPUV3_CORE)	+= ipu-v3/
obj-$(CONFIG_TRACE_GPU_MEM)		+= trace/
obj-$(CONFIG_NOVA_CORE)		+= nova-core/
+14 −0
Original line number Diff line number Diff line
config NOVA_CORE
	tristate "Nova Core GPU driver"
	depends on PCI
	depends on RUST
	depends on RUST_FW_LOADER_ABSTRACTIONS
	default n
	help
	  Choose this if you want to build the Nova Core driver for Nvidia
	  GPUs based on the GPU System Processor (GSP). This is true for Turing
	  and later GPUs.

	  This driver is work in progress and may not be functional.

	  If M is selected, the module will be called nova_core.
+3 −0
Original line number Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0

obj-$(CONFIG_NOVA_CORE) += nova_core.o
+47 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0

use kernel::{bindings, c_str, pci, prelude::*};

use crate::gpu::Gpu;

#[pin_data]
pub(crate) struct NovaCore {
    #[pin]
    pub(crate) gpu: Gpu,
}

const BAR0_SIZE: usize = 8;
pub(crate) type Bar0 = pci::Bar<BAR0_SIZE>;

kernel::pci_device_table!(
    PCI_TABLE,
    MODULE_PCI_TABLE,
    <NovaCore as pci::Driver>::IdInfo,
    [(
        pci::DeviceId::from_id(bindings::PCI_VENDOR_ID_NVIDIA, bindings::PCI_ANY_ID as _),
        ()
    )]
);

impl pci::Driver for NovaCore {
    type IdInfo = ();
    const ID_TABLE: pci::IdTable<Self::IdInfo> = &PCI_TABLE;

    fn probe(pdev: &mut pci::Device, _info: &Self::IdInfo) -> Result<Pin<KBox<Self>>> {
        dev_dbg!(pdev.as_ref(), "Probe Nova Core GPU driver.\n");

        pdev.enable_device_mem()?;
        pdev.set_master();

        let bar = pdev.iomap_region_sized::<BAR0_SIZE>(0, c_str!("nova-core/bar0"))?;

        let this = KBox::pin_init(
            try_pin_init!(Self {
                gpu <- Gpu::new(pdev, bar)?,
            }),
            GFP_KERNEL,
        )?;

        Ok(this)
    }
}
Loading