Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  * This file provides wrappers with sanitizer instrumentation for bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * locking operations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  * To use this functionality, an arch's bitops.h file needs to define each of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  * the below bit operations with an arch_ prefix (e.g. arch_set_bit(),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9)  * arch___set_bit(), etc.).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #ifndef _ASM_GENERIC_BITOPS_INSTRUMENTED_LOCK_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #define _ASM_GENERIC_BITOPS_INSTRUMENTED_LOCK_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/instrumented.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)  * clear_bit_unlock - Clear a bit in memory, for unlock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)  * @nr: the bit to set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)  * @addr: the address to start counting from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)  * This operation is atomic and provides release barrier semantics.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) static inline void clear_bit_unlock(long nr, volatile unsigned long *addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 	instrument_atomic_write(addr + BIT_WORD(nr), sizeof(long));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	arch_clear_bit_unlock(nr, addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)  * __clear_bit_unlock - Clears a bit in memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)  * @nr: Bit to clear
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)  * @addr: Address to start counting from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)  * This is a non-atomic operation but implies a release barrier before the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)  * memory operation. It can be used for an unlock if no other CPUs can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)  * concurrently modify other bits in the word.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) static inline void __clear_bit_unlock(long nr, volatile unsigned long *addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	instrument_write(addr + BIT_WORD(nr), sizeof(long));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	arch___clear_bit_unlock(nr, addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)  * test_and_set_bit_lock - Set a bit and return its old value, for lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)  * @nr: Bit to set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)  * @addr: Address to count from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)  * This operation is atomic and provides acquire barrier semantics if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)  * the returned value is 0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)  * It can be used to implement bit locks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) static inline bool test_and_set_bit_lock(long nr, volatile unsigned long *addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 	instrument_atomic_read_write(addr + BIT_WORD(nr), sizeof(long));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 	return arch_test_and_set_bit_lock(nr, addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #if defined(arch_clear_bit_unlock_is_negative_byte)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)  * clear_bit_unlock_is_negative_byte - Clear a bit in memory and test if bottom
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)  *                                     byte is negative, for unlock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)  * @nr: the bit to clear
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)  * @addr: the address to start counting from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)  * This operation is atomic and provides release barrier semantics.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)  * This is a bit of a one-trick-pony for the filemap code, which clears
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)  * PG_locked and tests PG_waiters,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) static inline bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) clear_bit_unlock_is_negative_byte(long nr, volatile unsigned long *addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 	instrument_atomic_write(addr + BIT_WORD(nr), sizeof(long));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 	return arch_clear_bit_unlock_is_negative_byte(nr, addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) /* Let everybody know we have it. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) #define clear_bit_unlock_is_negative_byte clear_bit_unlock_is_negative_byte
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) #endif /* _ASM_GENERIC_BITOPS_INSTRUMENTED_LOCK_H */