This patch adds safe Rust abstractions over the Linux kernel's GPU buddy allocator for physical memory management. The prerequisite infrastructure patches (DRM buddy code movement and the uninitialized buddy fix) have been absorbed into upstream -next, so this is now a standalone patch.
The git tree with all patches can be found at: git://git.kernel.org/pub/scm/linux/kernel/git/jfern/linux.git (tag: gpu-buddy-bindings-v12.1-20260309) Change log: Changes from v12 to v12.1: - Fixed undeclared type `GpuBuddyFlags` in doc examples: renamed to `GpuBuddyAllocFlags` in all seven doc test examples (found by kernel test robot). Changes from v11 to v12: - Rebased on linux-next; this is now a standalone single patch as dependencies are absorbed (but clist is a prerequisite). - Redesigned allocation API (Alexandre Courbot) for better Rust ergonomics. - Split single long example into 4 self-contained examples (Alexandre Courbot). - Several safety and invariant comment changes (Danilo). - MAINTAINERS changes (Arun, Mathew, Danilo, Dave). - Fixed `#[cfg(CONFIG_GPU_BUDDY)]` to `#[cfg(CONFIG_GPU_BUDDY = "y")]` (Danilo Krummrich). - Updated `ffi::clist::CListHead` to `interop::list::CListHead`. Changes from v10 to v11: - Dropped "rust: ffi: Convert pub use to pub mod and create ffi module" patch; the ffi module restructuring will go through a different path. - Dropped "rust: clist: Add support to interface with C linked lists" patch; the clist module will be submitted separately. - Dropped "nova-core: Kconfig: Sort select statements alphabetically" cosmetic patch. - Patches 1-3 (DRM buddy movement and fix) are included as reference only; they are already being pulled into upstream via drm-misc-next. - Removed clist patches as those can go in independently (Alice). - Moved the Kconfig GPU_BUDDY selection patch to nova-core mm series to enable it when it is actually used. - Various nits to comments, etc. Changes from v9 to v10: - Absorbed the DRM buddy code movement patches into this series as patches 1-2. Dave Airlie reworked these into two parts for better git history. - Added "gpu: Fix uninitialized buddy for built-in drivers" fix by Koen Koning, using subsys_initcall instead of module_init to fix NULL pointer dereference when built-in drivers use the buddy allocator before initialization. - Added "rust: ffi: Convert pub use to pub mod and create ffi module" to prepare the ffi module for hosting clist as a sub-module. - Moved clist from rust/kernel/clist.rs to rust/kernel/ffi/. - Added "nova-core: Kconfig: Sort select statements alphabetically" (Danilo). Changes from v8 to v9: - Updated nova-core Kconfig patch: addressed sorting of Kconfig options. - Added Daniel Almeida's Reviewed-by tag to clist patch. - Minor refinements to GPU buddy bindings. Changes from v7 to v8: - Added nova-core Kconfig patch to select GPU_BUDDY for VRAM allocation. - Various changes suggested by Danilo Krummrich, Gary Guo, and Daniel Almeida. - Added Acked-by: Gary Guo for clist patch. Changes from v6 to v7: - Major restructuring: split the large 26-patch v6 RFC series. v7 only contains the Rust infrastructure patches (clist + GPU buddy bindings), extracted from the full nova-core MM series. The nova-core MM patches follow separately. - Rebased on linux-next. Link to v12: https://lore.kernel.org/all/[email protected]/ Link to v11: https://lore.kernel.org/all/[email protected]/ Joel Fernandes (1): rust: gpu: Add GPU buddy allocator bindings MAINTAINERS | 6 +- rust/bindings/bindings_helper.h | 11 + rust/helpers/gpu.c | 23 ++ rust/helpers/helpers.c | 1 + rust/kernel/gpu/buddy.rs | 611 ++++++++++++++++++++++++++++++++ rust/kernel/gpu/mod.rs | 5 + rust/kernel/lib.rs | 2 + 7 files changed, 658 insertions(+), 1 deletion(-) create mode 100644 rust/helpers/gpu.c create mode 100644 rust/kernel/gpu/buddy.rs create mode 100644 rust/kernel/gpu/mod.rs -- 2.34.1
