Link: https://lore.kernel.org/r/20260217200002.683975158@linuxfoundation.org Tested-by: Florian Fainelli <florian.fainelli@broadcom.com> Tested-by: Takeshi Ogasawara <takeshi.ogasawara@futuring-girl.com> Tested-by: Peter Schneider <pschneider1968@googlemail.com> Tested-by: Jon Hunter <jonathanh@nvidia.com> Tested-by: Salvatore Bonaccorso <carnil@debian.org> Tested-by: Brett A C Sheffield <bacs@librecast.net> Tested-by: Mark Brown <broonie@kernel.org> Tested-by: Luna Jernberg <droidbittin@gmail.com> Tested-by: Ronald Warsow <rwarsow@gmx.de> Tested-by: Justin M. Forbes <jforbes@fedoraproject.org> Tested-by: Ron Economos <re@w6rz.net> Tested-by: Miguel Ojeda <ojeda@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
42 lines
834 B
C
42 lines
834 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _ASM_LOONGARCH_QSPINLOCK_H
|
|
#define _ASM_LOONGARCH_QSPINLOCK_H
|
|
|
|
#include <linux/jump_label.h>
|
|
|
|
#ifdef CONFIG_PARAVIRT
|
|
|
|
DECLARE_STATIC_KEY_FALSE(virt_spin_lock_key);
|
|
|
|
#define virt_spin_lock virt_spin_lock
|
|
|
|
static inline bool virt_spin_lock(struct qspinlock *lock)
|
|
{
|
|
int val;
|
|
|
|
if (!static_branch_unlikely(&virt_spin_lock_key))
|
|
return false;
|
|
|
|
/*
|
|
* On hypervisors without PARAVIRT_SPINLOCKS support we fall
|
|
* back to a Test-and-Set spinlock, because fair locks have
|
|
* horrible lock 'holder' preemption issues.
|
|
*/
|
|
|
|
__retry:
|
|
val = atomic_read(&lock->val);
|
|
|
|
if (val || !atomic_try_cmpxchg(&lock->val, &val, _Q_LOCKED_VAL)) {
|
|
cpu_relax();
|
|
goto __retry;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
#endif /* CONFIG_PARAVIRT */
|
|
|
|
#include <asm-generic/qspinlock.h>
|
|
|
|
#endif // _ASM_LOONGARCH_QSPINLOCK_H
|