Skip to content

Commit fb20c03

Browse files
committed
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
2 parents d464b03 + c0dc373 commit fb20c03

File tree

5 files changed

+36
-8
lines changed

5 files changed

+36
-8
lines changed

arch/x86/include/asm/qspinlock_paravirt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ asm (".pushsection .text;"
4343
"push %rdx;"
4444
"mov $0x1,%eax;"
4545
"xor %edx,%edx;"
46-
"lock cmpxchg %dl,(%rdi);"
46+
LOCK_PREFIX "cmpxchg %dl,(%rdi);"
4747
"cmp $0x1,%al;"
4848
"jne .slowpath;"
4949
"pop %rdx;"

drivers/i2c/i2c-core-base.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ static int i2c_check_addr_busy(struct i2c_adapter *adapter, int addr)
624624
static void i2c_adapter_lock_bus(struct i2c_adapter *adapter,
625625
unsigned int flags)
626626
{
627-
rt_mutex_lock(&adapter->bus_lock);
627+
rt_mutex_lock_nested(&adapter->bus_lock, i2c_adapter_depth(adapter));
628628
}
629629

630630
/**

drivers/i2c/i2c-mux.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static void i2c_mux_lock_bus(struct i2c_adapter *adapter, unsigned int flags)
144144
struct i2c_mux_priv *priv = adapter->algo_data;
145145
struct i2c_adapter *parent = priv->muxc->parent;
146146

147-
rt_mutex_lock(&parent->mux_lock);
147+
rt_mutex_lock_nested(&parent->mux_lock, i2c_adapter_depth(adapter));
148148
if (!(flags & I2C_LOCK_ROOT_ADAPTER))
149149
return;
150150
i2c_lock_bus(parent, flags);
@@ -181,7 +181,7 @@ static void i2c_parent_lock_bus(struct i2c_adapter *adapter,
181181
struct i2c_mux_priv *priv = adapter->algo_data;
182182
struct i2c_adapter *parent = priv->muxc->parent;
183183

184-
rt_mutex_lock(&parent->mux_lock);
184+
rt_mutex_lock_nested(&parent->mux_lock, i2c_adapter_depth(adapter));
185185
i2c_lock_bus(parent, flags);
186186
}
187187

include/linux/rtmutex.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,14 @@ static inline int rt_mutex_is_locked(struct rt_mutex *lock)
106106
extern void __rt_mutex_init(struct rt_mutex *lock, const char *name, struct lock_class_key *key);
107107
extern void rt_mutex_destroy(struct rt_mutex *lock);
108108

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
109113
extern void rt_mutex_lock(struct rt_mutex *lock);
114+
#define rt_mutex_lock_nested(lock, subclass) rt_mutex_lock(lock)
115+
#endif
116+
110117
extern int rt_mutex_lock_interruptible(struct rt_mutex *lock);
111118
extern int rt_mutex_timed_lock(struct rt_mutex *lock,
112119
struct hrtimer_sleeper *timeout);

kernel/locking/rtmutex.c

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,19 +1465,40 @@ rt_mutex_fastunlock(struct rt_mutex *lock,
14651465
rt_mutex_postunlock(&wake_q);
14661466
}
14671467

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
14681491
/**
14691492
* rt_mutex_lock - lock a rt_mutex
14701493
*
14711494
* @lock: the rt_mutex to be locked
14721495
*/
14731496
void __sched rt_mutex_lock(struct rt_mutex *lock)
14741497
{
1475-
might_sleep();
1476-
1477-
mutex_acquire(&lock->dep_map, 0, 0, _RET_IP_);
1478-
rt_mutex_fastlock(lock, TASK_UNINTERRUPTIBLE, rt_mutex_slowlock);
1498+
__rt_mutex_lock(lock, 0);
14791499
}
14801500
EXPORT_SYMBOL_GPL(rt_mutex_lock);
1501+
#endif
14811502

14821503
/**
14831504
* rt_mutex_lock_interruptible - lock a rt_mutex interruptible

0 commit comments

Comments
 (0)