Commit d439cea9 authored by Varun Wadekar's avatar Varun Wadekar
Browse files

locks: bakery: add a DMB to the 'read_cache_op' macro



ARM has a weak memory ordering model. This means that without
explicit barriers, memory accesses can be observed differently
than program order. In this case, the cache invalidate instruction
can be observed after the subsequent read to address.

To solve this, a DMB instruction is required between the cache
invalidate and the read. This ensures that the cache invalidate
completes before all memory accesses in program order after the DMB.

This patch updates the 'read_cache_op' macro to issue a DMB after
the cache invalidate instruction to fix this anomaly.

Change-Id: Iac9a90d228c57ba8bcdca7e409ea6719546ab441
Signed-off-by: default avatarVarun Wadekar <vwadekar@nvidia.com>
parent 03ea84c3
/*
* Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2020, NVIDIA Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
......@@ -77,6 +78,8 @@ static inline void read_cache_op(uintptr_t addr, bool cached)
{
if (cached)
dccivac(addr);
dmbish();
}
/* Helper function to check if the lock is acquired */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment