7.6 DSB
DSB (Data Synchronization Barrier) is about completion. A DMB fixes the order in which observers see accesses. A DSB waits until earlier operations are complete in the sense of 7.1, and holds back every later instruction until then. It is the only barrier that can tell you a TLBI or a DC has finished, and the one you need before WFI, before a power transition, and before an ISB that has to see the result of maintenance.
Encoding and options
DSB <option> uses the same CRm encodings as DMB (7.5) for SY, ST, LD, ISH, ISHST, ISHLD, NSH, NSHST, NSHLD, OSH, OSHST and OSHLD. Two CRm values whose access-type bits (CRm[1:0]) are 0b00 do not encode a DSB at all and are reused:
| Encoding | Instruction | Purpose |
|---|---|---|
DSB with CRm = 0b0000 | SSBB | Speculative Store Bypass Barrier (14.5) |
DSB with CRm = 0b0100 | PSSBB | Physical Speculative Store Bypass Barrier (14.5) |
DSB <option>nXS (separate encoding, FEAT_XS) | DSB SYnXS, ISHnXS, OSHnXS, NSHnXS | Need not wait for accesses to memory with the XS attribute (9.1) |
SSBB and PSSBB are not memory barriers in the ordering sense. Do not write DSB #0 expecting a weak DSB.
The completion rule
From the DSB definition in DDI0487, restated:
- All explicit memory accesses of the required access types that appear in program order before the DSB are complete for the required domain.
- If the required access types are reads and writes (no
LD/STqualifier), all cache maintenance and TLB maintenance instructions issued by this PE before the DSB are complete for the required domain. - No instruction after the DSB in program order can change any state of the system, or perform any part of its function, until the DSB completes. Being fetched and decoded is allowed, and so are a small number of side-effect-free operations that DDI0487 lists.
Rule 2 is the one that bites. DSB ISHST or DSB ST does not wait for a TLBI or a DC to complete. Only a full DSB does. In the TLB update sequence (9.1), the DSB ISHST before the TLBI makes the descriptor store complete. The DSB ISH after it waits for the invalidation. Swapping them, or using ST for both, is a real bug.
Rule 3 is what makes DSB expensive. It is not just “later memory accesses wait”. Later arithmetic also waits, as do system-register writes, WFI, everything except fetch and decode.
Everything a DMB with the same access types orders, the DSB orders too. A DSB is strictly stronger.
What “complete” means for each kind of operation
| Operation before the DSB | Complete when… | Typical consequence |
|---|---|---|
| Load | Its value is returned and no write by any observer can change it | Later instructions see a fixed value |
| Store to Normal memory | Globally observed (coherent observers) | No coherent observer can read the old value |
Store to Device memory, E | Acknowledged, possibly by an intermediate buffer | The peripheral may not have received it yet |
Store to Device memory, nE | Acknowledged by the endpoint | Received, but the side effect is not guaranteed to have happened (7.9) |
TLBI (local or broadcast) | No observer can make a new access using the invalidated entries, and earlier accesses that used them are complete | Safe to free or reuse the old page, after an ISB for this PE’s own instruction stream |
DC CVAC/CIVAC/CVAU/IVAC/... | The clean/invalidate has taken effect to the named point (PoC, PoU, PoP…) | A non-coherent master can read it, or the instruction side can fetch it (8.5) |
IC IVAU/IALLUIS/... | The invalidation has taken effect in all instruction caches in scope | Still needs an ISB before this PE executes the new code (8.6) |
A DSB never resynchronizes the instruction stream. After TLBI ...; DSB ISH, instructions already fetched under the old translation may still be in the pipeline. That is why the sequence ends in ISB (7.8).
The domain is now a “maintenance scope”
The same DDI0487 Known Issues entry that deprecates the DMB shareability argument (AARCH-24234, raised against issue M.a, see 7.5) also redefines the DSB argument:
- Because the model is other-multi-copy atomic, completion of explicit loads and stores does not depend on the domain. The argument is renamed the maintenance scope, and it matters only for the completion of TLBI and IC effects.
DSB ISHtherefore means “wait for my maintenance to complete across the Inner Shareable scope”. It is the natural partner ofTLBI ...ISandIC IALLUIS.DSB NSHis enough after purely local maintenance (TLBI VAE1,IC IALLU) when nothing else needs to observe it.DSB SYbehaves asDSB OSH.- The scope qualifiers on the
LDandSTforms (DSB ISHST,DSB NSHLD…) are deprecated. Those forms do not wait for maintenance, so a scope means nothing for them. ExistingDSB ISHSTbehaves exactly asDSB ST.
Older code and older text (including the classic TLB sequence written with DSB ISHST) is still correct. Only its spelling is deprecated. herdtools7 now flags Maintenance-scope-for-DSB-ST-is-deprecated for it (and Maintenance-scope-for-DSB-LD-is-deprecated for the LD forms).
The DSB-before-WFI rule
WFI is a hint that may put the PE into a low-power state. The architecture does not require WFI to wait for earlier memory accesses or maintenance to complete. Two failures follow from that:
- Power-down. If the PE (or its cluster) loses power after
WFI, outstanding stores and CMOs can be lost or left half-done. Every power-down path ends with completion first:
// TF-A style: psci_power_down_wfi
dsb sy // all earlier stores and maintenance complete
1: wfi
b 1b // not expected to return when powering down
- Handshakes. If the PE writes a “going to sleep” flag, clears a peripheral interrupt or releases a mailbox and then executes
WFI, the write may still be buffered while the PE sleeps. Another agent that waits for the write, and would then send the wake-up, may wait forever. Some implementations drain buffers on WFI anyway, which is IMPLEMENTATION DEFINED behaviour and exactly why the bug survives on one core and appears on the next.
The same reasoning applies before any operation with an effect outside the memory model that must follow earlier accesses: writing a reset controller register, handing off to a power controller over a doorbell, or SMC-ing to EL3 for a power state change. 7.10 has the recipes, and the CPU power-state flow is in 17.4.
DSB vs DMB cost
| Aspect | DMB | DSB |
|---|---|---|
| Waits for | Nothing (constrains order only) | Completion of the selected accesses and, for the full form, maintenance |
| Blocks later non-memory instructions | No | Yes |
Device nE store before it | Later accesses ordered behind it | Round trip to the endpoint |
Broadcast TLBI/IC before it | Not waited for | All PEs in scope must acknowledge. On AMBA CHI this is a DVM Sync and its responses (8.3) |
In the 6.1 picture, a DMB can usually be satisfied inside the PE’s load/store unit, while a DSB drains it and may wait on the farthest agent in the system. After a broadcast TLBI on a large mesh or across chiplets, a DSB can take microseconds. Use DSB only where completion is the property you need: before WFI/power-down, after maintenance, before an ISB that must see completed maintenance, and before signalling an agent outside the memory model. Everywhere else, use DMB, acquire/release or a dependency.
Bring-up note: “The core is stuck with the PC on a
DSB” is a classic first-silicon or new-platform symptom. It means something before the DSB never completed. The usual suspects are a Device write to an unclocked or unpowered peripheral that never returns a response, and a broadcastTLBI/ICwhose DVM messages the interconnect is not configured to handle (a DVM or snoop domain not enabled for the cluster, or a chiplet link not yet up). Look at the instruction before the DSB, then at the interconnect’s DVM and snoop configuration. 18.2 has the full triage.
Validation note: Time
TLBI VAE1IS; DSB ISHwithPMCCNTR_EL0for three placements: all PEs on one cluster, across clusters, and across chiplets. A latency that does not grow with scope suggests the TLBI was not actually broadcast (checkTLBIvsTLBI ...ISin the binary and the interconnect DVM counters). A large step across chiplets is expected, and it feeds the TLB shootdown budget. For CMOs, confirm completion functionally: clean a buffer,DSB SY, have a non-coherent DMA master read it, and compare. Run the same test with the DSB removed. The failure rate without it is your evidence that the test exercises the path (8.10).
Checkpoint
Q7.6.1 EL2 code unmaps a stage 2 page with STR xzr, [desc]; DSB ISHST; TLBI IPAS2E1IS, x0; DSB ISHST; TLBI VMALLE1IS; DSB ISHST; ISB and then frees the page. What is wrong?
- A. Nothing, because each
DSB ISHSTorders the TLBIs behind the descriptor store - B. The first
DSB ISHSTshould be aDMB ISHST - C. The DSBs after the TLBIs must be full (
DSB ISH). AST-only DSB does not wait for TLB maintenance to complete, so the page can be freed while other PEs still hold translations to it - D. The final
ISBshould come before the last DSB
Answer
C. Only a DSB whose required access types are reads and writes waits for TLB and cache maintenance. The first DSB ISHST is right: it only needs the descriptor store to complete before the walkers can be asked to re-walk. B would weaken it to ordering only, and a DMB does not order the descriptor store against the later TLBI: a TLBI is not an explicit memory access.
Read more: Arm ARM (DDI0487), DSB; the AArch64 VMSA chapter, “TLB maintenance instructions” and the ordering and completion of TLB maintenance
Q7.6.2 A CPU_OFF path cleans the PE’s data cache to the PoC, writes a “core off” flag to Normal Non-cacheable memory for the power controller, and executes WFI. On one SoC it works. On another, the power controller occasionally waits forever for the flag. What is the most likely missing step?
- A. A
DSB SYbeforeWFI, because WFI does not wait for the flag store or the cache clean to complete - B. An
ISBbeforeWFI, so that the flag store is executed - C. A
DMB STbetween the clean and the flag store - D. Making the flag memory Device-nGnRnE, so the store cannot be buffered
Answer
A. Without a DSB, the flag store (and the clean) may still be in flight when the PE stops. Whether WFI drains buffers is IMPLEMENTATION DEFINED, which explains the difference between the SoCs. B does nothing for completion. C orders the store after the clean but does not make either one complete. D changes where the acknowledgement comes from, but still nothing waits for it.
Read more: Arm ARM (DDI0487), WFI (“Wait For Interrupt”) and DSB; TF-A psci_power_down_wfi
Q7.6.3 Under the redefinition in Known Issues entry AARCH-24234, which use of the DSB argument still changes behaviour?
- A.
DSB ISHSTvsDSB OSHSTbefore a DMA doorbell - B.
DSB ISHLDvsDSB LDafter reading a mailbox - C.
DSB ISHvsDSB SYfor ordering two Device stores - D.
DSB NSHvsDSB ISHafter a broadcastTLBI VAE1IS
Answer
D. The argument is now a maintenance scope that matters only for TLBI and IC completion. After a broadcast TLBI, NSH scope is not enough to wait for the other PEs, and ISH is needed. For explicit accesses (A, B, C) completion does not depend on the domain, and the qualifiers on the LD/ST forms are deprecated.
Read more: Arm ARM (DDI0487), DSB; DDI0487 Known Issues, AARCH-24234