hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/include/linux/spinlock_rt.h
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 #ifndef __LINUX_SPINLOCK_RT_H
23 #define __LINUX_SPINLOCK_RT_H
34
....@@ -19,10 +20,10 @@
1920 } while (0)
2021
2122 extern void __lockfunc rt_spin_lock(spinlock_t *lock);
22
-extern unsigned long __lockfunc rt_spin_lock_trace_flags(spinlock_t *lock);
2323 extern void __lockfunc rt_spin_lock_nested(spinlock_t *lock, int subclass);
24
+extern void __lockfunc rt_spin_lock_nest_lock(spinlock_t *lock, struct lockdep_map *nest_lock);
2425 extern void __lockfunc rt_spin_unlock(spinlock_t *lock);
25
-extern void __lockfunc rt_spin_unlock_wait(spinlock_t *lock);
26
+extern void __lockfunc rt_spin_lock_unlock(spinlock_t *lock);
2627 extern int __lockfunc rt_spin_trylock_irqsave(spinlock_t *lock, unsigned long *flags);
2728 extern int __lockfunc rt_spin_trylock_bh(spinlock_t *lock);
2829 extern int __lockfunc rt_spin_trylock(spinlock_t *lock);
....@@ -68,6 +69,12 @@
6869 rt_spin_lock_nested(lock, subclass); \
6970 } while (0)
7071
72
+# define spin_lock_nest_lock(lock, subclass) \
73
+ do { \
74
+ typecheck(struct lockdep_map *, &(subclass)->dep_map); \
75
+ rt_spin_lock_nest_lock(lock, &(subclass)->dep_map); \
76
+ } while (0)
77
+
7178 # define spin_lock_irqsave_nested(lock, flags, subclass) \
7279 do { \
7380 typecheck(unsigned long, flags); \
....@@ -75,14 +82,15 @@
7582 rt_spin_lock_nested(lock, subclass); \
7683 } while (0)
7784 #else
78
-# define spin_lock_nested(lock, subclass) spin_lock(lock)
79
-# define spin_lock_bh_nested(lock, subclass) spin_lock_bh(lock)
85
+# define spin_lock_nested(lock, subclass) spin_lock(((void)(subclass), (lock)))
86
+# define spin_lock_nest_lock(lock, subclass) spin_lock(((void)(subclass), (lock)))
87
+# define spin_lock_bh_nested(lock, subclass) spin_lock_bh(((void)(subclass), (lock)))
8088
8189 # define spin_lock_irqsave_nested(lock, flags, subclass) \
8290 do { \
8391 typecheck(unsigned long, flags); \
8492 flags = 0; \
85
- spin_lock(lock); \
93
+ spin_lock(((void)(subclass), (lock))); \
8694 } while (0)
8795 #endif
8896
....@@ -92,20 +100,6 @@
92100 flags = 0; \
93101 spin_lock(lock); \
94102 } while (0)
95
-
96
-static inline unsigned long spin_lock_trace_flags(spinlock_t *lock)
97
-{
98
- unsigned long flags = 0;
99
-#ifdef CONFIG_TRACE_IRQFLAGS
100
- flags = rt_spin_lock_trace_flags(lock);
101
-#else
102
- spin_lock(lock); /* lock_local */
103
-#endif
104
- return flags;
105
-}
106
-
107
-/* FIXME: we need rt_spin_lock_nest_lock */
108
-#define spin_lock_nest_lock(lock, nest_lock) spin_lock_nested(lock, 0)
109103
110104 #define spin_unlock(lock) rt_spin_unlock(lock)
111105
....@@ -127,10 +121,15 @@
127121 #define spin_trylock_bh(lock) __cond_lock(lock, rt_spin_trylock_bh(lock))
128122 #define spin_trylock_irq(lock) spin_trylock(lock)
129123
130
-#define spin_trylock_irqsave(lock, flags) \
131
- rt_spin_trylock_irqsave(lock, &(flags))
132
-
133
-#define spin_unlock_wait(lock) rt_spin_unlock_wait(lock)
124
+#define spin_trylock_irqsave(lock, flags) \
125
+({ \
126
+ int __locked; \
127
+ \
128
+ typecheck(unsigned long, flags); \
129
+ flags = 0; \
130
+ __locked = spin_trylock(lock); \
131
+ __locked; \
132
+})
134133
135134 #ifdef CONFIG_GENERIC_LOCKBREAK
136135 # define spin_is_contended(lock) ((lock)->break_lock)