• Will Deacon's avatar
    ARM: 7955/1: spinlock: ensure we have a compiler barrier before sev · 7c8746a9
    Will Deacon authored
    When unlocking a spinlock, we require the following, strictly ordered
    sequence of events:
    
    	<barrier>	/* dmb */
    	<unlock>
    	<barrier>	/* dsb */
    	<sev>
    
    Whilst the code does indeed reflect this in terms of the architecture,
    the final <barrier> + <sev> have been contracted into a single inline
    asm without a "memory" clobber, therefore the compiler is at liberty to
    reorder the unlock to the end of the above sequence. In such a case,
    a waiting CPU may be woken up before the lock has been unlocked, leading
    to extremely poor performance.
    
    This patch reworks the dsb_sev() function to make use of the dsb()
    macro and ensure ordering against the unlock.
    
    Cc: <stable@vger.kernel.org>
    Reported-by: default avatarMark Rutland <mark.rutland@arm.com>
    Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
    Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
    7c8746a9
spinlock.h 6.06 KB