diff mbox

[v3,6/9] linux-generic: odp_ticketlock.c use odp_atomic.h and __atomic

Message ID 1416868730-26140-7-git-send-email-ola.liljedahl@linaro.org
State Accepted
Commit 2d4943a4713bdab5a2ec2096cd09b9791fe2cd0c
Headers show

Commit Message

Ola Liljedahl Nov. 24, 2014, 10:38 p.m. UTC
Signed-off-by: Ola Liljedahl <ola.liljedahl@linaro.org>
---
Updated to use odp_atomic.h functions. Updated to use GCC __atomic barriers
(temporary fix). Added missing barrier in odp_ticketlock_lock().

 platform/linux-generic/odp_ticketlock.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/platform/linux-generic/odp_ticketlock.c b/platform/linux-generic/odp_ticketlock.c
index be5b885..096bdc0 100644
--- a/platform/linux-generic/odp_ticketlock.c
+++ b/platform/linux-generic/odp_ticketlock.c
@@ -27,25 +27,24 @@  void odp_ticketlock_lock(odp_ticketlock_t *ticketlock)
 	while (ticket != ticketlock->cur_ticket)
 		odp_spin();
 
-	odp_mem_barrier();
+	__atomic_thread_fence(__ATOMIC_ACQUIRE);
 }
 
 
 void odp_ticketlock_unlock(odp_ticketlock_t *ticketlock)
 {
-	odp_sync_stores();
+	__atomic_thread_fence(__ATOMIC_RELEASE);
 
 	ticketlock->cur_ticket++;
 
 #if defined __OCTEON__
-	odp_sync_stores();
-#else
-	odp_mem_barrier();
+	odp_sync_stores(); /* SYNCW to flush write buffer */
 #endif
 }
 
 
 int odp_ticketlock_is_locked(odp_ticketlock_t *ticketlock)
 {
-	return ticketlock->cur_ticket != ticketlock->next_ticket;
+	return ticketlock->cur_ticket !=
+		odp_atomic_load_u32(&ticketlock->next_ticket);
 }