xtensa: save/restore scompare1 during context switch

Xtensa uses two instructions to perform atomic compare-and-set
instruction: first the comparison register, then the actual
instruction to do compare-and-set. There is a potential that
context switching is performed before these two instructions.
A restored context may have the wrong value in the comparison
register. So we need to save and restore the comparison
register during context switching.

Fixes #21800

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
Daniel Leung 2020-02-12 00:48:19 -08:00 committed by Johan Hedberg
commit bf50aae693
3 changed files with 30 additions and 2 deletions

View file

@ -110,6 +110,10 @@
rsr.LCOUNT a0
s32i a0, a1, BSA_LCOUNT_OFF
#endif
#if XCHAL_HAVE_S32C1I
rsr.SCOMPARE1 a0
s32i a0, a1, BSA_SCOMPARE1_OFF
#endif
.endm
/*