kernel: add functions to lock/unlock a pair of locks without saving irq flags
This commit is contained in:
@@ -22,6 +22,32 @@ typedef __aligned(8) ml_hwlock_t spin_lock_t;
|
|||||||
#define spin_unlock_irqrestore(lck, flags) \
|
#define spin_unlock_irqrestore(lck, flags) \
|
||||||
ml_hwlock_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(
|
static inline void spin_lock_pair_irqsave(
|
||||||
spin_lock_t *a,
|
spin_lock_t *a,
|
||||||
spin_lock_t *b,
|
spin_lock_t *b,
|
||||||
|
|||||||
@@ -180,20 +180,22 @@ void object_unlock_irqrestore(struct object *obj, unsigned long flags)
|
|||||||
spin_unlock_irqrestore(&obj->ob_lock, flags);
|
spin_unlock_irqrestore(&obj->ob_lock, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void object_lock_pair(struct object *a, struct object *b)
|
||||||
|
{
|
||||||
|
spin_lock_pair(&a->ob_lock, &b->ob_lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
void object_unlock_pair(struct object *a, struct object *b)
|
||||||
|
{
|
||||||
|
spin_unlock_pair(&a->ob_lock, &b->ob_lock);
|
||||||
|
}
|
||||||
|
|
||||||
void object_lock_pair_irqsave(
|
void object_lock_pair_irqsave(
|
||||||
struct object *a,
|
struct object *a,
|
||||||
struct object *b,
|
struct object *b,
|
||||||
unsigned long *flags)
|
unsigned long *flags)
|
||||||
{
|
{
|
||||||
if (a == b) {
|
spin_lock_pair_irqsave(&a->ob_lock, &b->ob_lock, flags);
|
||||||
object_lock_irqsave(a, flags);
|
|
||||||
} else if (a < b) {
|
|
||||||
object_lock_irqsave(a, flags);
|
|
||||||
object_lock(b);
|
|
||||||
} else {
|
|
||||||
object_lock_irqsave(b, flags);
|
|
||||||
object_lock(a);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void object_unlock_pair_irqrestore(
|
void object_unlock_pair_irqrestore(
|
||||||
@@ -201,15 +203,7 @@ void object_unlock_pair_irqrestore(
|
|||||||
struct object *b,
|
struct object *b,
|
||||||
unsigned long flags)
|
unsigned long flags)
|
||||||
{
|
{
|
||||||
if (a == b) {
|
spin_unlock_pair_irqrestore(&a->ob_lock, &b->ob_lock, flags);
|
||||||
object_unlock_irqrestore(a, flags);
|
|
||||||
} else if (a < b) {
|
|
||||||
object_unlock(b);
|
|
||||||
object_unlock_irqrestore(a, flags);
|
|
||||||
} else {
|
|
||||||
object_unlock(a);
|
|
||||||
object_unlock_irqrestore(b, flags);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void *object_data(struct object *obj)
|
void *object_data(struct object *obj)
|
||||||
|
|||||||
Reference in New Issue
Block a user