xen: arm: retry trylock if strex fails on free lock.
authorIan Campbell <ian.campbell@citrix.com>
Fri, 19 Jul 2013 15:20:10 +0000 (16:20 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 22 Aug 2013 14:48:13 +0000 (15:48 +0100)
commit08d89ac8bd7f43d897cdffe85b236c71d3408e16
treec5fc91ab77714fadb6c7567f584532d345829bf2
parentc85c3e3cb9c0540cb604c379298bfd885ade1592
xen: arm: retry trylock if strex fails on free lock.

This comes from the Linux patches 15e7e5c1ebf5 for arm32 and 4ecf7ccb1973 for
arm64 by Will Deacon and Catalin Marinas respectively. The Linux commit message
says:

    An exclusive store instruction may fail for reasons other than lock
    contention (e.g. a cache eviction during the critical section) so, in
    line with other architectures using similar exclusive instructions
    (alpha, mips, powerpc), retry the trylock operation if the lock appears
    to be free but the strex reported failure.

I have observed this due to register_cpu_notifier containing:
    if ( !spin_trylock(&cpu_add_remove_lock) )
        BUG(); /* Should never fail as we are called only during boot. */
which was spuriously failing.

The ARMv8 variant is taken directly from the Linux patch. For v7 I had to
reimplement since we don't currently use ticket locks.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
xen/include/asm-arm/arm32/spinlock.h
xen/include/asm-arm/arm64/spinlock.h