Nope, the compiler just has to look at the spl() call and decide that
it doesn't know what that function does to globally-visible
memory. For our purposes, "an ISR could have changed the data before
the spl() call" is functionally equivalent to the spl() call changing
the data itself. As long as the compiler thinks that this is possible
- and that's exactly what the memory-clobber means - we're okay.
Nope, this is about convincing the compiler to do the right thing in
the top-half code. The compiler is not fundamentally aware of the
concurrency that's going on in the kernel, where interrupts can
happen; by making the spl()s have these barriers and clobbers, we're
making it treat them properly. The same issue arises with
pthread_mutex_lock() and unlock(); those work because they are
function calls. In an implementation where they are not, they would
need similar manual annotations for clobbering memory.
It's not really about bus_dma(9)'s guarantees, which are generally at
a different layer (though they also offer useful opportunites for
barrier constructs that the compiler can respect).
- Nathan