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

Danilo Krummrich posted 5 patches 2 months, 4 weeks ago
There is a newer version of this series
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(-)
[PATCH 0/5] dma::Device trait and DMA mask
Posted by Danilo Krummrich 2 months, 4 weeks ago
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@kernel.org/ [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
Re: [PATCH 0/5] dma::Device trait and DMA mask
Posted by Abdiel Janulgue 2 months, 3 weeks ago
Thanks for completing this missing feature!

I've looked it into detail, and for patches 1, 2, and 5:

Reviewed-by: Abdiel Janulgue <abdiel.janulgue@gmail.com>

On 7/10/25 22:45, Danilo Krummrich wrote:
> 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@kernel.org/ [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