__xchg for sizes other than 32bit

Jamie Lokier jamie at shareable.org
Wed Mar 10 18:16:26 EST 2010


Russell King - ARM Linux wrote:
> On Wed, Mar 10, 2010 at 06:22:21PM +0200, Imre Deak wrote:
> > recently you've added support for __cmpxchg for ARMv6+. There the assumption
> > is that ldrex[bh]/strex[bh] is only supported on platforms with the 32v6K
> > extension.
> > 
> > Currently the __xchg code uses these even without the extension. Should this
> > be fixed?
> 
> >From what I remember, the half-word versions definitely aren't supported
> on anything without V6K extensions.  I think that the byte and word
> versions are supported on V6 and up though.
> 
> That'd make both __cmpxchg and __xchg slightly buggy, in different ways.
> 
> What it does mean is that atomic operations on unsigned shorts using
> ldrex/strex will only be possible on V6K and up.

It's possible to emulate 16-bit cmpxchg using 32-bit cmpxchg.

xchg can't be emulated with wider xchg, but of course it can use wider
cmpxchg in a loop.

That sort of thing probably should be in asm-generic somewhere.

-- Jamie



More information about the linux-arm-kernel mailing list