--- zzzz-none-000/linux-5.4.213/include/linux/spinlock.h 2022-09-15 10:04:56.000000000 +0000 +++ alder-5690pro-762/linux-5.4.213/include/linux/spinlock.h 2024-08-14 09:02:08.000000000 +0000 @@ -58,6 +58,16 @@ #include #include #include +#if defined(CONFIG_AVM_FASTIRQ_DEBUG) +#include +#define AVM_CHECK_LINUX_CONTEXT()\ + do {\ + if (is_cpu_mode_fiq())\ + pr_err("ERROR: fiq-context 0x%08lx 0x%08lx\n", _THIS_IP_, _RET_IP_);\ + } while (0) +#else +#define AVM_CHECK_LINUX_CONTEXT() +#endif /* CONFIG_AVM_FASTIRQ_DEBUG */ /* @@ -223,8 +233,11 @@ #define raw_spin_lock(lock) _raw_spin_lock(lock) #ifdef CONFIG_DEBUG_LOCK_ALLOC -# define raw_spin_lock_nested(lock, subclass) \ - _raw_spin_lock_nested(lock, subclass) +# define raw_spin_lock_nested(lock, subclass) \ + do { \ + AVM_CHECK_LINUX_CONTEXT(); \ + _raw_spin_lock_nested(lock, subclass); \ + } while (0) # define raw_spin_lock_nest_lock(lock, nest_lock) \ do { \ @@ -246,6 +259,7 @@ #define raw_spin_lock_irqsave(lock, flags) \ do { \ + AVM_CHECK_LINUX_CONTEXT(); \ typecheck(unsigned long, flags); \ flags = _raw_spin_lock_irqsave(lock); \ } while (0) @@ -253,12 +267,14 @@ #ifdef CONFIG_DEBUG_LOCK_ALLOC #define raw_spin_lock_irqsave_nested(lock, flags, subclass) \ do { \ + AVM_CHECK_LINUX_CONTEXT(); \ typecheck(unsigned long, flags); \ flags = _raw_spin_lock_irqsave_nested(lock, subclass); \ } while (0) #else #define raw_spin_lock_irqsave_nested(lock, flags, subclass) \ do { \ + AVM_CHECK_LINUX_CONTEXT(); \ typecheck(unsigned long, flags); \ flags = _raw_spin_lock_irqsave(lock); \ } while (0) @@ -268,6 +284,7 @@ #define raw_spin_lock_irqsave(lock, flags) \ do { \ + AVM_CHECK_LINUX_CONTEXT(); \ typecheck(unsigned long, flags); \ _raw_spin_lock_irqsave(lock, flags); \ } while (0) @@ -294,6 +311,7 @@ #define raw_spin_trylock_irq(lock) \ ({ \ + AVM_CHECK_LINUX_CONTEXT(); \ local_irq_disable(); \ raw_spin_trylock(lock) ? \ 1 : ({ local_irq_enable(); 0; }); \ @@ -301,6 +319,7 @@ #define raw_spin_trylock_irqsave(lock, flags) \ ({ \ + AVM_CHECK_LINUX_CONTEXT(); \ local_irq_save(flags); \ raw_spin_trylock(lock) ? \ 1 : ({ local_irq_restore(flags); 0; }); \ @@ -335,41 +354,49 @@ static __always_inline void spin_lock(spinlock_t *lock) { + AVM_CHECK_LINUX_CONTEXT(); raw_spin_lock(&lock->rlock); } static __always_inline void spin_lock_bh(spinlock_t *lock) { + AVM_CHECK_LINUX_CONTEXT(); raw_spin_lock_bh(&lock->rlock); } static __always_inline int spin_trylock(spinlock_t *lock) { + AVM_CHECK_LINUX_CONTEXT(); return raw_spin_trylock(&lock->rlock); } #define spin_lock_nested(lock, subclass) \ do { \ + AVM_CHECK_LINUX_CONTEXT(); \ raw_spin_lock_nested(spinlock_check(lock), subclass); \ } while (0) #define spin_lock_nest_lock(lock, nest_lock) \ do { \ + AVM_CHECK_LINUX_CONTEXT(); \ raw_spin_lock_nest_lock(spinlock_check(lock), nest_lock); \ } while (0) static __always_inline void spin_lock_irq(spinlock_t *lock) { + AVM_CHECK_LINUX_CONTEXT(); raw_spin_lock_irq(&lock->rlock); } #define spin_lock_irqsave(lock, flags) \ do { \ + AVM_CHECK_LINUX_CONTEXT(); \ raw_spin_lock_irqsave(spinlock_check(lock), flags); \ } while (0) #define spin_lock_irqsave_nested(lock, flags, subclass) \ do { \ + AVM_CHECK_LINUX_CONTEXT(); \ raw_spin_lock_irqsave_nested(spinlock_check(lock), flags, subclass); \ } while (0) @@ -395,16 +422,19 @@ static __always_inline int spin_trylock_bh(spinlock_t *lock) { + AVM_CHECK_LINUX_CONTEXT(); return raw_spin_trylock_bh(&lock->rlock); } static __always_inline int spin_trylock_irq(spinlock_t *lock) { + AVM_CHECK_LINUX_CONTEXT(); return raw_spin_trylock_irq(&lock->rlock); } #define spin_trylock_irqsave(lock, flags) \ ({ \ + AVM_CHECK_LINUX_CONTEXT(); \ raw_spin_trylock_irqsave(spinlock_check(lock), flags); \ })