kernel: add functions to lock/unlock a pair of locks without saving irq flags

This commit is contained in:
2026-03-14 22:25:15 +00:00
parent 115a2e7415
commit 62bdb51618
2 changed files with 38 additions and 18 deletions

View File

@@ -22,6 +22,32 @@ typedef __aligned(8) ml_hwlock_t spin_lock_t;
#define spin_unlock_irqrestore(lck, flags) \
ml_hwlock_unlock_irqrestore(lck, flags);
static inline void spin_lock_pair(spin_lock_t *a, spin_lock_t *b)
{
if (a == b) {
spin_lock(a);
} else if (a < b) {
spin_lock(a);
spin_lock(b);
} else {
spin_lock(b);
spin_lock(a);
}
}
static inline void spin_unlock_pair(spin_lock_t *a, spin_lock_t *b)
{
if (a == b) {
spin_unlock(a);
} else if (a < b) {
spin_unlock(b);
spin_unlock(a);
} else {
spin_unlock(a);
spin_unlock(b);
}
}
static inline void spin_lock_pair_irqsave(
spin_lock_t *a,
spin_lock_t *b,