diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-07-30 14:37:16 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-07-30 14:37:16 -0400 |
commit | fb20c03d3748fc6991dd58a3161c0d954485c2ce (patch) | |
tree | 751c3d121f489111b54aa32793570516bd2f36db | |
parent | d464b0314c79996a0a4ae9ed3b13f914052d747d (diff) | |
parent | c0dc373a780f4ec63e45a573b9551763abd8cd1a (diff) |
Merge branch 'locking-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull locking fixes from Ingo Molnar:
"A paravirt UP-patching fix, and an I2C MUX driver lockdep warning fix"
* 'locking-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
locking/pvqspinlock/x86: Use LOCK_PREFIX in __pv_queued_spin_unlock() assembly code
i2c/mux, locking/core: Annotate the nested rt_mutex usage
locking/rtmutex: Allow specifying a subclass for nested locking
-rw-r--r-- | arch/x86/include/asm/qspinlock_paravirt.h | 2 | ||||
-rw-r--r-- | drivers/i2c/i2c-core-base.c | 2 | ||||
-rw-r--r-- | drivers/i2c/i2c-mux.c | 4 | ||||
-rw-r--r-- | include/linux/rtmutex.h | 7 | ||||
-rw-r--r-- | kernel/locking/rtmutex.c | 29 |
5 files changed, 36 insertions, 8 deletions
diff --git a/arch/x86/include/asm/qspinlock_paravirt.h b/arch/x86/include/asm/qspinlock_paravirt.h index 9ef5ee03d2d7..159622ee0674 100644 --- a/arch/x86/include/asm/qspinlock_paravirt.h +++ b/arch/x86/include/asm/qspinlock_paravirt.h | |||
@@ -43,7 +43,7 @@ asm (".pushsection .text;" | |||
43 | "push %rdx;" | 43 | "push %rdx;" |
44 | "mov $0x1,%eax;" | 44 | "mov $0x1,%eax;" |
45 | "xor %edx,%edx;" | 45 | "xor %edx,%edx;" |
46 | "lock cmpxchg %dl,(%rdi);" | 46 | LOCK_PREFIX "cmpxchg %dl,(%rdi);" |
47 | "cmp $0x1,%al;" | 47 | "cmp $0x1,%al;" |
48 | "jne .slowpath;" | 48 | "jne .slowpath;" |
49 | "pop %rdx;" | 49 | "pop %rdx;" |
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 301285c54603..15c95aaa484c 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c | |||
@@ -624,7 +624,7 @@ static int i2c_check_addr_busy(struct i2c_adapter *adapter, int addr) | |||
624 | static void i2c_adapter_lock_bus(struct i2c_adapter *adapter, | 624 | static void i2c_adapter_lock_bus(struct i2c_adapter *adapter, |
625 | unsigned int flags) | 625 | unsigned int flags) |
626 | { | 626 | { |
627 | rt_mutex_lock(&adapter->bus_lock); | 627 | rt_mutex_lock_nested(&adapter->bus_lock, i2c_adapter_depth(adapter)); |
628 | } | 628 | } |
629 | 629 | ||
630 | /** | 630 | /** |
diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c index 300ab4b672e4..29646aa6132e 100644 --- a/drivers/i2c/i2c-mux.c +++ b/drivers/i2c/i2c-mux.c | |||
@@ -144,7 +144,7 @@ static void i2c_mux_lock_bus(struct i2c_adapter *adapter, unsigned int flags) | |||
144 | struct i2c_mux_priv *priv = adapter->algo_data; | 144 | struct i2c_mux_priv *priv = adapter->algo_data; |
145 | struct i2c_adapter *parent = priv->muxc->parent; | 145 | struct i2c_adapter *parent = priv->muxc->parent; |
146 | 146 | ||
147 | rt_mutex_lock(&parent->mux_lock); | 147 | rt_mutex_lock_nested(&parent->mux_lock, i2c_adapter_depth(adapter)); |
148 | if (!(flags & I2C_LOCK_ROOT_ADAPTER)) | 148 | if (!(flags & I2C_LOCK_ROOT_ADAPTER)) |
149 | return; | 149 | return; |
150 | i2c_lock_bus(parent, flags); | 150 | i2c_lock_bus(parent, flags); |
@@ -181,7 +181,7 @@ static void i2c_parent_lock_bus(struct i2c_adapter *adapter, | |||
181 | struct i2c_mux_priv *priv = adapter->algo_data; | 181 | struct i2c_mux_priv *priv = adapter->algo_data; |
182 | struct i2c_adapter *parent = priv->muxc->parent; | 182 | struct i2c_adapter *parent = priv->muxc->parent; |
183 | 183 | ||
184 | rt_mutex_lock(&parent->mux_lock); | 184 | rt_mutex_lock_nested(&parent->mux_lock, i2c_adapter_depth(adapter)); |
185 | i2c_lock_bus(parent, flags); | 185 | i2c_lock_bus(parent, flags); |
186 | } | 186 | } |
187 | 187 | ||
diff --git a/include/linux/rtmutex.h b/include/linux/rtmutex.h index 1b92a28dd672..6fd615a0eea9 100644 --- a/include/linux/rtmutex.h +++ b/include/linux/rtmutex.h | |||
@@ -106,7 +106,14 @@ static inline int rt_mutex_is_locked(struct rt_mutex *lock) | |||
106 | extern void __rt_mutex_init(struct rt_mutex *lock, const char *name, struct lock_class_key *key); | 106 | extern void __rt_mutex_init(struct rt_mutex *lock, const char *name, struct lock_class_key *key); |
107 | extern void rt_mutex_destroy(struct rt_mutex *lock); | 107 | extern void rt_mutex_destroy(struct rt_mutex *lock); |
108 | 108 | ||
109 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
110 | extern void rt_mutex_lock_nested(struct rt_mutex *lock, unsigned int subclass); | ||
111 | #define rt_mutex_lock(lock) rt_mutex_lock_nested(lock, 0) | ||
112 | #else | ||
109 | extern void rt_mutex_lock(struct rt_mutex *lock); | 113 | extern void rt_mutex_lock(struct rt_mutex *lock); |
114 | #define rt_mutex_lock_nested(lock, subclass) rt_mutex_lock(lock) | ||
115 | #endif | ||
116 | |||
110 | extern int rt_mutex_lock_interruptible(struct rt_mutex *lock); | 117 | extern int rt_mutex_lock_interruptible(struct rt_mutex *lock); |
111 | extern int rt_mutex_timed_lock(struct rt_mutex *lock, | 118 | extern int rt_mutex_timed_lock(struct rt_mutex *lock, |
112 | struct hrtimer_sleeper *timeout); | 119 | struct hrtimer_sleeper *timeout); |
diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c index 4f014be7a4b8..2823d4163a37 100644 --- a/kernel/locking/rtmutex.c +++ b/kernel/locking/rtmutex.c | |||
@@ -1465,6 +1465,29 @@ rt_mutex_fastunlock(struct rt_mutex *lock, | |||
1465 | rt_mutex_postunlock(&wake_q); | 1465 | rt_mutex_postunlock(&wake_q); |
1466 | } | 1466 | } |
1467 | 1467 | ||
1468 | static inline void __rt_mutex_lock(struct rt_mutex *lock, unsigned int subclass) | ||
1469 | { | ||
1470 | might_sleep(); | ||
1471 | |||
1472 | mutex_acquire(&lock->dep_map, subclass, 0, _RET_IP_); | ||
1473 | rt_mutex_fastlock(lock, TASK_UNINTERRUPTIBLE, rt_mutex_slowlock); | ||
1474 | } | ||
1475 | |||
1476 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
1477 | /** | ||
1478 | * rt_mutex_lock_nested - lock a rt_mutex | ||
1479 | * | ||
1480 | * @lock: the rt_mutex to be locked | ||
1481 | * @subclass: the lockdep subclass | ||
1482 | */ | ||
1483 | void __sched rt_mutex_lock_nested(struct rt_mutex *lock, unsigned int subclass) | ||
1484 | { | ||
1485 | __rt_mutex_lock(lock, subclass); | ||
1486 | } | ||
1487 | EXPORT_SYMBOL_GPL(rt_mutex_lock_nested); | ||
1488 | #endif | ||
1489 | |||
1490 | #ifndef CONFIG_DEBUG_LOCK_ALLOC | ||
1468 | /** | 1491 | /** |
1469 | * rt_mutex_lock - lock a rt_mutex | 1492 | * rt_mutex_lock - lock a rt_mutex |
1470 | * | 1493 | * |
@@ -1472,12 +1495,10 @@ rt_mutex_fastunlock(struct rt_mutex *lock, | |||
1472 | */ | 1495 | */ |
1473 | void __sched rt_mutex_lock(struct rt_mutex *lock) | 1496 | void __sched rt_mutex_lock(struct rt_mutex *lock) |
1474 | { | 1497 | { |
1475 | might_sleep(); | 1498 | __rt_mutex_lock(lock, 0); |
1476 | |||
1477 | mutex_acquire(&lock->dep_map, 0, 0, _RET_IP_); | ||
1478 | rt_mutex_fastlock(lock, TASK_UNINTERRUPTIBLE, rt_mutex_slowlock); | ||
1479 | } | 1499 | } |
1480 | EXPORT_SYMBOL_GPL(rt_mutex_lock); | 1500 | EXPORT_SYMBOL_GPL(rt_mutex_lock); |
1501 | #endif | ||
1481 | 1502 | ||
1482 | /** | 1503 | /** |
1483 | * rt_mutex_lock_interruptible - lock a rt_mutex interruptible | 1504 | * rt_mutex_lock_interruptible - lock a rt_mutex interruptible |