drm/nova: make unstable uAPI use explicit
Subsystems (6)
Danilo Krummrich
maintainercover drm/nova: make unstable uAPI use explicit
Nova and its uAPI are under active upstream development. We want to develop these interfaces upstream while making clear that they are not yet stable and may change incompatibly.
This series makes that status more explicit and requires users to acknowledge it before enabling the driver, tainting the kernel when they do.
Introduce a minimal Rust abstraction for kernel tainting in order to support this.
As individual interfaces stabilize, they should move from nova_drm_unstable.h to the stable nova_drm.h header. Once all interfaces have moved and all stakeholders agree that the uAPI is stable, the acknowledgment requirement and kernel tainting can be removed.
(Compile-tested only, as I'm currently travelling.)
Danilo Krummrich (3):
drm/nova: mark the uAPI header as unstable
rust: add kernel taint abstraction drm/nova: require explicit opt-in to unstable uAPI
drivers/gpu/drm/nova/Kconfig | 11 +- drivers/gpu/drm/nova/nova.rs | 55 +++++- drivers/gpu/drm/nova/nova_drm_unstable.h | 212 +++++++++++++++++++++++ include/uapi/drm/nova_drm.h | 204 +--------------------- rust/bindings/bindings_helper.h | 1 + rust/kernel/lib.rs | 1 + rust/kernel/panic.rs | 50 ++++++ rust/uapi/uapi_helper.h | 2 + 8 files changed, 332 insertions(+), 204 deletions(-) create mode 100644 drivers/gpu/drm/nova/nova_drm_unstable.h create mode 100644 rust/kernel/panic.rs
base-commit: 3497a403264b094ebd61b8b755165d56e7d9dc37
Signature · 1 line
2.56.0
Danilo Krummrich
maintainerPATCH 1/3 drm/nova: mark the uAPI header as unstable
The header already documents that its uAPI is unstable and intended for development. It may change incompatibly as it is developed upstream. Rename it to nova_drm_unstable.h and move it out of include/uapi/ to make this more explicit.
As individual interfaces become stable, move them to include/uapi/drm/nova_drm.h.
--- drivers/gpu/drm/nova/nova_drm_unstable.h | 212 +++++++++++++++++++++++ include/uapi/drm/nova_drm.h | 204 +--------------------- rust/uapi/uapi_helper.h | 2 + 3 files changed, 217 insertions(+), 201 deletions(-) create mode 100644 drivers/gpu/drm/nova/nova_drm_unstable.h
drivers/gpu/drm/nova/nova_drm_unstable.h new file +212 -0
@@ -0,0 +1,212 @@ +/* SPDX-License-Identifier: MIT */ + +#ifndef __NOVA_DRM_UNSTABLE_H__ +#define __NOVA_DRM_UNSTABLE_H__ + +#include <drm/drm.h> + +/* DISCLAIMER: Do not use, this is not a stable uAPI. +* +* This uAPI serves only testing purposes as long as this driver is still in +* development. It is required to implement and test infrastructure which is +* upstreamed in the context of this driver. See also [1]. +* +* The uAPI in this file may change incompatibly. Stable interfaces should +* be moved to include/uapi/drm/nova_drm.h. +* +* [1] https://lore.kernel.org/dri-devel/Zfsj0_tb-0-tNrJy@cassiopeiae/ +*/ + +#if defined(__cplusplus) +extern "C" { +#endif + +/** +* enum drm_nova_architecture - GPU architecture identifier +*/ +enum drm_nova_architecture { +NOVA_DRM_ARCHITECTURE_TURING =0x16 , +NOVA_DRM_ARCHITECTURE_AMPERE =0x17 , +NOVA_DRM_ARCHITECTURE_HOPPER =0x18 , +NOVA_DRM_ARCHITECTURE_ADA =0x19 , +NOVA_DRM_ARCHITECTURE_BLACKWELL_GB10X =0x1a , +NOVA_DRM_ARCHITECTURE_BLACKWELL_GB20X =0x1b , +}; + +/** +* enum drm_nova_chipid - opaque GPU chip identifier +* +* These values identify the chip a GPU is based on. They are otherwise +* opaque: userspace must not assume the values carry any particular meaning +* or encoding, only that they may be compared against this enum. +*/ +enum drm_nova_chipid { +/* Turing */ +NOVA_DRM_CHIPID_TU102 =0x162 , +NOVA_DRM_CHIPID_TU104 =0x164 , +NOVA_DRM_CHIPID_TU106 =0x166 , +NOVA_DRM_CHIPID_TU117 =0x167 , +NOVA_DRM_CHIPID_TU116 =0x168 , +/* Ampere */ +NOVA_DRM_CHIPID_GA100 =0x170 , +NOVA_DRM_CHIPID_GA102 =0x172 , +NOVA_DRM_CHIPID_GA103 =0x173 , +NOVA_DRM_CHIPID_GA104 =0x174 , +NOVA_DRM_CHIPID_GA106 =0x176 , +NOVA_DRM_CHIPID_GA107 =0x177 , +/* Hopper */ +NOVA_DRM_CHIPID_GH100 =0x180 , +/* Ada */ +NOVA_DRM_CHIPID_AD102 =0x192 , +NOVA_DRM_CHIPID_AD103 =0x193 , +NOVA_DRM_CHIPID_AD104 =0x194 , +NOVA_DRM_CHIPID_AD106 =0x196 , +NOVA_DRM_CHIPID_AD107 =0x197 , +/* Blackwell GB10x */ +NOVA_DRM_CHIPID_GB100 =0x1a0 , +NOVA_DRM_CHIPID_GB102 =0x1a2 , +/* Blackwell GB20x */ +NOVA_DRM_CHIPID_GB202 =0x1b2 , +NOVA_DRM_CHIPID_GB203 =0x1b3 , +NOVA_DRM_CHIPID_GB205 =0x1b5 , +NOVA_DRM_CHIPID_GB206 =0x1b6 , +NOVA_DRM_CHIPID_GB207 =0x1b7 , +}; + +/** +* struct drm_nova_gem_create - create a new DRM GEM object +*/ +struct drm_nova_gem_create { +/** +* @handle: The handle of the new DRM GEM object. +*/ +__u32 handle; + +/** +* @pad: 32 bit padding, should be 0. +*/ +__u32 pad; + +/** +* @size: The size of the new DRM GEM object. +*/ +__u64 size; +}; + +/** +* struct drm_nova_gem_info - query DRM GEM object metadata +*/ +struct drm_nova_gem_info { +/** +* @handle: The handle of the DRM GEM object to query. +*/ +__u32 handle; + +/** +* @pad: 32 bit padding, should be 0. +*/ +__u32 pad; + +/** +* @size: The size of the DRM GEM object. +*/ +__u64 size; +}; + +/** +* struct drm_nova_info - query device information +*/ +struct drm_nova_info { +/** +* @id: The identifier of the information to query. +*/ +__u32 id; + +/** +* @size: The amount of space allocated by userspace at @data. The kernel +* will return the number of bytes it wrote, or the size of the queried +* information structure if @data is NULL. +*/ +__u32 size; + +/** +* @data: Pointer to the userspace buffer into which the queried +* information will be written. May be NULL, in which case nothing is +* written and @size is set to the size of the information structure so +* userspace can allocate a suitably sized buffer. +*/ +__u64 data; +}; + +/** +* DRM_NOVA_INFO_GPU +* +* Query GPU information. The result is returned in a +* &struct drm_nova_info_gpu. +*/ +#define DRM_NOVA_INFO_GPU 0x00 + +/** +* struct drm_nova_info_gpu - GPU information +*/ +struct drm_nova_info_gpu { +/** +* @architecture: GPU architecture identifier. +* +* See &enum drm_nova_architecture for currently known architectures. +*/ +__u32 architecture; + +/** +* @chipid: Opaque GPU chip identifier. +* +* See &enum drm_nova_chipid for currently known chips. +*/ +__u32 chipid; + +/** +* @vram_size: Amount of usable FB, excluding GSP carveouts and protected +* regions. +*/ +__u64 vram_size; + +/** +* @vram_bar_size: Size of the PCI BAR aperture used to access VRAM, in bytes. +*/ +__u64 vram_bar_size; + +/** +* @gpu_name: NUL-terminated full GPU name. +*/ +__u8 gpu_name[64 ]; + +/** +* @gpu_short_name: NUL-terminated short GPU name. +*/ +__u8 gpu_short_name[64 ]; + +/** +* @gpu_gid: 16-byte SHA-1 GPU identifier supplied by GSP-RM. +*/ +__u8 gpu_gid[16 ]; +}; + +#define DRM_NOVA_INFO 0x00 +#define DRM_NOVA_GEM_CREATE 0x01 +#define DRM_NOVA_GEM_INFO 0x02 + +/* Note: this is an enum so that it can be resolved by Rust bindgen. */ +enum { +DRM_IOCTL_NOVA_INFO =DRM_IOWR (DRM_COMMAND_BASE +DRM_NOVA_INFO , + struct drm_nova_info), +DRM_IOCTL_NOVA_GEM_CREATE =DRM_IOWR (DRM_COMMAND_BASE +DRM_NOVA_GEM_CREATE , + struct drm_nova_gem_create), +DRM_IOCTL_NOVA_GEM_INFO =DRM_IOWR (DRM_COMMAND_BASE +DRM_NOVA_GEM_INFO , + struct drm_nova_gem_info), +}; + +#if defined(__cplusplus) +} +#endif + +#endif /* __NOVA_DRM_UNSTABLE_H__ */
include/uapi/drm/nova_drm.h +3 -201
210 lines not on this page · raw message
rust/uapi/uapi_helper.h +2 -0
@@ -6,6 +6,8 @@* Sorted alphabetically. */ +#include "../../drivers/gpu/drm/nova/nova_drm_unstable.h" +#include <uapi/drm/drm.h> #include <uapi/drm/nova_drm.h> #include <uapi/drm/panthor_drm.h>
Signature · 1 line
2.56.0
Re: [PATCH 1/3] drm/nova: mark the uAPI header as unstable
Quoted 10 lines · Danilo Krummrich
The header already documents that its uAPI is unstable and intended for development. It may change incompatibly as it is developed upstream. Rename it to
nova_drm_unstable.hand move it out ofinclude/uapi/to make this more explicit.As individual interfaces become stable, move them to
include/uapi/drm/nova_drm.h.Signed-off-by Danilo Krummrich <[email protected]>
Quoted 456 lines
--- drivers/gpu/drm/nova/nova_drm_unstable.h | 212 +++++++++++++++++++++++ include/uapi/drm/nova_drm.h | 204 +--------------------- rust/uapi/uapi_helper.h | 2 + 3 files changed, 217 insertions(+), 201 deletions(-) create mode 100644 drivers/gpu/drm/nova/nova_drm_unstable.hdrivers/gpu/drm/nova/nova_drm_unstable.h new file +212
-0@@ -0,0 +1,212 @@ +/* SPDX-License-Identifier: MIT */ + +#ifndef __NOVA_DRM_UNSTABLE_H__ +#define __NOVA_DRM_UNSTABLE_H__ + +#include <drm/drm.h> + +/* DISCLAIMER: Do not use, this is not a stable uAPI. +* +* This uAPI serves only testing purposes as long as this driver is still in +* development. It is required to implement and test infrastructure which is +* upstreamed in the context of this driver. See also [1]. +* +* The uAPI in this file may change incompatibly. Stable interfaces should +* be moved to include/uapi/drm/nova_drm.h. +* +* [1] https://lore.kernel.org/dri-devel/Zfsj0_tb-0-tNrJy@cassiopeiae/ +*/ + +#if defined(__cplusplus) +extern "C" { +#endif + +/** +* enum drm_nova_architecture - GPU architecture identifier +*/ +enum drm_nova_architecture { +NOVA_DRM_ARCHITECTURE_TURING =0x16 , +NOVA_DRM_ARCHITECTURE_AMPERE =0x17 , +NOVA_DRM_ARCHITECTURE_HOPPER =0x18 , +NOVA_DRM_ARCHITECTURE_ADA =0x19 , +NOVA_DRM_ARCHITECTURE_BLACKWELL_GB10X =0x1a , +NOVA_DRM_ARCHITECTURE_BLACKWELL_GB20X =0x1b , +}; + +/** +* enum drm_nova_chipid - opaque GPU chip identifier +* +* These values identify the chip a GPU is based on. They are otherwise +* opaque: userspace must not assume the values carry any particular meaning +* or encoding, only that they may be compared against this enum. +*/ +enum drm_nova_chipid { +/* Turing */ +NOVA_DRM_CHIPID_TU102 =0x162 , +NOVA_DRM_CHIPID_TU104 =0x164 , +NOVA_DRM_CHIPID_TU106 =0x166 , +NOVA_DRM_CHIPID_TU117 =0x167 , +NOVA_DRM_CHIPID_TU116 =0x168 , +/* Ampere */ +NOVA_DRM_CHIPID_GA100 =0x170 , +NOVA_DRM_CHIPID_GA102 =0x172 , +NOVA_DRM_CHIPID_GA103 =0x173 , +NOVA_DRM_CHIPID_GA104 =0x174 , +NOVA_DRM_CHIPID_GA106 =0x176 , +NOVA_DRM_CHIPID_GA107 =0x177 , +/* Hopper */ +NOVA_DRM_CHIPID_GH100 =0x180 , +/* Ada */ +NOVA_DRM_CHIPID_AD102 =0x192 , +NOVA_DRM_CHIPID_AD103 =0x193 , +NOVA_DRM_CHIPID_AD104 =0x194 , +NOVA_DRM_CHIPID_AD106 =0x196 , +NOVA_DRM_CHIPID_AD107 =0x197 , +/* Blackwell GB10x */ +NOVA_DRM_CHIPID_GB100 =0x1a0 , +NOVA_DRM_CHIPID_GB102 =0x1a2 , +/* Blackwell GB20x */ +NOVA_DRM_CHIPID_GB202 =0x1b2 , +NOVA_DRM_CHIPID_GB203 =0x1b3 , +NOVA_DRM_CHIPID_GB205 =0x1b5 , +NOVA_DRM_CHIPID_GB206 =0x1b6 , +NOVA_DRM_CHIPID_GB207 =0x1b7 , +}; + +/** +* struct drm_nova_gem_create - create a new DRM GEM object +*/ +struct drm_nova_gem_create { +/** +* @handle: The handle of the new DRM GEM object. +*/ +__u32 handle; + +/** +* @pad: 32 bit padding, should be 0. +*/ +__u32 pad; + +/** +* @size: The size of the new DRM GEM object. +*/ +__u64 size; +}; + +/** +* struct drm_nova_gem_info - query DRM GEM object metadata +*/ +struct drm_nova_gem_info { +/** +* @handle: The handle of the DRM GEM object to query. +*/ +__u32 handle; + +/** +* @pad: 32 bit padding, should be 0. +*/ +__u32 pad; + +/** +* @size: The size of the DRM GEM object. +*/ +__u64 size; +}; + +/** +* struct drm_nova_info - query device information +*/ +struct drm_nova_info { +/** +* @id: The identifier of the information to query. +*/ +__u32 id; + +/** +* @size: The amount of space allocated by userspace at @data. The kernel +* will return the number of bytes it wrote, or the size of the queried +* information structure if @data is NULL. +*/ +__u32 size; + +/** +* @data: Pointer to the userspace buffer into which the queried +* information will be written. May be NULL, in which case nothing is +* written and @size is set to the size of the information structure so +* userspace can allocate a suitably sized buffer. +*/ +__u64 data; +}; + +/** +* DRM_NOVA_INFO_GPU +* +* Query GPU information. The result is returned in a +* &struct drm_nova_info_gpu. +*/ +#define DRM_NOVA_INFO_GPU 0x00 + +/** +* struct drm_nova_info_gpu - GPU information +*/ +struct drm_nova_info_gpu { +/** +* @architecture: GPU architecture identifier. +* +* See &enum drm_nova_architecture for currently known architectures. +*/ +__u32 architecture; + +/** +* @chipid: Opaque GPU chip identifier. +* +* See &enum drm_nova_chipid for currently known chips. +*/ +__u32 chipid; + +/** +* @vram_size: Amount of usable FB, excluding GSP carveouts and protected +* regions. +*/ +__u64 vram_size; + +/** +* @vram_bar_size: Size of the PCI BAR aperture used to access VRAM, in bytes. +*/ +__u64 vram_bar_size; + +/** +* @gpu_name: NUL-terminated full GPU name. +*/ +__u8 gpu_name[64 ]; + +/** +* @gpu_short_name: NUL-terminated short GPU name. +*/ +__u8 gpu_short_name[64 ]; + +/** +* @gpu_gid: 16-byte SHA-1 GPU identifier supplied by GSP-RM. +*/ +__u8 gpu_gid[16 ]; +}; + +#define DRM_NOVA_INFO 0x00 +#define DRM_NOVA_GEM_CREATE 0x01 +#define DRM_NOVA_GEM_INFO 0x02 + +/* Note: this is an enum so that it can be resolved by Rust bindgen. */ +enum { +DRM_IOCTL_NOVA_INFO =DRM_IOWR (DRM_COMMAND_BASE +DRM_NOVA_INFO , + struct drm_nova_info), +DRM_IOCTL_NOVA_GEM_CREATE =DRM_IOWR (DRM_COMMAND_BASE +DRM_NOVA_GEM_CREATE , + struct drm_nova_gem_create), +DRM_IOCTL_NOVA_GEM_INFO =DRM_IOWR (DRM_COMMAND_BASE +DRM_NOVA_GEM_INFO , + struct drm_nova_gem_info), +}; + +#if defined(__cplusplus) +} +#endif + +#endif /* __NOVA_DRM_UNSTABLE_H__ */ include/uapi/drm/nova_drm.h +3
-201@@ -3,207 +3,9 @@#ifndef __NOVA_DRM_H__#define __NOVA_DRM_H__ -#include "drm.h" - -/* DISCLAIMER: Do not use, this is not a stable uAPI. -* -* This uAPI serves only testing purposes as long as this driver is still in -* development. It is required to implement and test infrastructure which is -* upstreamed in the context of this driver. See also [1]. -* -* [1] https://lore.kernel.org/dri-devel/Zfsj0_tb-0-tNrJy@cassiopeiae/T/#u -*/ - -#if defined(__cplusplus) -extern "C" { -#endif - -/** -* enum drm_nova_architecture - GPU architecture identifier -*/ -enum drm_nova_architecture { -NOVA_DRM_ARCHITECTURE_TURING =0x16 , -NOVA_DRM_ARCHITECTURE_AMPERE =0x17 , -NOVA_DRM_ARCHITECTURE_HOPPER =0x18 , -NOVA_DRM_ARCHITECTURE_ADA =0x19 , -NOVA_DRM_ARCHITECTURE_BLACKWELL_GB10X =0x1a , -NOVA_DRM_ARCHITECTURE_BLACKWELL_GB20X =0x1b , -}; - -/** -* enum drm_nova_chipid - opaque GPU chip identifier -* -* These values identify the chip a GPU is based on. They are otherwise -* opaque: userspace must not assume the values carry any particular meaning -* or encoding, only that they may be compared against this enum. -*/ -enum drm_nova_chipid { -/* Turing */ -NOVA_DRM_CHIPID_TU102 =0x162 , -NOVA_DRM_CHIPID_TU104 =0x164 , -NOVA_DRM_CHIPID_TU106 =0x166 , -NOVA_DRM_CHIPID_TU117 =0x167 , -NOVA_DRM_CHIPID_TU116 =0x168 , -/* Ampere */ -NOVA_DRM_CHIPID_GA100 =0x170 , -NOVA_DRM_CHIPID_GA102 =0x172 , -NOVA_DRM_CHIPID_GA103 =0x173 , -NOVA_DRM_CHIPID_GA104 =0x174 , -NOVA_DRM_CHIPID_GA106 =0x176 , -NOVA_DRM_CHIPID_GA107 =0x177 , -/* Hopper */ -NOVA_DRM_CHIPID_GH100 =0x180 , -/* Ada */ -NOVA_DRM_CHIPID_AD102 =0x192 , -NOVA_DRM_CHIPID_AD103 =0x193 , -NOVA_DRM_CHIPID_AD104 =0x194 , -NOVA_DRM_CHIPID_AD106 =0x196 , -NOVA_DRM_CHIPID_AD107 =0x197 , -/* Blackwell GB10x */ -NOVA_DRM_CHIPID_GB100 =0x1a0 , -NOVA_DRM_CHIPID_GB102 =0x1a2 , -/* Blackwell GB20x */ -NOVA_DRM_CHIPID_GB202 =0x1b2 , -NOVA_DRM_CHIPID_GB203 =0x1b3 , -NOVA_DRM_CHIPID_GB205 =0x1b5 , -NOVA_DRM_CHIPID_GB206 =0x1b6 , -NOVA_DRM_CHIPID_GB207 =0x1b7 , -}; - -/** -* struct drm_nova_gem_create - create a new DRM GEM object -*/ -struct drm_nova_gem_create { -/** -* @handle: The handle of the new DRM GEM object. -*/ -__u32 handle; - -/** -* @pad: 32 bit padding, should be 0. -*/ -__u32 pad; - -/** -* @size: The size of the new DRM GEM object. -*/ -__u64 size; -}; - -/** -* struct drm_nova_gem_info - query DRM GEM object metadata -*/ -struct drm_nova_gem_info { -/** -* @handle: The handle of the DRM GEM object to query. -*/ -__u32 handle; - -/** -* @pad: 32 bit padding, should be 0. -*/ -__u32 pad; - -/** -* @size: The size of the DRM GEM obejct. -*/ -__u64 size; -}; - -/** -* struct drm_nova_info - query device information +/* +* Stable Nova uAPI. Interfaces should be moved here from +* drivers/gpu/drm/nova/nova_drm_unstable.h as they become stable. */ -struct drm_nova_info { -/** -* @id: The identifier of the information to query. -*/ -__u32 id; - -/** -* @size: The amount of space allocated by userspace at @data. The kernel -* will return the number of bytes it wrote, or the size of the queried -* information structure if @data is NULL. -*/ -__u32 size; - -/** -* @data: Pointer to the userspace buffer into which the queried -* information will be written. May be NULL, in which case nothing is -* written and @size is set to the size of the information structure so -* userspace can allocate a suitably sized buffer. -*/ -__u64 data; -}; - -/** -* DRM_NOVA_INFO_GPU -* -* Query GPU information. The result is returned in a -* &struct drm_nova_info_gpu. -*/ -#define DRM_NOVA_INFO_GPU 0x00 - -/** -* struct drm_nova_info_gpu - GPU information -*/ -struct drm_nova_info_gpu { -/** -* @architecture: GPU architecture identifier. -* -* See &enum drm_nova_architecture for currently known architectures. -*/ -__u32 architecture; - -/** -* @chipid: Opaque GPU chip identifier. -* -* See &enum drm_nova_chipid for currently known chips. -*/ -__u32 chipid; - -/** -* @vram_size: Amount of usable FB, excluding GSP carveouts and protected -* regions. -*/ -__u64 vram_size; - -/** -* @vram_bar_size: Size of the PCI BAR aperture used to access VRAM, in bytes. -*/ -__u64 vram_bar_size; - -/** -* @gpu_name: NUL-terminated full GPU name. -*/ -__u8 gpu_name[64 ]; - -/** -* @gpu_short_name: NUL-terminated short GPU name. -*/ -__u8 gpu_short_name[64 ]; - -/** -* @gpu_gid: 16-byte SHA-1 GPU identifier supplied by GSP-RM. -*/ -__u8 gpu_gid[16 ]; -}; - -#define DRM_NOVA_INFO 0x00 -#define DRM_NOVA_GEM_CREATE 0x01 -#define DRM_NOVA_GEM_INFO 0x02 - -/* Note: this is an enum so that it can be resolved by Rust bindgen. */ -enum { -DRM_IOCTL_NOVA_INFO =DRM_IOWR (DRM_COMMAND_BASE +DRM_NOVA_INFO , - struct drm_nova_info), -DRM_IOCTL_NOVA_GEM_CREATE =DRM_IOWR (DRM_COMMAND_BASE +DRM_NOVA_GEM_CREATE , - struct drm_nova_gem_create), -DRM_IOCTL_NOVA_GEM_INFO =DRM_IOWR (DRM_COMMAND_BASE +DRM_NOVA_GEM_INFO , - struct drm_nova_gem_info), -}; - -#if defined(__cplusplus) -} -#endif #endif /* __NOVA_DRM_H__ */ rust/uapi/uapi_helper.h +2
-1@@ -6,6 +6,8 @@* Sorted alphabetically. */ +#include "../../drivers/gpu/drm/nova/nova_drm_unstable.h" +#include <uapi/drm/drm.h> #include <uapi/drm/nova_drm.h> #include <uapi/drm/panthor_drm.h> --2.56.0
Re: [PATCH 1/3] drm/nova: mark the uAPI header as unstable
In reply to Danilo KrummrichQuoted 10 lines · Danilo Krummrich
The header already documents that its uAPI is unstable and intended for development. It may change incompatibly as it is developed upstream. Rename it to
nova_drm_unstable.hand move it out ofinclude/uapi/to make this more explicit.As individual interfaces become stable, move them to
include/uapi/drm/nova_drm.h.Signed-off-by Danilo Krummrich <[email protected]>
Danilo Krummrich
maintainerPATCH 2/3 rust: add kernel taint abstraction
In reply to Danilo KrummrichAllow Rust code to taint the kernel to record conditions that may be relevant when diagnosing subsequent kernel failures.
--- rust/bindings/bindings_helper.h | 1 + rust/kernel/lib.rs | 1 + rust/kernel/panic.rs | 50 +++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 rust/kernel/panic.rs
rust/bindings/bindings_helper.h +1 -0
@@ -74,6 +74,7 @@#include <linux/mm.h> #include <linux/miscdevice.h> #include <linux/of_device.h> +#include <linux/panic.h> #include <linux/pci.h> #include <linux/phy.h> #include <linux/pid_namespace.h>
rust/kernel/lib.rs +1 -0
@@ -112,6 +112,7 @@#[cfg( CONFIG_PM_OPP )] pub mod opp;pub mod page; +pub mod panic;#[cfg( CONFIG_PCI )] pub mod pci;pub mod pid_namespace;
rust/kernel/panic.rs new file +50 -0
50 lines not on this page · raw message
Signature · 1 line
2.56.0
Gary Guo
reviewerRe: [PATCH 2/3] rust: add kernel taint abstraction
Quoted 60 lines · Danilo Krummrich
Allow Rust code to taint the kernel to record conditions that may be relevant when diagnosing subsequent kernel failures.
Signed-off-by Danilo Krummrich <[email protected]>--- rust/bindings/bindings_helper.h | 1 + rust/kernel/lib.rs | 1 + rust/kernel/panic.rs | 50 +++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 rust/kernel/panic.rsrust/bindings/bindings_helper.h +1
-0@@ -74,6 +74,7 @@#include <linux/mm.h> #include <linux/miscdevice.h> #include <linux/of_device.h> +#include <linux/panic.h> #include <linux/pci.h> #include <linux/phy.h> #include <linux/pid_namespace.h> rust/kernel/lib.rs +1
-0@@ -112,6 +112,7 @@#[cfg( CONFIG_PM_OPP )] pub mod opp;pub mod page; +pub mod panic;#[cfg( CONFIG_PCI )] pub mod pci;pub mod pid_namespace;rust/kernel/panic.rs new file +19
-0@@ -0,0 +1,50 @@ +// SPDX-License-Identifier: GPL-2.0 + +//! Kernel taint tracking. +//! +//! C header: [`include/linux/panic.h`](srctree/include/linux/panic.h) +//! +//! See the [tainted-kernels documentation] for the meaning of each taint. +//! +//! [tainted-kernels documentation]: srctree/Documentation/admin-guide/tainted-kernels.rst + +/// A reason for tainting the kernel. +#[derive( Clone , Copy , Debug , Eq , PartialEq )] +#[repr( u32 )] +pub enum Taint { +/// Tainting was explicitly requested by the user. +User = bindings::TAINT_USER , +} + +impl Taint {
rust/kernel/panic.rs line 29
Quoted 10 lines
rust/kernel/panic.rs new file +10
-0+#[inline] +const fn as_raw (self) ->u32 { + selfas u32 + } +} + +/// Whether lock debugging remains reliable after a tainting event. +#[derive( Clone , Copy , Debug , Eq , PartialEq )] +#[repr( u32 )] +pub enum Lockdep {
The plain "Lockdep" is too confusing I think. I think sticking to the C enum name LockdepOk would better.
Alternatively, we can consider just calling it TaintFlags?
struct TaintFlags { ... }
TaintFlags::lockdep_still_okay()
TaintFlags::lockdep_now_unreliable()Best,
Gary
Quoted 21 lines
rust/kernel/panic.rs new file +21
-0+/// Keep lock debugging enabled. + StillOk = bindings::lockdep_ok_LOCKDEP_STILL_OK, +} + +impl Lockdep { +#[inline] +const fn as_raw (self) -> bindings::lockdep_ok { + selfas u32 + } +} + +/// Adds a kernel taint flag. +/// +/// Taint flags persist until reboot, even if the module that set them is unloaded. +/// Use [`Lockdep::StillOk`] when the tainting event does not compromise lock debugging. +/// This may panic if the kernel's `panic_on_taint` setting matches a set taint flag. +#[inline] +pub fn add_taint (flag:Taint , lockdep:Lockdep ) { +// SAFETY: `Taint` and `Lockdep` restrict both arguments to valid C API values. +unsafe { bindings::add_taint (flag.as_raw (), lockdep.as_raw ()) }; +}
Danilo Krummrich
maintainerPATCH 3/3 drm/nova: require explicit opt-in to unstable uAPI
In reply to Danilo KrummrichNova and its uAPI are under active upstream development. Require users to acknowledge that the uAPI is not yet stable and may change incompatibly before enabling the driver.
Refuse to load unless acknowledge_unstable_uapi=1 is set, and taint the kernel when enabled. This keeps use of the unstable interfaces an explicit opt-in while they are developed upstream.
--- drivers/gpu/drm/nova/Kconfig | 11 +++++++- drivers/gpu/drm/nova/nova.rs | 55 ++++++++++++++++++++++++++++++++++-- 2 files changed, 63 insertions(+), 3 deletions(-)
drivers/gpu/drm/nova/Kconfig +10 -1
@@ -12,6 +12,15 @@ config DRM_NOVA 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. + This driver is under active upstream development and may not be + functional. Its uAPI is intended to be developed upstream alongside + the driver and is not yet stable. It may change incompatibly during + development. + + Loading requires the acknowledge_unstable_uapi=1 module parameter, or + nova-drm.acknowledge_unstable_uapi=1 on the kernel command line when + built in. + + Enabling the driver taints the kernel. If M is selected, the module will be called nova-drm.
drivers/gpu/drm/nova/nova.rs +53 -2
69 lines not on this page · raw message
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH 3/3] drm/nova: require explicit opt-in to unstable uAPI
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] drm/nova: missing kernel-parameters.txt entry for acknowledge_unstable_uapi --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] drm/nova: missing kernel-parameters.txt entry for acknowledge_unstable_uapi --
commit 77a1b4c686914a70a5ae235e8e03b1e3542d6c45
Author: Danilo Krummrich <[email protected]>
drm/nova: require explicit opt-in to unstable uAPI
This commit adds the acknowledge_unstable_uapi module parameter to nova-drm to require users to explicitly opt in to the unstable uAPI before enabling the driver, and taints the kernel when enabled.
Quoted 25 lines
drivers/gpu/drm/nova/Kconfig +10
-1@@ -12,6 +12,15 @@ config DRM_NOVA 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. + This driver is under active upstream development and may not be + functional. Its uAPI is intended to be developed upstream alongside + the driver and is not yet stable. It may change incompatibly during + development. + + Loading requires the acknowledge_unstable_uapi=1 module parameter, or + nova-drm.acknowledge_unstable_uapi=1 on the kernel command line when + built in. + + Enabling the driver taints the kernel. If M is selected, the module will be called nova-drm.drivers/gpu/drm/nova/nova.rs +0
-0
[ ... ]
Quoted 20 lines
drivers/gpu/drm/nova/nova.rs +14
-2-kernel::module_auxiliary_driver! { -type :NovaDriver , +module! { +type :NovaModule , name:"nova-drm" , authors: ["Danilo Krummrich" ], description:"Nova GPU driver" , license:"GPL v2" , +params : { + acknowledge_unstable_uapi:bool { +default :false , + description:"Acknowledge that Nova and its uAPI are under active upstream development \ +and the uAPI may change incompatibly; enable the driver (taints kernel)" , + }, + }, +} + +#[pin_data] +struct NovaModule { + #[pin]
drivers/gpu/drm/nova/nova.rs line 50
Quoted 10 lines
drivers/gpu/drm/nova/nova.rs +10
-0+ _driver: Registration<auxiliary::Adapter<NovaDriver>>, +} + +impl NovaModule { +fn check_unstable_uapi () ->Result { +pr_warn! ("Nova and its uAPI are under active upstream development\n" ); + +if !module_parameters::acknowledge_unstable_uapi.value () { +pr_err! ("Driver disabled: Nova's uAPI is unstable and may change incompatibly\n" ); +pr_info! ("Set nova-drm.acknowledge_unstable_uapi=1 to enable (taints kernel)\n" );
[Severity: Low]
Since NovaModule defines the acknowledge_unstable_uapi parameter in drivers/gpu/drm/nova/nova.rs and both DRM_NOVA in drivers/gpu/drm/nova/Kconfig and NovaModule::check_unstable_uapi() instruct users to pass nova-drm.acknowledge_unstable_uapi=1 on the kernel command line when built in, should this parameter also be documented in Documentation/admin-guide/kernel-parameters.txt?
Quoted 2 lines
drivers/gpu/drm/nova/nova.rs +2
-0+return Err (EPERM ); + }
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Re: (subset) [PATCH 0/3] drm/nova: make unstable uAPI use explicit
In reply to Danilo KrummrichQuoted 1 line · Danilo Krummrich
[PATCH 0/3] drm/nova: make unstable uAPI use explicit
Applied, thanks!
Branch: drm-rust-next
Tree: https://gitlab.freedesktop.org/drm/rust/kernel.git
[1/3] drm/nova: mark the uAPI header as unstable
commit: 4e85d5f62ec4
The patch will appear in the next linux-next integration (typically within 24 hours on weekdays).
The patch is queued up for the upcoming merge window for the next major kernel release.