Drivers: hv: vmbus: Move the crash notification function
[linux-2.6/btrfs-unstable.git] / arch / x86 / include / asm / qspinlock.h
blobc343ab52579ff87faa26b5e363995076ebca2cb0
1 #ifndef _ASM_X86_QSPINLOCK_H
2 #define _ASM_X86_QSPINLOCK_H
4 #include <asm/cpufeature.h>
5 #include <asm-generic/qspinlock_types.h>
6 #include <asm/paravirt.h>
8 #define queued_spin_unlock queued_spin_unlock
9 /**
10 * queued_spin_unlock - release a queued spinlock
11 * @lock : Pointer to queued spinlock structure
13 * A smp_store_release() on the least-significant byte.
15 static inline void native_queued_spin_unlock(struct qspinlock *lock)
17 smp_store_release((u8 *)lock, 0);
20 #ifdef CONFIG_PARAVIRT_SPINLOCKS
21 extern void native_queued_spin_lock_slowpath(struct qspinlock *lock, u32 val);
22 extern void __pv_init_lock_hash(void);
23 extern void __pv_queued_spin_lock_slowpath(struct qspinlock *lock, u32 val);
24 extern void __raw_callee_save___pv_queued_spin_unlock(struct qspinlock *lock);
26 static inline void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val)
28 pv_queued_spin_lock_slowpath(lock, val);
31 static inline void queued_spin_unlock(struct qspinlock *lock)
33 pv_queued_spin_unlock(lock);
36 #define vcpu_is_preempted vcpu_is_preempted
37 static inline bool vcpu_is_preempted(int cpu)
39 return pv_vcpu_is_preempted(cpu);
41 #else
42 static inline void queued_spin_unlock(struct qspinlock *lock)
44 native_queued_spin_unlock(lock);
46 #endif
48 #ifdef CONFIG_PARAVIRT
49 #define virt_spin_lock virt_spin_lock
50 static inline bool virt_spin_lock(struct qspinlock *lock)
52 if (!static_cpu_has(X86_FEATURE_HYPERVISOR))
53 return false;
56 * On hypervisors without PARAVIRT_SPINLOCKS support we fall
57 * back to a Test-and-Set spinlock, because fair locks have
58 * horrible lock 'holder' preemption issues.
61 do {
62 while (atomic_read(&lock->val) != 0)
63 cpu_relax();
64 } while (atomic_cmpxchg(&lock->val, 0, _Q_LOCKED_VAL) != 0);
66 return true;
68 #endif /* CONFIG_PARAVIRT */
70 #include <asm-generic/qspinlock.h>
72 #endif /* _ASM_X86_QSPINLOCK_H */