diff options
author | Jett Rink <jettrink@chromium.org> | 2019-01-08 10:22:09 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2019-01-09 01:50:37 +0000 |
commit | eb9e5a0061236c08460f8c285cca748ff3ae548a (patch) | |
tree | 5e5aff324b20f90c3c4ed3e81061aeb0a3059be8 | |
parent | 2f16a6245009215ca342a478576a7e5f6a857b9a (diff) | |
download | chrome-ec-eb9e5a0061236c08460f8c285cca748ff3ae548a.tar.gz |
ish: remove lock; prefix from inline ASMstabilize-atlas-11177.B
Since all instances of minute-ia core are a single core, the
lock; prefix on statements does not have any meaningful affect
other than a potential performance hit.
We still want to mark inline asm where it would matter, so we
introduce a new define that evaluates to empty today.
BRANCH=atlas_ish
BUG=none
TEST=builds
Change-Id: I47506951dfdabfdbd16ae825fe742b01b44205d1
Signed-off-by: Jett Rink <jettrink@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1401014
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
(cherry picked from commit 7ced9b2e02cdb49b78384ecb93978c1bab5cd015)
Reviewed-on: https://chromium-review.googlesource.com/c/1401808
Reviewed-by: Caveh Jalali <caveh@google.com>
Commit-Queue: Caveh Jalali <caveh@google.com>
Tested-by: Caveh Jalali <caveh@google.com>
-rw-r--r-- | core/minute-ia/atomic.h | 6 | ||||
-rw-r--r-- | core/minute-ia/config_core.h | 14 | ||||
-rw-r--r-- | core/minute-ia/task.c | 4 |
3 files changed, 19 insertions, 5 deletions
diff --git a/core/minute-ia/atomic.h b/core/minute-ia/atomic.h index 08f0888cdf..00dce90607 100644 --- a/core/minute-ia/atomic.h +++ b/core/minute-ia/atomic.h @@ -13,7 +13,7 @@ #define ATOMIC_OP(asm_op, a, v) do { \ __asm__ __volatile__ ( \ - "lock;" #asm_op " %1, %0\n" \ + ASM_LOCK_PREFIX #asm_op " %1, %0\n" \ : "+m" (*a) \ : "ir" (v) \ : "memory"); \ @@ -24,7 +24,7 @@ static inline int bool_compare_and_swap_u32(uint32_t *var, uint32_t old_value, { uint32_t _old_value = old_value; - __asm__ __volatile__("lock; cmpxchgl %2, %1" + __asm__ __volatile__(ASM_LOCK_PREFIX "cmpxchgl %2, %1" : "=a" (old_value), "+m" (*var) : "r" (new_value), "0" (old_value) : "memory"); @@ -74,7 +74,7 @@ static inline uint32_t atomic_read_clear(uint32_t volatile *addr) if (*addr == 0) return 0; - asm volatile("lock; xchgl %0, %1\n" + asm volatile(ASM_LOCK_PREFIX "xchgl %0, %1\n" : "+r" (ret), "+m" (*addr) : : "memory", "cc"); diff --git a/core/minute-ia/config_core.h b/core/minute-ia/config_core.h index 3ca60cf71d..426e215eae 100644 --- a/core/minute-ia/config_core.h +++ b/core/minute-ia/config_core.h @@ -12,4 +12,18 @@ #define CONFIG_SOFTWARE_PANIC +/* + * Since all implementations minute-ia are a single core, we do not need a + * "lock;" prefix on any instructions. We use the below define in places where + * a lock statement would be needed if there were multiple cores. + * + * Also the destination operand needs to be a memory location instead of a + * register for us to drop the "lock;" prefix for a single-core chip. + */ +#ifndef __ASSEMBLER__ +#define ASM_LOCK_PREFIX "" +#else +#define ASM_LOCK_PREFIX +#endif + #endif /* __CROS_EC_CONFIG_CORE_H */ diff --git a/core/minute-ia/task.c b/core/minute-ia/task.c index 16bb724c2d..77c429c288 100644 --- a/core/minute-ia/task.c +++ b/core/minute-ia/task.c @@ -433,7 +433,7 @@ void mutex_lock(struct mutex *mtx) do { old_val = 0; __asm__ __volatile__( - "lock; cmpxchg %1, %2\n" + ASM_LOCK_PREFIX "cmpxchg %1, %2\n" : "=a" (old_val) : "r" (value), "m" (mtx->lock), "a" (old_val) : "memory"); @@ -454,7 +454,7 @@ void mutex_unlock(struct mutex *mtx) task_ *tsk = current_task; __asm__ __volatile__( - "lock; cmpxchg %1, %2\n" + ASM_LOCK_PREFIX "cmpxchg %1, %2\n" : "=a" (old_val) : "r" (val), "m" (mtx->lock), "a" (old_val) : "memory"); |