Add device D to the two-core system. Use MESI for C0/C1 and a software handoff that stops CPU writes before D consumes the buffer. Warm start from X = 0: C0 M / 1, C1 I / -, H exclusive(C0), memory = 0. A coherent device read path snoops C0 and returns 1. A non-coherent path reads memory directly and returns the stale 0 unless software has cleaned the line first.
The Linux DMA guide distinguishes coherent and streaming mappings and explains why drivers use the DMA API. The clean itself is the trace already shown in Cache Maintenance Operations: PutM, H writes memory, Put-Ack, and the operation is complete. It is not redrawn here. The sourcing lesson supplies the coherent mechanism.
Case | What software or hardware does | Result in the X example |
|---|---|---|
Coherent DMA read | The coherent path snoops C0 on D's behalf, C0 supplies its dirty 1 | D reads 1. See I/O-Coherent Ports for the trace. |
Non-coherent DMA read | Software clean of X to the point of coherence (here memory) | memory = 1 and the clean has completed before the doorbell write, so D reads 1. |
Non-coherent D write of 2, then CPU read | Clean or invalidate X before D starts, invalidate X after D's completion | C0 invalidated, so the CPU load misses and reads D's 2 from memory. |
For the non-coherent snapshot, a device read of memory = 0 is a stale device input caused by a missing clean. It is not evidence that the CPU coherence controller lost X = 1: C0 still has it. Conversely, making the device path coherent would not fix an incorrect descriptor address or a device started before the producer finished.
Rule for a non-coherent device: clean the buffer's lines to the point of coherence before the device reads. Clean or invalidate before the device writes, so that a dirty CPU victim cannot later overwrite the device's data. Invalidate after the device completes and before the CPU reads, because speculative fills may have refetched the old value during the transfer. Use Part 3's clean and invalidate definitions; the platform API chooses the instructions.
A non-coherent device reads memory directly. If software did not clean X to the point of coherence before the doorbell, memory still holds 0. C0's 1 is not lost: the stale device input and a lost CPU value are different diagnoses.