[PATCH v3 0/2] rust: add initial scatterlist abstraction

Abdiel Janulgue posted 2 patches 2 months, 2 weeks ago
rust/bindings/bindings_helper.h |   1 +
rust/helpers/helpers.c          |   1 +
rust/helpers/scatterlist.c      |  30 +++
rust/kernel/dma.rs              |  18 ++
rust/kernel/lib.rs              |   1 +
rust/kernel/scatterlist.rs      | 405 ++++++++++++++++++++++++++++++++
samples/rust/rust_dma.rs        |  49 +++-
7 files changed, 504 insertions(+), 1 deletion(-)
create mode 100644 rust/helpers/scatterlist.c
create mode 100644 rust/kernel/scatterlist.rs
[PATCH v3 0/2] rust: add initial scatterlist abstraction
Posted by Abdiel Janulgue 2 months, 2 weeks ago
Hi all,

This is v3 of the rust scatterlist abstraction incorporating feedback
and code from Alexandre Courbot.

Changes since v3:
- After further discussion it seems we need a variant of typestate after
  all. A major change for this version is to introduce unsafe methods only
  when using one of the constructors for a SG table. Otherwise nothing in
  the interface should need to be unsafe.

Changes since v2:
- Drop typestate pattern. Introduce SGTablePages trait to enforce ownership
  of the pages to SGTable.

Link to v2: https://lore.kernel.org/lkml/20250626203247.816273-1-abdiel.janulgue@gmail.com/

Abdiel Janulgue (2):
  rust: add initial scatterlist abstraction
  samples: rust: add sample code for scatterlist abstraction

 rust/bindings/bindings_helper.h |   1 +
 rust/helpers/helpers.c          |   1 +
 rust/helpers/scatterlist.c      |  30 +++
 rust/kernel/dma.rs              |  18 ++
 rust/kernel/lib.rs              |   1 +
 rust/kernel/scatterlist.rs      | 405 ++++++++++++++++++++++++++++++++
 samples/rust/rust_dma.rs        |  49 +++-
 7 files changed, 504 insertions(+), 1 deletion(-)
 create mode 100644 rust/helpers/scatterlist.c
 create mode 100644 rust/kernel/scatterlist.rs


base-commit: 23b128bba76776541dc09efaf3acf6242917e1f0
-- 
2.43.0
Re: [PATCH v3 0/2] rust: add initial scatterlist abstraction
Posted by Danilo Krummrich 2 months, 2 weeks ago
On 7/18/25 12:33 PM, Abdiel Janulgue wrote:
> Abdiel Janulgue (2):
>    rust: add initial scatterlist abstraction
>    samples: rust: add sample code for scatterlist abstraction
> 
>   rust/bindings/bindings_helper.h |   1 +
>   rust/helpers/helpers.c          |   1 +
>   rust/helpers/scatterlist.c      |  30 +++
>   rust/kernel/dma.rs              |  18 ++
>   rust/kernel/lib.rs              |   1 +
>   rust/kernel/scatterlist.rs      | 405 ++++++++++++++++++++++++++++++++
>   samples/rust/rust_dma.rs        |  49 +++-
>   7 files changed, 504 insertions(+), 1 deletion(-)
>   create mode 100644 rust/helpers/scatterlist.c
>   create mode 100644 rust/kernel/scatterlist.rs

I think this is missing a corresponding MAINTAINERS entry. I assume the
scatterlist stuff should go under the "DMA MAPPING HELPERS DEVICE DRIVER API
[RUST]" entry (which we may want to rename a bit for this purpose).

@Andrew: Any comments or other preferences from your end?