aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDimitris Papastamos <dimitris.papastamos@arm.com>2018-09-05 15:42:15 +0100
committerGitHub <noreply@github.com>2018-09-05 15:42:15 +0100
commit783fd8e00f7a58462891ff16fa3f10f635df7a12 (patch)
tree2bb6bff9d831d0e67a870113b0dc6f44e809979b /lib
parent42dc33106996c4a5849d405c3e54964a7231d272 (diff)
parent24dc97091532751ea810e99bd5a9be33514decf6 (diff)
downloadplatform_external_arm-trusted-firmware-783fd8e00f7a58462891ff16fa3f10f635df7a12.tar.gz
platform_external_arm-trusted-firmware-783fd8e00f7a58462891ff16fa3f10f635df7a12.tar.bz2
platform_external_arm-trusted-firmware-783fd8e00f7a58462891ff16fa3f10f635df7a12.zip
Merge pull request #1561 from jeenu-arm/bakery-barrier
Add missing barriers to Bakery Locks
Diffstat (limited to 'lib')
-rw-r--r--lib/locks/bakery/bakery_lock_coherent.c15
-rw-r--r--lib/locks/bakery/bakery_lock_normal.c13
2 files changed, 23 insertions, 5 deletions
diff --git a/lib/locks/bakery/bakery_lock_coherent.c b/lib/locks/bakery/bakery_lock_coherent.c
index 788ba9818..03277c32f 100644
--- a/lib/locks/bakery/bakery_lock_coherent.c
+++ b/lib/locks/bakery/bakery_lock_coherent.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2015, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -133,7 +133,12 @@ void bakery_lock_get(bakery_lock_t *bakery)
bakery_ticket_number(bakery->lock_data[they]));
}
}
- /* Lock acquired */
+
+ /*
+ * Lock acquired. Ensure that any reads from a shared resource in the
+ * critical section read values after the lock is acquired.
+ */
+ dmbld();
}
@@ -146,9 +151,11 @@ void bakery_lock_release(bakery_lock_t *bakery)
assert(bakery_ticket_number(bakery->lock_data[me]));
/*
- * Release lock by resetting ticket. Then signal other
- * waiting contenders
+ * Ensure that other observers see any stores in the critical section
+ * before releasing the lock. Release the lock by resetting ticket.
+ * Then signal other waiting contenders.
*/
+ dmbst();
bakery->lock_data[me] = 0;
dsb();
sev();
diff --git a/lib/locks/bakery/bakery_lock_normal.c b/lib/locks/bakery/bakery_lock_normal.c
index 630226ae2..b947da9c7 100644
--- a/lib/locks/bakery/bakery_lock_normal.c
+++ b/lib/locks/bakery/bakery_lock_normal.c
@@ -204,7 +204,12 @@ void bakery_lock_get(bakery_lock_t *lock)
== bakery_ticket_number(their_bakery_info->lock_data));
}
}
- /* Lock acquired */
+
+ /*
+ * Lock acquired. Ensure that any reads from a shared resource in the
+ * critical section read values after the lock is acquired.
+ */
+ dmbld();
}
void bakery_lock_release(bakery_lock_t *lock)
@@ -220,6 +225,12 @@ void bakery_lock_release(bakery_lock_t *lock)
assert(is_lock_acquired(my_bakery_info, is_cached));
+ /*
+ * Ensure that other observers see any stores in the critical section
+ * before releasing the lock. Release the lock by resetting ticket.
+ * Then signal other waiting contenders.
+ */
+ dmbst();
my_bakery_info->lock_data = 0;
write_cache_op(my_bakery_info, is_cached);
sev();