diff options
author | 2025-03-06 23:23:30 +0100 | |
---|---|---|
committer | 2025-03-09 19:24:27 +0100 | |
commit | 54e6baf123fde089cfa9f609b0b39b40abe41e94 (patch) | |
tree | e33cdbf61ecc85552edb2d114e2da110f10c99b1 /drivers/gpu/nova-core/util.rs | |
parent | rust: firmware: add `module_firmware!` macro (diff) | |
download | wireguard-linux-54e6baf123fde089cfa9f609b0b39b40abe41e94.tar.xz wireguard-linux-54e6baf123fde089cfa9f609b0b39b40abe41e94.zip |
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: Alexandre Courbot <acourbot@nvidia.com>
Link: https://lore.kernel.org/r/20250306222336.23482-5-dakr@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Diffstat (limited to 'drivers/gpu/nova-core/util.rs')
-rw-r--r-- | drivers/gpu/nova-core/util.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/gpu/nova-core/util.rs b/drivers/gpu/nova-core/util.rs new file mode 100644 index 000000000000..332a64cfc6a9 --- /dev/null +++ b/drivers/gpu/nova-core/util.rs @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 + +pub(crate) const fn to_lowercase_bytes<const N: usize>(s: &str) -> [u8; N] { + let src = s.as_bytes(); + let mut dst = [0; N]; + let mut i = 0; + + while i < src.len() && i < N { + dst[i] = (src[i] as char).to_ascii_lowercase() as u8; + i += 1; + } + + dst +} + +pub(crate) const fn const_bytes_to_str(bytes: &[u8]) -> &str { + match core::str::from_utf8(bytes) { + Ok(string) => string, + Err(_) => kernel::build_error!("Bytes are not valid UTF-8."), + } +} |