Skip to contentSkip to conversation

Nova DRM skeleton driver

PATCH Applied Danilo Krummrich 1 participant 4 messages Apr 24, 2025 – May 12, 2025

Subsystems (6)
DRM drivers DRM misc Rust DRM Rust +2 more subsystems
lore
Share & tools
lore

Danilo Krummrich

author maintainer
#0 lore raw

v2 cover Nova DRM skeleton driver

This patch series adds the nova-drm skeleton driver.

nova-drm is connected to nova-core through the auxiliary bus and implements the DRM parts of the nova driver stack.

For now, it implements the fundamental DRM abstractions, i.e. creates a DRM device and registers it, exposing a three sample IOCTLs.

DRM_IOCTL_NOVA_GETPARAM
- provides the PCI bar size from the bar that maps the GPUs VRAM from nova-core

DRM_IOCTL_NOVA_GEM_CREATE
- creates a new dummy DRM GEM object and returns a handle

DRM_IOCTL_NOVA_GEM_INFO
- provides metadata for the DRM GEM object behinda given handle

I implemented a small userspace test suite [1] that utilizes this interface.

The patches from this series are also available in [2].

[1] https://gitlab.freedesktop.org/dakr/drm-test
[2] https://gitlab.freedesktop.org/drm/nova/-/tree/staging/nova-drm

Changes in v2:
- Implement abstractions for the corresponding ::kernel::uapi:: types.

Danilo Krummrich (2):
gpu: nova-core: register auxiliary device for nova-drm
drm: nova-drm: add initial driver skeleton

 MAINTAINERS                        |  12 ++++
 drivers/gpu/drm/Kconfig            |   2 +
 drivers/gpu/drm/Makefile           |   1 +
 drivers/gpu/drm/nova/Kconfig       |  14 ++++
 drivers/gpu/drm/nova/Makefile      |   3 +
 drivers/gpu/drm/nova/driver.rs     |  69 ++++++++++++++++++++
 drivers/gpu/drm/nova/file.rs       |  74 +++++++++++++++++++++
 drivers/gpu/drm/nova/gem.rs        |  49 ++++++++++++++
 drivers/gpu/drm/nova/nova.rs       |  18 +++++
 drivers/gpu/drm/nova/uapi.rs       |  61 +++++++++++++++++
 drivers/gpu/nova-core/Kconfig      |   1 +
 drivers/gpu/nova-core/driver.rs    |   9 ++-
 drivers/gpu/nova-core/nova_core.rs |   2 +
 include/uapi/drm/nova_drm.h        | 101 +++++++++++++++++++++++++++++
 rust/uapi/uapi_helper.h            |   1 +
 15 files changed, 416 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/nova/Kconfig
 create mode 100644 drivers/gpu/drm/nova/Makefile
 create mode 100644 drivers/gpu/drm/nova/driver.rs
 create mode 100644 drivers/gpu/drm/nova/file.rs
 create mode 100644 drivers/gpu/drm/nova/gem.rs
 create mode 100644 drivers/gpu/drm/nova/nova.rs
 create mode 100644 drivers/gpu/drm/nova/uapi.rs
 create mode 100644 include/uapi/drm/nova_drm.h

base-commit: b5cb47f81a2857d270cabbbb3a9feec0e483caed

Signature · 1 line
2.49.0
author maintainer
#1 lore raw

PATCH v2 1/2 gpu: nova-core: register auxiliary device for nova-drm

Register an auxiliary device for nova-drm.

For now always use zero for the auxiliary device's ID; we don't use it yet anyways. However, once it lands, we should switch to XArray.

---
 drivers/gpu/nova-core/Kconfig      | 1 +
 drivers/gpu/nova-core/driver.rs    | 9 ++++++++-
 drivers/gpu/nova-core/nova_core.rs | 2 ++
 3 files changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/nova-core/Kconfig +1 -0
index ad0c06756516..67f99b6a023a 100644
@@ -1,5 +1,6 @@
 config NOVA_CORE
 	tristate "Nova Core GPU driver"
+	depends on AUXILIARY_BUS
 	depends on PCI
 	depends on RUST
 	depends on RUST_FW_LOADER_ABSTRACTIONS
drivers/gpu/nova-core/driver.rs +8 -1
index a08fb6599267..8c86101c26cb 100644
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 
-use kernel::{bindings, c_str, device::Core, pci, prelude::*};
+use kernel::{auxiliary, bindings, c_str, device::Core, pci, prelude::*};
 
 use crate::gpu::Gpu;
 
@@ -8,6 +8,7 @@
 pub(crate) struct NovaCore {
     #[pin]
     pub(crate) gpu: Gpu,
+    _reg: auxiliary::Registration,
 }
 
 const BAR0_SIZE: usize = 8;
@@ -38,6 +39,12 @@ fn probe(pdev: &pci::Device<Core>, _info: &Self::IdInfo) -> Result<Pin<KBox<Self
         let this = KBox::pin_init(
             try_pin_init!(Self {
                 gpu <- Gpu::new(pdev, bar)?,
+                _reg: auxiliary::Registration::new(
+                    pdev.as_ref(),
+                    c_str!("nova-drm"),
+                    0, // TODO: Once it lands, use XArray; for now we don't use the ID.
+                    crate::MODULE_NAME
+                )?,
             }),
             GFP_KERNEL,
         )?;
drivers/gpu/nova-core/nova_core.rs +2 -0
index a91cd924054b..618632f0abcc 100644
@@ -8,6 +8,8 @@
 mod regs;
 mod util;
 
+pub(crate) const MODULE_NAME: &kernel::str::CStr = <LocalModule as kernel::ModuleMetadata>::NAME;
+
 kernel::module_pci_driver! {
     type: driver::NovaCore,
     name: "NovaCore",
Signature · 1 line
2.49.0
author maintainer
#2 lore raw

PATCH v2 2/2 drm: nova-drm: add initial driver skeleton

In reply to Danilo Krummrich

Add the initial nova-drm driver skeleton.

nova-drm is connected to nova-core through the auxiliary bus and implements the DRM parts of the nova driver stack.

For now, it implements the fundamental DRM abstractions, i.e. creates a DRM device and registers it, exposing a three sample IOCTLs.

DRM_IOCTL_NOVA_GETPARAM
- provides the PCI bar size from the bar that maps the GPUs VRAM from nova-core

DRM_IOCTL_NOVA_GEM_CREATE
- creates a new dummy DRM GEM object and returns a handle

DRM_IOCTL_NOVA_GEM_INFO
- provides metadata for the DRM GEM object behind a given handle

I implemented a small userspace test suite [1] that utilizes this interface.

---
 MAINTAINERS                    |  12 ++++
 drivers/gpu/drm/Kconfig        |   2 +
 drivers/gpu/drm/Makefile       |   1 +
 drivers/gpu/drm/nova/Kconfig   |  14 +++++
 drivers/gpu/drm/nova/Makefile  |   3 +
 drivers/gpu/drm/nova/driver.rs |  69 ++++++++++++++++++++++
 drivers/gpu/drm/nova/file.rs   |  74 ++++++++++++++++++++++++
 drivers/gpu/drm/nova/gem.rs    |  49 ++++++++++++++++
 drivers/gpu/drm/nova/nova.rs   |  18 ++++++
 drivers/gpu/drm/nova/uapi.rs   |  61 ++++++++++++++++++++
 include/uapi/drm/nova_drm.h    | 101 +++++++++++++++++++++++++++++++++
 rust/uapi/uapi_helper.h        |   1 +
 12 files changed, 405 insertions(+)
 create mode 100644 drivers/gpu/drm/nova/Kconfig
 create mode 100644 drivers/gpu/drm/nova/Makefile
 create mode 100644 drivers/gpu/drm/nova/driver.rs
 create mode 100644 drivers/gpu/drm/nova/file.rs
 create mode 100644 drivers/gpu/drm/nova/gem.rs
 create mode 100644 drivers/gpu/drm/nova/nova.rs
 create mode 100644 drivers/gpu/drm/nova/uapi.rs
 create mode 100644 include/uapi/drm/nova_drm.h
MAINTAINERS +12 -0
index 2fe2e531f4cb..f7cffb0a5a77 100644
@@ -7594,6 +7594,18 @@ T:	git https://gitlab.freedesktop.org/drm/nova.git nova-next
 F:	Documentation/gpu/nova/
 F:	drivers/gpu/nova-core/
 
+DRM DRIVER FOR NVIDIA GPUS [RUST]
+M:	Danilo Krummrich <[email protected]>
+L:	[email protected]
+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:	Documentation/gpu/nova/
+F:	drivers/gpu/drm/nova/
+F:	include/uapi/drm/nova_drm.h
+
 DRM DRIVER FOR OLIMEX LCD-OLINUXINO PANELS
 M:	Stefan Mavrodiev <[email protected]>
 S:	Maintained
drivers/gpu/drm/Kconfig +2 -0
index 2cba2b6ebe1c..90cdaa0068bd 100644
@@ -343,6 +343,8 @@ source "drivers/gpu/drm/amd/amdgpu/Kconfig"
 
 source "drivers/gpu/drm/nouveau/Kconfig"
 
+source "drivers/gpu/drm/nova/Kconfig"
+
 source "drivers/gpu/drm/i915/Kconfig"
 
 source "drivers/gpu/drm/xe/Kconfig"
drivers/gpu/drm/Makefile +1 -0
index ed54a546bbe2..947ed126135b 100644
@@ -176,6 +176,7 @@ obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
 obj-$(CONFIG_DRM_VGEM)	+= vgem/
 obj-$(CONFIG_DRM_VKMS)	+= vkms/
 obj-$(CONFIG_DRM_NOUVEAU) +=nouveau/
+obj-$(CONFIG_DRM_NOVA) += nova/
 obj-$(CONFIG_DRM_EXYNOS) +=exynos/
 obj-$(CONFIG_DRM_ROCKCHIP) +=rockchip/
 obj-$(CONFIG_DRM_GMA500) += gma500/
drivers/gpu/drm/nova/Kconfig new file +14 -0
new file mode 100644
index 000000000000..cf6261584c81
@@ -0,0 +1,14 @@
+config DRM_NOVA
+	tristate "Nova DRM driver"
+	depends on AUXILIARY_BUS
+	depends on DRM
+	depends on PCI
+	depends on RUST
+	default n
+	help
+	  Choose this if you want to build the Nova DRM driver for Nvidia
+	  GSP-based GPUs.
+
+	  This driver is work in progress and may not be functional.
+
+	  If M is selected, the module will be called nova.
drivers/gpu/drm/nova/Makefile new file +3 -0
new file mode 100644
index 000000000000..42019bff3173
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+
+obj-$(CONFIG_DRM_NOVA) += nova.o
drivers/gpu/drm/nova/driver.rs new file +69 -0

69 lines not on this page · raw message

drivers/gpu/drm/nova/file.rs new file +74 -0

74 lines not on this page · raw message

drivers/gpu/drm/nova/gem.rs new file +49 -0

49 lines not on this page · raw message

drivers/gpu/drm/nova/nova.rs new file +18 -0
new file mode 100644
index 000000000000..902876aa14d1
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0
+
+//! Nova DRM Driver
+
+mod driver;
+mod file;
+mod gem;
+mod uapi;
+
+use crate::driver::NovaDriver;
+
+kernel::module_auxiliary_driver! {
+    type: NovaDriver,
+    name: "Nova",
+    author: "Danilo Krummrich",
+    description: "Nova GPU driver",
+    license: "GPL v2",
+}
drivers/gpu/drm/nova/uapi.rs new file +61 -0

61 lines not on this page · raw message

include/uapi/drm/nova_drm.h new file +101 -0

101 lines not on this page · raw message

rust/uapi/uapi_helper.h +1 -0
index 19587e55e604..1409441359f5 100644
@@ -8,6 +8,7 @@
 
 #include <uapi/asm-generic/ioctl.h>
 #include <uapi/drm/drm.h>
+#include <uapi/drm/nova_drm.h>
 #include <uapi/linux/mdio.h>
 #include <uapi/linux/mii.h>
 #include <uapi/linux/ethtool.h>
Signature · 1 line
2.49.0