]> git.baikalelectronics.ru Git - kernel.git/commit
metag: fix memory barriers
authorMikulas Patocka <mpatocka@redhat.com>
Thu, 8 May 2014 19:51:37 +0000 (15:51 -0400)
committerJames Hogan <james.hogan@imgtec.com>
Wed, 14 May 2014 23:00:34 +0000 (00:00 +0100)
commit4a044a5ef6b70e6b0ec53052117d50ca3d58e246
treec7f5c430603383d0875633f983d0c21030b8d715
parent992383c95ec7ad652d78c0258f849d6a422720f4
metag: fix memory barriers

Volatile access doesn't really imply the compiler barrier. Volatile access
is only ordered with respect to other volatile accesses, it isn't ordered
with respect to general memory accesses. Gcc may reorder memory accesses
around volatile access, as we can see in this simple example (if we
compile it with optimization, both increments of *b will be collapsed to
just one):

void fn(volatile int *a, long *b)
{
(*b)++;
*a = 10;
(*b)++;
}

Consequently, we need the compiler barrier after a write to the volatile
variable, to make sure that the compiler doesn't reorder the volatile
write with something else.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: stable@vger.kernel.org
Acked-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: James Hogan <james.hogan@imgtec.com>
arch/metag/include/asm/barrier.h