summaryrefslogtreecommitdiff
path: root/arch/tile/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-05-24 05:05:11 +0300
committerLinus Torvalds <torvalds@linux-foundation.org>2016-05-24 05:05:11 +0300
commitd6542d76ec88dde3305b06c03952d87b15bbc292 (patch)
tree4510f1b1bef283f22e168bbfd5933983c991fe78 /arch/tile/include
parent3ec438afed6f166f1774b3e95b9a65e3b6da5f2c (diff)
parentbdf03e59f8c136f709dd44987ad21f6ce19dc98c (diff)
downloadlinux-d6542d76ec88dde3305b06c03952d87b15bbc292.tar.xz
Merge git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile
Pull arch/tile updates from Chris Metcalf: "This is an even quieter cycle than usual" * git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile: Fix typo Fix typo Fix typo tile: sort the "select" lines in the TILE/TILEGX configs tile: clarify barrier semantics of atomic_add_return tile/defconfigs: Remove CONFIG_IPV6_PRIVACY
Diffstat (limited to 'arch/tile/include')
-rw-r--r--arch/tile/include/asm/atomic_64.h17
1 files changed, 15 insertions, 2 deletions
diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
index 51cabc26e387..b0531a623653 100644
--- a/arch/tile/include/asm/atomic_64.h
+++ b/arch/tile/include/asm/atomic_64.h
@@ -37,12 +37,25 @@ static inline void atomic_add(int i, atomic_t *v)
__insn_fetchadd4((void *)&v->counter, i);
}
+/*
+ * Note a subtlety of the locking here. We are required to provide a
+ * full memory barrier before and after the operation. However, we
+ * only provide an explicit mb before the operation. After the
+ * operation, we use barrier() to get a full mb for free, because:
+ *
+ * (1) The barrier directive to the compiler prohibits any instructions
+ * being statically hoisted before the barrier;
+ * (2) the microarchitecture will not issue any further instructions
+ * until the fetchadd result is available for the "+ i" add instruction;
+ * (3) the smb_mb before the fetchadd ensures that no other memory
+ * operations are in flight at this point.
+ */
static inline int atomic_add_return(int i, atomic_t *v)
{
int val;
smp_mb(); /* barrier for proper semantics */
val = __insn_fetchadd4((void *)&v->counter, i) + i;
- barrier(); /* the "+ i" above will wait on memory */
+ barrier(); /* equivalent to smp_mb(); see block comment above */
return val;
}
@@ -95,7 +108,7 @@ static inline long atomic64_add_return(long i, atomic64_t *v)
int val;
smp_mb(); /* barrier for proper semantics */
val = __insn_fetchadd((void *)&v->counter, i) + i;
- barrier(); /* the "+ i" above will wait on memory */
+ barrier(); /* equivalent to smp_mb; see atomic_add_return() */
return val;
}