/*
- * 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
*/
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();
}
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();
== 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)
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();