question on memory barriers
Hi,
this code made me think:
/* Give this link TRB to the hardware */
wmb();
next->link.control ^= cpu_to_le32(TRB_CYCLE);Can you do this or may there be a CPU that speculatively writes before it reads next->link.control ?
Regards
Oliver
Signature · 6 lines
- - - SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg) Maxfeldstraße 5 90409 Nürnberg Germany - - -
Quoted 10 lines · Oliver Neukum
Hi,
this code made me think:
/* Give this link TRB to the hardware */ wmb(); next->link.control ^= cpu_to_le32(TRB_CYCLE);Can you do this or may there be a CPU that speculatively writes before it reads
next->link.control?
CPUs never do speculative writes. And even if they did, the wmb() would prevent the speculative write from preceding any statement that comes before the memory barrier.
Alan Stern