Skip to content

fix(dmac): Use inline asm for compiler fences in DMAC#985

Open
jbeaurivage wants to merge 3 commits intoatsamd-rs:masterfrom
jbeaurivage:dmac-safe-fences
Open

fix(dmac): Use inline asm for compiler fences in DMAC#985
jbeaurivage wants to merge 3 commits intoatsamd-rs:masterfrom
jbeaurivage:dmac-safe-fences

Conversation

@jbeaurivage
Copy link
Contributor

Summary

According to this discussion, it seems core::sync::atomic::{fence, compiler_fence} aren't a strong guarantee that the compiler won't reorder memory accesses beyond the fence. The suggested fix is to add an inline assembly call, which apparently guarantees there won't be any memory accesses beyond the asm call.

@jbeaurivage jbeaurivage force-pushed the dmac-safe-fences branch 2 times, most recently from f24948e to 563cf3d Compare January 25, 2026 05:04
@rnd-ash
Copy link
Contributor

rnd-ash commented Jan 28, 2026

Looks good @jbeaurivage , but maybe, its best to put the fence functions near the crate root for future use by other peripherals should we need to in future? - Or is this specific to DMAC?

@jbeaurivage
Copy link
Contributor Author

I think this should remain a DMAC-specific thing, as peripherals are expected to control DMA through the DMAC API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants