1/* 2 * (C) Copyright 2025 Rockchip Electronics Co., Ltd. 3 * 4 * SPDX-License-Identifier: GPL-2.0+ 5 */ 6 7#include <asm/macro.h> 8#include <asm-offsets.h> 9#include <config.h> 10#include <linux/linkage.h> 11 12 .globl __spin_lock 13 .globl __spin_unlock 14 15/* 16 * Acquire lock using load-/store-exclusive instruction pair. 17 * 18 * void __spin_lock(spinlock_t *lock); 19 */ 20ENTRY(__spin_lock) 21 mov w2, #1 22 sevl 23l1: wfe 24l2: ldaxr w1, [x0] 25 cbnz w1, l1 26 stxr w1, w2, [x0] 27 cbnz w1, l2 28 ret 29ENDPROC(__spin_lock) 30 31/* 32 * Release lock previously acquired by __spin_lock. 33 * 34 * Use store-release to unconditionally clear the spinlock variable. 35 * Store operation generates an event to all cores waiting in WFE 36 * when address is monitored by the global monitor. 37 * 38 * void __spin_unlock(spinlock_t *lock); 39 */ 40ENTRY(__spin_unlock) 41 stlr wzr, [x0] 42 ret 43ENDPROC(__spin_unlock) 44