Skip to content

Commit bf4ce2b

Browse files
author
Jack Morgenstein
committed
net/mlx4_core: Fix lockdep warning in mac/vlan register/unregister/replace functions
In the mac and vlan register/unregister/replace functions, the driver locks the mac table mutex (or vlan table mutex) on both ports. Use mutex_lock_nested() to prevent warnings, such as the one below. [ 101.828445] ============================================= [ 101.834820] [ INFO: possible recursive locking detected ] [ 101.841199] 4.5.0-rc2-cmpn_stream_dbg-vm_2016_02_22-14_48_g759ca5d torvalds#49 Not tainted [ 101.850251] --------------------------------------------- [ 101.856621] modprobe/3054 is trying to acquire lock: [ 101.862514] (&table->mutex#2){+.+.+.}, at: [<ffffffffa079c10e>] __mlx4_register_mac+0x87e/0xa90 [mlx4_core] [ 101.874598] [ 101.874598] but task is already holding lock: [ 101.881703] (&table->mutex#2){+.+.+.}, at: [<ffffffffa079c0f0>] __mlx4_register_mac+0x860/0xa90 [mlx4_core] [ 101.893776] [ 101.893776] other info that might help us debug this: [ 101.901658] Possible unsafe locking scenario: [ 101.901658] [ 101.908859] CPU0 [ 101.911923] ---- [ 101.914985] lock(&table->mutex#2); [ 101.919595] lock(&table->mutex#2); [ 101.924199] [ 101.924199] * DEADLOCK * [ 101.924199] [ 101.931643] May be due to missing lock nesting notation This fix used here is the same as the one used by Haggai Eran in commit 31b57b8 ("IB/ucma: Fix lockdep warning in ucma_lock_files"). issue: 736271 Change-Id: Ic74edc755ef8c7d15bd96a122aa484f9b442cce4 Fixes: 5f61385 ("net/mlx4_core: Keep VLAN/MAC tables mirrored in multifunc HA mode") Suggested-by: Doron Tsur <[email protected]> Signed-off-by: Jack Morgenstein <[email protected]>
1 parent f6d99de commit bf4ce2b

File tree

1 file changed

+10
-10
lines changed
  • drivers/net/ethernet/mellanox/mlx4

1 file changed

+10
-10
lines changed

Diff for: drivers/net/ethernet/mellanox/mlx4/port.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,10 @@ int __mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac)
193193
if (need_mf_bond) {
194194
if (port == 1) {
195195
mutex_lock(&table->mutex);
196-
mutex_lock(&dup_table->mutex);
196+
mutex_lock_nested(&dup_table->mutex, SINGLE_DEPTH_NESTING);
197197
} else {
198198
mutex_lock(&dup_table->mutex);
199-
mutex_lock(&table->mutex);
199+
mutex_lock_nested(&table->mutex, SINGLE_DEPTH_NESTING);
200200
}
201201
} else {
202202
mutex_lock(&table->mutex);
@@ -389,10 +389,10 @@ void __mlx4_unregister_mac(struct mlx4_dev *dev, u8 port, u64 mac)
389389
if (dup) {
390390
if (port == 1) {
391391
mutex_lock(&table->mutex);
392-
mutex_lock(&dup_table->mutex);
392+
mutex_lock_nested(&dup_table->mutex, SINGLE_DEPTH_NESTING);
393393
} else {
394394
mutex_lock(&dup_table->mutex);
395-
mutex_lock(&table->mutex);
395+
mutex_lock_nested(&table->mutex, SINGLE_DEPTH_NESTING);
396396
}
397397
} else {
398398
mutex_lock(&table->mutex);
@@ -479,10 +479,10 @@ int __mlx4_replace_mac(struct mlx4_dev *dev, u8 port, int qpn, u64 new_mac)
479479
if (dup) {
480480
if (port == 1) {
481481
mutex_lock(&table->mutex);
482-
mutex_lock(&dup_table->mutex);
482+
mutex_lock_nested(&dup_table->mutex, SINGLE_DEPTH_NESTING);
483483
} else {
484484
mutex_lock(&dup_table->mutex);
485-
mutex_lock(&table->mutex);
485+
mutex_lock_nested(&table->mutex, SINGLE_DEPTH_NESTING);
486486
}
487487
} else {
488488
mutex_lock(&table->mutex);
@@ -588,10 +588,10 @@ int __mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan,
588588
if (need_mf_bond) {
589589
if (port == 1) {
590590
mutex_lock(&table->mutex);
591-
mutex_lock(&dup_table->mutex);
591+
mutex_lock_nested(&dup_table->mutex, SINGLE_DEPTH_NESTING);
592592
} else {
593593
mutex_lock(&dup_table->mutex);
594-
mutex_lock(&table->mutex);
594+
mutex_lock_nested(&table->mutex, SINGLE_DEPTH_NESTING);
595595
}
596596
} else {
597597
mutex_lock(&table->mutex);
@@ -764,10 +764,10 @@ void __mlx4_unregister_vlan(struct mlx4_dev *dev, u8 port, u16 vlan)
764764
if (dup) {
765765
if (port == 1) {
766766
mutex_lock(&table->mutex);
767-
mutex_lock(&dup_table->mutex);
767+
mutex_lock_nested(&dup_table->mutex, SINGLE_DEPTH_NESTING);
768768
} else {
769769
mutex_lock(&dup_table->mutex);
770-
mutex_lock(&table->mutex);
770+
mutex_lock_nested(&table->mutex, SINGLE_DEPTH_NESTING);
771771
}
772772
} else {
773773
mutex_lock(&table->mutex);

0 commit comments

Comments
 (0)