dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC 0/4] rust: Introduce support for C linked list interfacing and DRM Buddy bindings
@ 2025-10-30 19:06 Joel Fernandes
  2025-10-30 19:06 ` [PATCH RFC 1/4] rust: clist: Add abstraction for iterating over C linked lists Joel Fernandes
                   ` (3 more replies)
  0 siblings, 4 replies; 32+ messages in thread
From: Joel Fernandes @ 2025-10-30 19:06 UTC (permalink / raw)
  To: linux-kernel, rust-for-linux, dri-devel, dakr, David Airlie
  Cc: acourbot, Alistair Popple, Miguel Ojeda, Alex Gaynor, Boqun Feng,
	Gary Guo, bjorn3_gh, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Simona Vetter, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, John Hubbard, Joel Fernandes, Timur Tabi, joel,
	Elle Rhumsaa, Daniel Almeida, Andrea Righi, Philipp Stanner,
	nouveau

Introduction
============
This patchset introduces an interface to iterate over doubly circular linked
lists used in the kernel (allocated by C kernel code). The main usecase is
iterating over the list of blocks provided by the DRM buddy allocator.

The first 2 patches introduce a new rust module called clist. The last 2
patches use the clist in the DRM buddy allocator bindings. Samples have been
provided to show the usage.

A question may arise:  Why not use rust list.rs for this?
=========================================================
Rust's list.rs is used to provide safe intrusive lists for Rust-allocated
items. In doing so, it takes ownership of the items in the list and the links
between list items. However, the usecase for DRM buddy allocator bindings, the
C side allocates the items in the list, and also links the list together. Due
to this, there is an ownership conflict making list.rs not the best abstraction
for this usecase. What we need is a view of the list, not ownership of it.
Further, the list links in a bindings usecase may come from C allocated
objects, not from the Rust side.

Other comments
==============
The patches IMO are ahead of RFC-quality, but I am still keeping the RFC
tag for initial comments and to get a sense of what everyone thinks. I already
presented the idea in Zulip and it seemed it mostly got agreements there. I
rebased the patches on linux-next. I can also add MAINTAINER entries in v2, if
folks agree this should have its own MAINTAINER record.

Joel Fernandes (4):
  rust: clist: Add abstraction for iterating over C linked lists
  samples: rust: Add sample demonstrating C linked list iteration
  rust: drm: Add DRM buddy allocator bindings
  samples: rust: Add sample demonstrating DRM buddy allocator

 rust/bindings/bindings_helper.h |  11 +
 rust/helpers/drm.c              |  23 +-
 rust/helpers/helpers.c          |   1 +
 rust/helpers/list.c             |  28 +++
 rust/kernel/clist.rs            | 296 ++++++++++++++++++++++++++
 rust/kernel/drm/buddy.rs        | 357 ++++++++++++++++++++++++++++++++
 rust/kernel/drm/mod.rs          |   1 +
 rust/kernel/lib.rs              |   1 +
 samples/rust/Kconfig            |  25 +++
 samples/rust/Makefile           |   3 +
 samples/rust/rust_clist_c.c     |  54 +++++
 samples/rust/rust_clist_main.rs | 138 ++++++++++++
 samples/rust/rust_drm_buddy.rs  | 106 ++++++++++
 13 files changed, 1043 insertions(+), 1 deletion(-)
 create mode 100644 rust/helpers/list.c
 create mode 100644 rust/kernel/clist.rs
 create mode 100644 rust/kernel/drm/buddy.rs
 create mode 100644 samples/rust/rust_clist_c.c
 create mode 100644 samples/rust/rust_clist_main.rs
 create mode 100644 samples/rust/rust_drm_buddy.rs


base-commit: 131f3d9446a6075192cdd91f197989d98302faa6
-- 
2.34.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2025-11-05 22:43 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-30 19:06 [PATCH RFC 0/4] rust: Introduce support for C linked list interfacing and DRM Buddy bindings Joel Fernandes
2025-10-30 19:06 ` [PATCH RFC 1/4] rust: clist: Add abstraction for iterating over C linked lists Joel Fernandes
2025-10-30 21:15   ` Danilo Krummrich
2025-10-30 22:44     ` Joel Fernandes
2025-11-01  3:51   ` Alexandre Courbot
2025-11-04  0:58     ` Joel Fernandes
2025-11-04 13:42       ` Alexandre Courbot
2025-11-04 14:07         ` Miguel Ojeda
2025-11-04 14:35           ` Guillaume Gomez
2025-11-04 18:35             ` Miguel Ojeda
2025-11-04 19:06               ` Miguel Ojeda
2025-11-05 10:54                 ` Guillaume Gomez
2025-11-04 13:52       ` Miguel Ojeda
2025-11-05 22:42         ` Joel Fernandes
2025-11-04 13:49     ` Danilo Krummrich
2025-10-30 19:06 ` [PATCH RFC 2/4] samples: rust: Add sample demonstrating C linked list iteration Joel Fernandes
2025-10-30 21:15   ` Danilo Krummrich
2025-10-30 22:09     ` Joel Fernandes
2025-11-01  3:52     ` Alexandre Courbot
2025-11-01 15:47       ` Miguel Ojeda
2025-10-30 19:06 ` [PATCH RFC 3/4] rust: drm: Add DRM buddy allocator bindings Joel Fernandes
2025-10-30 21:27   ` Danilo Krummrich
2025-10-30 22:49     ` Joel Fernandes
2025-10-31  9:25   ` Alice Ryhl
2025-11-04 22:57     ` Joel Fernandes
2025-11-01  5:08   ` Alexandre Courbot
2025-11-05  0:59     ` Joel Fernandes
2025-11-01  5:19   ` Alexandre Courbot
2025-10-30 19:06 ` [PATCH RFC 4/4] samples: rust: Add sample demonstrating DRM buddy allocator Joel Fernandes
2025-10-30 21:17   ` Danilo Krummrich
2025-10-31 16:42   ` Matthew Auld
2025-11-01  5:11   ` Alexandre Courbot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).