diff options
author | Soby Mathew <soby.mathew@arm.com> | 2015-01-08 18:02:19 +0000 |
---|---|---|
committer | Dan Handley <dan.handley@arm.com> | 2015-01-22 10:57:44 +0000 |
commit | 8c5fe0b5b9f1666b4ddd8f5849de80249cdebe40 (patch) | |
tree | e2528b93b735f00ae31d81680dd8c3a14b4c0f0c /include/lib | |
parent | 5b1cd43bc1b69b8a6df251b9e54591f2405f5e0c (diff) | |
download | platform_external_arm-trusted-firmware-8c5fe0b5b9f1666b4ddd8f5849de80249cdebe40.tar.gz platform_external_arm-trusted-firmware-8c5fe0b5b9f1666b4ddd8f5849de80249cdebe40.tar.bz2 platform_external_arm-trusted-firmware-8c5fe0b5b9f1666b4ddd8f5849de80249cdebe40.zip |
Move bakery algorithm implementation out of coherent memory
This patch moves the bakery locks out of coherent memory to normal memory.
This implies that the lock information needs to be placed on a separate cache
line for each cpu. Hence the bakery_lock_info_t structure is allocated in the
per-cpu data so as to minimize memory wastage. A similar platform per-cpu
data is introduced for the platform locks.
As a result of the above changes, the bakery lock api is completely changed.
Earlier, a reference to the lock structure was passed to the lock implementation.
Now a unique-id (essentially an index into the per-cpu data array) and an offset
into the per-cpu data for bakery_info_t needs to be passed to the lock
implementation.
Change-Id: I1e76216277448713c6c98b4c2de4fb54198b39e0
Diffstat (limited to 'include/lib')
-rw-r--r-- | include/lib/bakery_lock.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/include/lib/bakery_lock.h b/include/lib/bakery_lock.h index 95634cf54..9736f850a 100644 --- a/include/lib/bakery_lock.h +++ b/include/lib/bakery_lock.h @@ -35,6 +35,11 @@ #define BAKERY_LOCK_MAX_CPUS PLATFORM_CORE_COUNT +#ifndef __ASSEMBLY__ +#include <stdint.h> + +#if USE_COHERENT_MEM + typedef struct bakery_lock { int owner; volatile char entering[BAKERY_LOCK_MAX_CPUS]; @@ -48,4 +53,21 @@ 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 + +typedef struct bakery_info { + /* + * The lock_data is a bit-field of 2 members: + * Bit[0] : choosing. This field is set when the CPU is + * choosing its bakery number. + * Bits[1 - 15] : number. This is the bakery number allocated. + */ + 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); + +#endif /* __USE_COHERENT_MEM__ */ +#endif /* __ASSEMBLY__ */ #endif /* __BAKERY_LOCK_H__ */ |