[PATCH 0/3] rust: more memory barriers bindings

From: Gary Guo

Date: Thu Apr 02 2026 - 11:33:06 EST


From: Gary Guo <gary@xxxxxxxxxxx>

This expands the existing smp barriers to also mandatory barriers and
DMA barriers.

The API looks like:
`mb(Ordering)`/`smp_mb(Ordering)`/`dma_mb(Ordering)`, where `Ordering`
is one of `Full`, `Read`, `Write` and also `Acquire`, `Release`.

The `Acquire` and `Release` barriers are mapped to `Full` barriers for
now and they only serve the purpose of documenting what ordering is
needed without codegen optimizations, but they could be improved
later to produce better codegen compared to full barriers. More on them
in the commit message of patch 2.

A user of these introduced API is included in patch 3, which is a
concurrency bug that exists in Nova code today due to missing barriers.

To: Miguel Ojeda <ojeda@xxxxxxxxxx>
To: Boqun Feng <boqun@xxxxxxxxxx>
To: Danilo Krummrich <dakr@xxxxxxxxxx>
To: Alexandre Courbot <acourbot@xxxxxxxxxx>
Cc: Björn Roy Baron <bjorn3_gh@xxxxxxxxxxxxxx>
Cc: Benno Lossin <lossin@xxxxxxxxxx>
Cc: Andreas Hindborg <a.hindborg@xxxxxxxxxx>
Cc: Alice Ryhl <aliceryhl@xxxxxxxxxx>
Cc: Trevor Gross <tmgross@xxxxxxxxx>
Cc: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>
Cc: Andrea Parri <parri.andrea@xxxxxxxxx>
Cc: Will Deacon <will@xxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Nicholas Piggin <npiggin@xxxxxxxxx>
Cc: David Howells <dhowells@xxxxxxxxxx>
Cc: Jade Alglave <j.alglave@xxxxxxxxx>
Cc: Luc Maranget <luc.maranget@xxxxxxxx>
Cc: "Paul E. McKenney" <paulmck@xxxxxxxxxx>
Cc: Akira Yokosawa <akiyks@xxxxxxxxx>
Cc: Daniel Lustig <dlustig@xxxxxxxxxx>
Cc: Joel Fernandes <joelagnelf@xxxxxxxxxx>
Cc: rust-for-linux@xxxxxxxxxxxxxxx
Cc: nouveau@xxxxxxxxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
Cc: linux-arch@xxxxxxxxxxxxxxx
Cc: lkmm@xxxxxxxxxxxxxxx

Gary Guo (3):
rust: sync: add helpers for mb, dma_mb and friends
rust: sync: generic memory barriers
gpu: nova-core: fix wrong use of barriers in GSP code

drivers/gpu/nova-core/gsp/cmdq.rs | 19 +++
drivers/gpu/nova-core/gsp/fw.rs | 12 --
rust/helpers/barrier.c | 30 +++++
rust/kernel/sync/atomic/ordering.rs | 2 +-
rust/kernel/sync/barrier.rs | 194 ++++++++++++++++++++++++----
5 files changed, 217 insertions(+), 40 deletions(-)


base-commit: 36ece9697e89016181e5ae87510e40fb31d86f2b
--
2.51.2