[PATCH 0/5] dma::Device trait and DMA mask

From: Danilo Krummrich
Date: Thu Jul 10 2025 - 15:46:16 EST


This patch series adds the dma::Device trait to be implemented by bus devices on
DMA capable busses.

The dma::Device trait implements methods to set the DMA mask for for such
devices.

The first two bus devices implementing the trait are PCI and platform.

Unfortunately, the DMA mask setters have to be unsafe for now, since, with
reasonable effort, we can't prevent drivers from data races writing and reading
the DMA mask fields concurrently (see also [1]).

Link: https://lore.kernel.org/lkml/DB6YTN5P23X3.2S0NH4YECP1CP@xxxxxxxxxx/ [1]
Link: https://git.kernel.org/pub/scm/linux/kernel/git/dakr/linux.git/log/?h=rust/dma-mask

Danilo Krummrich (5):
rust: dma: implement `dma::Device` trait
rust: dma: add DMA addressing capabilities
rust: pci: implement the `dma::Device` trait
rust: platform: implement the `dma::Device` trait
rust: samples: dma: set DMA mask

rust/helpers/dma.c | 5 +++
rust/kernel/dma.rs | 95 +++++++++++++++++++++++++++++++++++++---
rust/kernel/pci.rs | 2 +
rust/kernel/platform.rs | 2 +
samples/rust/rust_dma.rs | 12 ++++-
5 files changed, 109 insertions(+), 7 deletions(-)


base-commit: d49ac7744f578bcc8708a845cce24d3b91f86260
--
2.50.0