From 580dd051eacfdde49ae9bc3214afc989f3c519b5 Mon Sep 17 00:00:00 2001 From: David Gwynne Date: Wed, 11 Feb 2015 03:56:01 +0000 Subject: the only user of __cpu_cas is lock_machdep, so move it there. machine/lock.h only provides SPINLOCK_SPIN_HOOK which is included directly by the three files that use it. --- sys/arch/alpha/alpha/lock_machdep.c | 43 +++++++++++++++++++++++++++---------- sys/arch/alpha/include/lock.h | 25 +-------------------- 2 files changed, 33 insertions(+), 35 deletions(-) diff --git a/sys/arch/alpha/alpha/lock_machdep.c b/sys/arch/alpha/alpha/lock_machdep.c index 91be2bb6970..36cd7dab6ee 100644 --- a/sys/arch/alpha/alpha/lock_machdep.c +++ b/sys/arch/alpha/alpha/lock_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lock_machdep.c,v 1.2 2015/02/11 01:10:48 dlg Exp $ */ +/* $OpenBSD: lock_machdep.c,v 1.3 2015/02/11 03:56:00 dlg Exp $ */ /* * Copyright (c) 2007 Artur Grabowski @@ -18,31 +18,52 @@ #include -#include #include #include #include #include -#include - -void -__mp_lock_init(struct __mp_lock *lock) -{ - lock->mpl_cpu = NULL; - lock->mpl_count = 0; -} - #if defined(MP_LOCKDEBUG) #ifndef DDB #error "MP_LOCKDEBUG requires DDB" #endif +#include /* CPU-dependent timing, needs this to be settable from ddb. */ extern int __mp_lock_spinout; #endif +static inline int +__cpu_cas(volatile unsigned long *addr, unsigned long old, unsigned long new) +{ + unsigned long t0, v0; + + __asm volatile( + "1: ldq_l %1, 0(%2) \n" /* v0 = *addr */ + " cmpeq %1, %3, %0 \n" /* t0 = v0 == old */ + " beq %0, 2f \n" + " mov %4, %0 \n" /* t0 = new */ + " stq_c %0, 0(%2) \n" /* *addr = new */ + " beq %0, 3f \n" + " mb \n" + "2: br 4f \n" + "3: br 1b \n" /* update failed */ + "4: \n" + : "=&r" (t0), "=&r" (v0) + : "r" (addr), "r" (old), "r" (new) + : "memory"); + + return (v0 != old); +} + +void +__mp_lock_init(struct __mp_lock *lock) +{ + lock->mpl_cpu = NULL; + lock->mpl_count = 0; +} + static inline void __mp_lock_spin(struct __mp_lock *mpl) { diff --git a/sys/arch/alpha/include/lock.h b/sys/arch/alpha/include/lock.h index e40761990d2..3ef8a5cb550 100644 --- a/sys/arch/alpha/include/lock.h +++ b/sys/arch/alpha/include/lock.h @@ -1,4 +1,4 @@ -/* $OpenBSD: lock.h,v 1.8 2015/02/11 00:14:11 dlg Exp $ */ +/* $OpenBSD: lock.h,v 1.9 2015/02/11 03:56:00 dlg Exp $ */ /* $NetBSD: lock.h,v 1.16 2001/12/17 23:34:57 thorpej Exp $ */ /*- @@ -61,27 +61,4 @@ do { \ } while (0) #endif /* MULTIPROCESSOR */ -static inline int -__cpu_cas(volatile unsigned long *addr, unsigned long old, unsigned long new) -{ - unsigned long t0, v0; - - __asm volatile( - "1: ldq_l %1, 0(%2) \n" /* v0 = *addr */ - " cmpeq %1, %3, %0 \n" /* t0 = v0 == old */ - " beq %0, 2f \n" - " mov %4, %0 \n" /* t0 = new */ - " stq_c %0, 0(%2) \n" /* *addr = new */ - " beq %0, 3f \n" - " mb \n" - "2: br 4f \n" - "3: br 1b \n" /* update failed */ - "4: \n" - : "=&r" (t0), "=&r" (v0) - : "r" (addr), "r" (old), "r" (new) - : "memory"); - - return (v0 != old); -} - #endif /* _MACHINE_LOCK_H_ */ -- cgit v1.2.3