cregit-Linux how code gets into the kernel

Release 4.14 arch/metag/include/asm/spinlock_lock1.h

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __ASM_SPINLOCK_LOCK1_H

#define __ASM_SPINLOCK_LOCK1_H

#include <asm/bug.h>
#include <asm/global_lock.h>


static inline int arch_spin_is_locked(arch_spinlock_t *lock) { int ret; barrier(); ret = lock->lock; WARN_ON(ret != 0 && ret != 1); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
James Hogan37100.00%1100.00%
Total37100.00%1100.00%


static inline void arch_spin_lock(arch_spinlock_t *lock) { unsigned int we_won = 0; unsigned long flags; again: __global_lock1(flags); if (lock->lock == 0) { fence(); lock->lock = 1; we_won = 1; } __global_unlock1(flags); if (we_won == 0) goto again; WARN_ON(lock->lock != 1); }

Contributors

PersonTokensPropCommitsCommitProp
James Hogan74100.00%1100.00%
Total74100.00%1100.00%

/* Returns 0 if failed to acquire lock */
static inline int arch_spin_trylock(arch_spinlock_t *lock) { unsigned long flags; unsigned int ret; __global_lock1(flags); ret = lock->lock; if (ret == 0) { fence(); lock->lock = 1; } __global_unlock1(flags); return (ret == 0); }

Contributors

PersonTokensPropCommitsCommitProp
James Hogan59100.00%1100.00%
Total59100.00%1100.00%


static inline void arch_spin_unlock(arch_spinlock_t *lock) { barrier(); WARN_ON(!lock->lock); lock->lock = 0; }

Contributors

PersonTokensPropCommitsCommitProp
James Hogan28100.00%1100.00%
Total28100.00%1100.00%

/* * RWLOCKS * * * Write locks are easy - we just set bit 31. When unlocking, we can * just write zero since the lock is exclusively held. */
static inline void arch_write_lock(arch_rwlock_t *rw) { unsigned long flags; unsigned int we_won = 0; again: __global_lock1(flags); if (rw->lock == 0) { fence(); rw->lock = 0x80000000; we_won = 1; } __global_unlock1(flags); if (we_won == 0) goto again; WARN_ON(rw->lock != 0x80000000); }

Contributors

PersonTokensPropCommitsCommitProp
James Hogan74100.00%1100.00%
Total74100.00%1100.00%


static inline int arch_write_trylock(arch_rwlock_t *rw) { unsigned long flags; unsigned int ret; __global_lock1(flags); ret = rw->lock; if (ret == 0) { fence(); rw->lock = 0x80000000; } __global_unlock1(flags); return (ret == 0); }

Contributors

PersonTokensPropCommitsCommitProp
James Hogan59100.00%1100.00%
Total59100.00%1100.00%


static inline void arch_write_unlock(arch_rwlock_t *rw) { barrier(); WARN_ON(rw->lock != 0x80000000); rw->lock = 0; }

Contributors

PersonTokensPropCommitsCommitProp
James Hogan29100.00%1100.00%
Total29100.00%1100.00%

/* write_can_lock - would write_trylock() succeed? */
static inline int arch_write_can_lock(arch_rwlock_t *rw) { unsigned int ret; barrier(); ret = rw->lock; return (ret == 0); }

Contributors

PersonTokensPropCommitsCommitProp
James Hogan31100.00%1100.00%
Total31100.00%1100.00%

/* * Read locks are a bit more hairy: * - Exclusively load the lock value. * - Increment it. * - Store new lock value if positive, and we still own this location. * If the value is negative, we've already failed. * - If we failed to store the value, we want a negative result. * - If we failed, try again. * Unlocking is similarly hairy. We may have multiple read locks * currently active. However, we know we won't have any write * locks. */
static inline void arch_read_lock(arch_rwlock_t *rw) { unsigned long flags; unsigned int we_won = 0, ret; again: __global_lock1(flags); ret = rw->lock; if (ret < 0x80000000) { fence(); rw->lock = ret + 1; we_won = 1; } __global_unlock1(flags); if (!we_won) goto again; }

Contributors

PersonTokensPropCommitsCommitProp
James Hogan72100.00%1100.00%
Total72100.00%1100.00%


static inline void arch_read_unlock(arch_rwlock_t *rw) { unsigned long flags; unsigned int ret; __global_lock1(flags); fence(); ret = rw->lock--; __global_unlock1(flags); WARN_ON(ret == 0); }

Contributors

PersonTokensPropCommitsCommitProp
James Hogan46100.00%1100.00%
Total46100.00%1100.00%


static inline int arch_read_trylock(arch_rwlock_t *rw) { unsigned long flags; unsigned int ret; __global_lock1(flags); ret = rw->lock; if (ret < 0x80000000) { fence(); rw->lock = ret + 1; } __global_unlock1(flags); return (ret < 0x80000000); }

Contributors

PersonTokensPropCommitsCommitProp
James Hogan61100.00%1100.00%
Total61100.00%1100.00%

/* read_can_lock - would read_trylock() succeed? */
static inline int arch_read_can_lock(arch_rwlock_t *rw) { unsigned int ret; barrier(); ret = rw->lock; return (ret < 0x80000000); }

Contributors

PersonTokensPropCommitsCommitProp
James Hogan31100.00%1100.00%
Total31100.00%1100.00%

#endif /* __ASM_SPINLOCK_LOCK1_H */

Overall Contributors

PersonTokensPropCommitsCommitProp
James Hogan62199.84%150.00%
Greg Kroah-Hartman10.16%150.00%
Total622100.00%2100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.