Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9d664c0a authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar
Browse files

locking/atomic: Fix atomic_set_release() for 'funny' architectures



Those architectures that have a special atomic_set implementation also
need a special atomic_set_release(), because for the very same reason
WRITE_ONCE() is broken for them, smp_store_release() is too.

The vast majority is architectures that have spinlock hash based atomic
implementation except hexagon which seems to have a hardware 'feature'.

The spinlock based atomics should be SC, that is, none of them appear to
place extra barriers in atomic_cmpxchg() or any of the other SC atomic
primitives and therefore seem to rely on their spinlock implementation
being SC (I did not fully validate all that).

Therefore, the normal atomic_set() is SC and can be used at
atomic_set_release().

Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Chris Metcalf <cmetcalf@mellanox.com> [for tile]
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will.deacon@arm.com>
Cc: davem@davemloft.net
Cc: james.hogan@imgtec.com
Cc: jejb@parisc-linux.org
Cc: rkuo@codeaurora.org
Cc: vgupta@synopsys.com
Link: http://lkml.kernel.org/r/20170609110506.yod47flaav3wgoj5@hirez.programming.kicks-ass.net


Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 35a2897c
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -123,6 +123,8 @@ static inline void atomic_set(atomic_t *v, int i)
	atomic_ops_unlock(flags);
}

#define atomic_set_release(v, i)	atomic_set((v), (i))

#endif

/*
+2 −0
Original line number Diff line number Diff line
@@ -42,6 +42,8 @@ static inline void atomic_set(atomic_t *v, int new)
	);
}

#define atomic_set_release(v, i)	atomic_set((v), (i))

/**
 * atomic_read - reads a word, atomically
 * @v: pointer to atomic value
+2 −0
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@ static inline int atomic_set(atomic_t *v, int i)
	return i;
}

#define atomic_set_release(v, i) atomic_set((v), (i))

#define ATOMIC_OP(op, c_op)						\
static inline void atomic_##op(int i, atomic_t *v)			\
{									\
+2 −0
Original line number Diff line number Diff line
@@ -65,6 +65,8 @@ static __inline__ void atomic_set(atomic_t *v, int i)
	_atomic_spin_unlock_irqrestore(v, flags);
}

#define atomic_set_release(v, i)	atomic_set((v), (i))

static __inline__ int atomic_read(const atomic_t *v)
{
	return READ_ONCE((v)->counter);
+2 −0
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@ int atomic_xchg(atomic_t *, int);
int __atomic_add_unless(atomic_t *, int, int);
void atomic_set(atomic_t *, int);

#define atomic_set_release(v, i)	atomic_set((v), (i))

#define atomic_read(v)          ACCESS_ONCE((v)->counter)

#define atomic_add(i, v)	((void)atomic_add_return( (int)(i), (v)))
Loading