2015-04-25 02:56:31 +08:00
|
|
|
#ifndef _ASM_X86_QSPINLOCK_H
|
|
|
|
#define _ASM_X86_QSPINLOCK_H
|
|
|
|
|
2015-04-25 02:56:36 +08:00
|
|
|
#include <asm/cpufeature.h>
|
2015-04-25 02:56:31 +08:00
|
|
|
#include <asm-generic/qspinlock_types.h>
|
2015-04-25 02:56:38 +08:00
|
|
|
#include <asm/paravirt.h>
|
2015-04-25 02:56:31 +08:00
|
|
|
|
|
|
|
#define queued_spin_unlock queued_spin_unlock
|
|
|
|
/**
|
|
|
|
* queued_spin_unlock - release a queued spinlock
|
|
|
|
* @lock : Pointer to queued spinlock structure
|
|
|
|
*
|
|
|
|
* A smp_store_release() on the least-significant byte.
|
|
|
|
*/
|
2015-04-25 02:56:38 +08:00
|
|
|
static inline void native_queued_spin_unlock(struct qspinlock *lock)
|
2015-04-25 02:56:31 +08:00
|
|
|
{
|
|
|
|
smp_store_release((u8 *)lock, 0);
|
|
|
|
}
|
|
|
|
|
2015-04-25 02:56:38 +08:00
|
|
|
#ifdef CONFIG_PARAVIRT_SPINLOCKS
|
|
|
|
extern void native_queued_spin_lock_slowpath(struct qspinlock *lock, u32 val);
|
|
|
|
extern void __pv_init_lock_hash(void);
|
|
|
|
extern void __pv_queued_spin_lock_slowpath(struct qspinlock *lock, u32 val);
|
|
|
|
extern void __raw_callee_save___pv_queued_spin_unlock(struct qspinlock *lock);
|
|
|
|
|
|
|
|
static inline void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val)
|
|
|
|
{
|
|
|
|
pv_queued_spin_lock_slowpath(lock, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void queued_spin_unlock(struct qspinlock *lock)
|
|
|
|
{
|
|
|
|
pv_queued_spin_unlock(lock);
|
|
|
|
}
|
2016-11-15 23:47:06 +08:00
|
|
|
|
|
|
|
#define vcpu_is_preempted vcpu_is_preempted
|
|
|
|
static inline bool vcpu_is_preempted(int cpu)
|
|
|
|
{
|
|
|
|
return pv_vcpu_is_preempted(cpu);
|
|
|
|
}
|
2015-04-25 02:56:38 +08:00
|
|
|
#else
|
|
|
|
static inline void queued_spin_unlock(struct qspinlock *lock)
|
|
|
|
{
|
|
|
|
native_queued_spin_unlock(lock);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-09-05 22:55:05 +08:00
|
|
|
#ifdef CONFIG_PARAVIRT
|
2015-09-04 23:25:23 +08:00
|
|
|
#define virt_spin_lock virt_spin_lock
|
|
|
|
static inline bool virt_spin_lock(struct qspinlock *lock)
|
2015-04-25 02:56:36 +08:00
|
|
|
{
|
|
|
|
if (!static_cpu_has(X86_FEATURE_HYPERVISOR))
|
|
|
|
return false;
|
|
|
|
|
2015-09-04 23:25:23 +08:00
|
|
|
/*
|
|
|
|
* On hypervisors without PARAVIRT_SPINLOCKS support we fall
|
|
|
|
* back to a Test-and-Set spinlock, because fair locks have
|
|
|
|
* horrible lock 'holder' preemption issues.
|
|
|
|
*/
|
|
|
|
|
|
|
|
do {
|
|
|
|
while (atomic_read(&lock->val) != 0)
|
|
|
|
cpu_relax();
|
|
|
|
} while (atomic_cmpxchg(&lock->val, 0, _Q_LOCKED_VAL) != 0);
|
2015-04-25 02:56:36 +08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2015-09-05 22:55:05 +08:00
|
|
|
#endif /* CONFIG_PARAVIRT */
|
2015-04-25 02:56:36 +08:00
|
|
|
|
2015-04-25 02:56:31 +08:00
|
|
|
#include <asm-generic/qspinlock.h>
|
|
|
|
|
|
|
|
#endif /* _ASM_X86_QSPINLOCK_H */
|