mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
xen/spinlock: add rspin_[un]lock_irq[save|restore]()
Instead of special casing rspin_lock_irqsave() and rspin_unlock_irqrestore() for the console lock, add those functions to spinlock handling and use them where needed. Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
1 parent
c9aca2a1f6
commit
cc3e8df542
3 files changed
+27
-4
No files matched your search
@@ -475,6 +475,16 @@ void _rspin_lock(rspinlock_t *lock)
|
||||
lock->recurse_cnt++;
|
||||
}
|
||||
|
||||
unsigned long _rspin_lock_irqsave(rspinlock_t *lock)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
local_irq_save(flags);
|
||||
_rspin_lock(lock);
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
void _rspin_unlock(rspinlock_t *lock)
|
||||
{
|
||||
if ( likely(--lock->recurse_cnt == 0) )
|
||||
@@ -484,6 +494,12 @@ void _rspin_unlock(rspinlock_t *lock)
|
||||
}
|
||||
}
|
||||
|
||||
void _rspin_unlock_irqrestore(rspinlock_t *lock, unsigned long flags)
|
||||
{
|
||||
_rspin_unlock(lock);
|
||||
local_irq_restore(flags);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_DEBUG_LOCK_PROFILE
|
||||
|
||||
struct lock_profile_anc {
|
||||
|
||||
@@ -1161,16 +1161,14 @@ unsigned long console_lock_recursive_irqsave(void)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
local_irq_save(flags);
|
||||
rspin_lock(&console_lock);
|
||||
rspin_lock_irqsave(&console_lock, flags);
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
void console_unlock_recursive_irqrestore(unsigned long flags)
|
||||
{
|
||||
rspin_unlock(&console_lock);
|
||||
local_irq_restore(flags);
|
||||
rspin_unlock_irqrestore(&console_lock, flags);
|
||||
}
|
||||
|
||||
void console_force_unlock(void)
|
||||
|
||||
@@ -272,7 +272,15 @@ static always_inline void spin_lock_if(bool condition, spinlock_t *l)
|
||||
*/
|
||||
bool _rspin_trylock(rspinlock_t *lock);
|
||||
void _rspin_lock(rspinlock_t *lock);
|
||||
#define rspin_lock_irqsave(l, f) \
|
||||
({ \
|
||||
BUILD_BUG_ON(sizeof(f) != sizeof(unsigned long)); \
|
||||
(f) = _rspin_lock_irqsave(l); \
|
||||
block_lock_speculation(); \
|
||||
})
|
||||
unsigned long _rspin_lock_irqsave(rspinlock_t *lock);
|
||||
void _rspin_unlock(rspinlock_t *lock);
|
||||
void _rspin_unlock_irqrestore(rspinlock_t *lock, unsigned long flags);
|
||||
|
||||
static always_inline void rspin_lock(rspinlock_t *lock)
|
||||
{
|
||||
@@ -282,5 +290,6 @@ static always_inline void rspin_lock(rspinlock_t *lock)
|
||||
|
||||
#define rspin_trylock(l) lock_evaluate_nospec(_rspin_trylock(l))
|
||||
#define rspin_unlock(l) _rspin_unlock(l)
|
||||
#define rspin_unlock_irqrestore(l, f) _rspin_unlock_irqrestore(l, f)
|
||||
|
||||
#endif /* __SPINLOCK_H__ */
|
||||