diff options
author | Achin Gupta <achin.gupta@arm.com> | 2015-09-14 21:49:10 +0100 |
---|---|---|
committer | Achin Gupta <achin.gupta@arm.com> | 2015-09-14 21:49:10 +0100 |
commit | 7dc28e9c6e577c5151d0a6df7165f7d21f509f5f (patch) | |
tree | 7b8ca90411e2c16b3334cdb92beb7e72683d1707 /include/lib | |
parent | 84e1903689764718d6c79300a3ce1f764a6f468c (diff) | |
parent | c3ec0b9ea4274120c6e82d86ccc427f13f65fa59 (diff) |
Merge pull request #390 from vikramkanigiri/at/unify_bakery_locks_v2
Re-design bakery lock allocation and algorithm
Diffstat (limited to 'include/lib')
-rw-r--r-- | include/lib/bakery_lock.h | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/include/lib/bakery_lock.h b/include/lib/bakery_lock.h index 2e1afa21..86adb9cb 100644 --- a/include/lib/bakery_lock.h +++ b/include/lib/bakery_lock.h @@ -56,6 +56,11 @@ * External bakery lock interface. ****************************************************************************/ #if USE_COHERENT_MEM +/* + * Bakery locks are stored in coherent memory + * + * Each lock's data is contiguous and fully allocated by the compiler + */ typedef struct bakery_lock { /* @@ -67,12 +72,15 @@ typedef struct bakery_lock { volatile uint16_t lock_data[BAKERY_LOCK_MAX_CPUS]; } bakery_lock_t; -void bakery_lock_init(bakery_lock_t *bakery); -void bakery_lock_get(bakery_lock_t *bakery); -void bakery_lock_release(bakery_lock_t *bakery); -int bakery_lock_try(bakery_lock_t *bakery); - #else +/* + * Bakery locks are stored in normal .bss memory + * + * Each lock's data is spread across multiple cache lines, one per CPU, + * but multiple locks can share the same cache line. + * The compiler will allocate enough memory for one CPU's bakery locks, + * the remaining cache lines are allocated by the linker script + */ typedef struct bakery_info { /* @@ -84,9 +92,19 @@ typedef struct bakery_info { volatile uint16_t lock_data; } bakery_info_t; -void bakery_lock_get(unsigned int id, unsigned int offset); -void bakery_lock_release(unsigned int id, unsigned int offset); +typedef bakery_info_t bakery_lock_t; #endif /* __USE_COHERENT_MEM__ */ + +inline void bakery_lock_init(bakery_lock_t *bakery) {} +void bakery_lock_get(bakery_lock_t *bakery); +void bakery_lock_release(bakery_lock_t *bakery); + +#define DEFINE_BAKERY_LOCK(_name) bakery_lock_t _name \ + __attribute__ ((section("bakery_lock"))) + +#define DECLARE_BAKERY_LOCK(_name) extern bakery_lock_t _name + + #endif /* __ASSEMBLY__ */ #endif /* __BAKERY_LOCK_H__ */ |