Improve atomic memory access and support -mno-atomic.

Use CONFIG_GENERIC_ATOMIC64 if 32-bit.  Add system call to emulate
atomic compare exchange, primarily for targets lacking hardware
support (i.e., lacking RV32A, RV64A).  Support excluding use of
atomic memory instructions (-mno-atomic).

This change is mutually dependent on the corresponding change to
riscv-gcc.
On 08/16/2014 02:02 AM, Albert Ou wrote:
> In arch/riscv/include/asm/cmpxchg.h:
> 
>> +
>> +static inline unsigned long __cmpxchg_local(volatile void *ptr,
>> +                unsigned long old, unsigned long new, int size)
>> +{
>> +	register unsigned long flags, prev;
>> +
>> +	/*
>> +	 * Sanity checking, compile-time.
>> +	 */
>> +	BUILD_BUG_ON(size == 8 && sizeof(unsigned long) != 8);
>> +
>> +	switch (size) {
>> +	case 4:
>> +	__asm__ __volatile__ (
>> +	"0:"
>> +                "csrrc %1,status,4\n"
> 
> The hard-coded immediate can be replaced with |"i" (SR_EI)| as an input
> operand, after including |<asm/csr.h>|.
> 

Ok.  Although this becomes a non-issue if <asm-generic/cmpxchg-local.h>
is used.

// darius