Release 4.14 arch/parisc/include/asm/spinlock.h
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __ASM_SPINLOCK_H
#define __ASM_SPINLOCK_H
#include <asm/barrier.h>
#include <asm/ldcw.h>
#include <asm/processor.h>
#include <asm/spinlock_types.h>
static inline int arch_spin_is_locked(arch_spinlock_t *x)
{
volatile unsigned int *a = __ldcw_align(x);
return *a == 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Matthew Wilcox | 26 | 92.86% | 2 | 50.00% |
Thomas Gleixner | 2 | 7.14% | 2 | 50.00% |
Total | 28 | 100.00% | 4 | 100.00% |
#define arch_spin_lock(lock) arch_spin_lock_flags(lock, 0)
static inline void arch_spin_lock_flags(arch_spinlock_t *x,
unsigned long flags)
{
volatile unsigned int *a;
mb();
a = __ldcw_align(x);
while (__ldcw(a) == 0)
while (*a == 0)
if (flags & PSW_SM_I) {
local_irq_enable();
cpu_relax();
local_irq_disable();
} else
cpu_relax();
mb();
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Matthew Wilcox | 43 | 60.56% | 3 | 42.86% |
James Bottomley | 25 | 35.21% | 1 | 14.29% |
Thomas Gleixner | 2 | 2.82% | 2 | 28.57% |
Linus Torvalds (pre-git) | 1 | 1.41% | 1 | 14.29% |
Total | 71 | 100.00% | 7 | 100.00% |
static inline void arch_spin_unlock(arch_spinlock_t *x)
{
volatile unsigned int *a;
mb();
a = __ldcw_align(x);
*a = 1;
mb();
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Matthew Wilcox | 30 | 85.71% | 2 | 40.00% |
Linus Torvalds (pre-git) | 3 | 8.57% | 1 | 20.00% |
Thomas Gleixner | 2 | 5.71% | 2 | 40.00% |
Total | 35 | 100.00% | 5 | 100.00% |
static inline int arch_spin_trylock(arch_spinlock_t *x)
{
volatile unsigned int *a;
int ret;
mb();
a = __ldcw_align(x);
ret = __ldcw(a) != 0;
mb();
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Matthew Wilcox | 40 | 88.89% | 2 | 40.00% |
Linus Torvalds (pre-git) | 3 | 6.67% | 1 | 20.00% |
Thomas Gleixner | 2 | 4.44% | 2 | 40.00% |
Total | 45 | 100.00% | 5 | 100.00% |
/*
* Read-write spinlocks, allowing multiple readers but only one writer.
* Linux rwlocks are unfair to writers; they can be starved for an indefinite
* time by readers. With care, they can also be taken in interrupt context.
*
* In the PA-RISC implementation, we have a spinlock and a counter.
* Readers use the lock to serialise their access to the counter (which
* records how many readers currently hold the lock).
* Writers hold the spinlock, preventing any readers or other writers from
* grabbing the rwlock.
*/
/* Note that we have to ensure interrupts are disabled in case we're
* interrupted by some other code that wants to grab the same read lock */
static __inline__ void arch_read_lock(arch_rwlock_t *rw)
{
unsigned long flags;
local_irq_save(flags);
arch_spin_lock_flags(&rw->lock, flags);
rw->counter++;
arch_spin_unlock(&rw->lock);
local_irq_restore(flags);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 25 | 52.08% | 1 | 14.29% |
Matthew Wilcox | 19 | 39.58% | 3 | 42.86% |
Thomas Gleixner | 4 | 8.33% | 3 | 42.86% |
Total | 48 | 100.00% | 7 | 100.00% |
/* Note that we have to ensure interrupts are disabled in case we're
* interrupted by some other code that wants to grab the same read lock */
static __inline__ void arch_read_unlock(arch_rwlock_t *rw)
{
unsigned long flags;
local_irq_save(flags);
arch_spin_lock_flags(&rw->lock, flags);
rw->counter--;
arch_spin_unlock(&rw->lock);
local_irq_restore(flags);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 25 | 52.08% | 1 | 14.29% |
Matthew Wilcox | 19 | 39.58% | 3 | 42.86% |
Thomas Gleixner | 4 | 8.33% | 3 | 42.86% |
Total | 48 | 100.00% | 7 | 100.00% |
/* Note that we have to ensure interrupts are disabled in case we're
* interrupted by some other code that wants to grab the same read lock */
static __inline__ int arch_read_trylock(arch_rwlock_t *rw)
{
unsigned long flags;
retry:
local_irq_save(flags);
if (arch_spin_trylock(&rw->lock)) {
rw->counter++;
arch_spin_unlock(&rw->lock);
local_irq_restore(flags);
return 1;
}
local_irq_restore(flags);
/* If write-locked, we fail to acquire the lock */
if (rw->counter < 0)
return 0;
/* Wait until we have a realistic chance at the lock */
while (arch_spin_is_locked(&rw->lock) && rw->counter >= 0)
cpu_relax();
goto retry;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Matthew Wilcox | 90 | 94.74% | 1 | 25.00% |
Thomas Gleixner | 5 | 5.26% | 3 | 75.00% |
Total | 95 | 100.00% | 4 | 100.00% |
/* Note that we have to ensure interrupts are disabled in case we're
* interrupted by some other code that wants to read_trylock() this lock */
static __inline__ void arch_write_lock(arch_rwlock_t *rw)
{
unsigned long flags;
retry:
local_irq_save(flags);
arch_spin_lock_flags(&rw->lock, flags);
if (rw->counter != 0) {
arch_spin_unlock(&rw->lock);
local_irq_restore(flags);
while (rw->counter != 0)
cpu_relax();
goto retry;
}
rw->counter = -1; /* mark as write-locked */
mb();
local_irq_restore(flags);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 45 | 52.94% | 1 | 12.50% |
Matthew Wilcox | 33 | 38.82% | 3 | 37.50% |
Thomas Gleixner | 4 | 4.71% | 3 | 37.50% |
Ingo Molnar | 3 | 3.53% | 1 | 12.50% |
Total | 85 | 100.00% | 8 | 100.00% |
static __inline__ void arch_write_unlock(arch_rwlock_t *rw)
{
rw->counter = 0;
arch_spin_unlock(&rw->lock);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 15 | 60.00% | 1 | 20.00% |
Matthew Wilcox | 7 | 28.00% | 1 | 20.00% |
Thomas Gleixner | 3 | 12.00% | 3 | 60.00% |
Total | 25 | 100.00% | 5 | 100.00% |
/* Note that we have to ensure interrupts are disabled in case we're
* interrupted by some other code that wants to read_trylock() this lock */
static __inline__ int arch_write_trylock(arch_rwlock_t *rw)
{
unsigned long flags;
int result = 0;
local_irq_save(flags);
if (arch_spin_trylock(&rw->lock)) {
if (rw->counter == 0) {
rw->counter = -1;
result = 1;
} else {
/* Read-locked. Oh well. */
arch_spin_unlock(&rw->lock);
}
}
local_irq_restore(flags);
return result;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Matthew Wilcox | 74 | 94.87% | 2 | 40.00% |
Thomas Gleixner | 4 | 5.13% | 3 | 60.00% |
Total | 78 | 100.00% | 5 | 100.00% |
/*
* read_can_lock - would read_trylock() succeed?
* @lock: the rwlock in question.
*/
static __inline__ int arch_read_can_lock(arch_rwlock_t *rw)
{
return rw->counter >= 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Matthew Wilcox | 15 | 83.33% | 1 | 25.00% |
Thomas Gleixner | 2 | 11.11% | 2 | 50.00% |
Kyle McMartin | 1 | 5.56% | 1 | 25.00% |
Total | 18 | 100.00% | 4 | 100.00% |
/*
* write_can_lock - would write_trylock() succeed?
* @lock: the rwlock in question.
*/
static __inline__ int arch_write_can_lock(arch_rwlock_t *rw)
{
return !rw->counter;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Matthew Wilcox | 14 | 82.35% | 1 | 25.00% |
Thomas Gleixner | 2 | 11.76% | 2 | 50.00% |
Kyle McMartin | 1 | 5.88% | 1 | 25.00% |
Total | 17 | 100.00% | 4 | 100.00% |
#define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
#define arch_write_lock_flags(lock, flags) arch_write_lock(lock)
#endif /* __ASM_SPINLOCK_H */
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Matthew Wilcox | 416 | 64.20% | 6 | 35.29% |
Linus Torvalds (pre-git) | 132 | 20.37% | 1 | 5.88% |
Thomas Gleixner | 42 | 6.48% | 4 | 23.53% |
James Bottomley | 25 | 3.86% | 1 | 5.88% |
Robin Holt | 14 | 2.16% | 1 | 5.88% |
Ingo Molnar | 8 | 1.23% | 1 | 5.88% |
Rolf Eike Beer | 6 | 0.93% | 1 | 5.88% |
Kyle McMartin | 4 | 0.62% | 1 | 5.88% |
Greg Kroah-Hartman | 1 | 0.15% | 1 | 5.88% |
Total | 648 | 100.00% | 17 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.