Skip to contentSkip to conversation

RDMA/mlx5: Annotate lock dependency in unbinding slave port

PATCH In review Leon Romanovsky 2 participants 3 messages Aug 8, 2019 – Aug 13, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RDMA/mlx5: Annotate lock dependency in unbinding slave port

From: Leon Romanovsky <[email protected]>

NULL-ing notifier_call is performed under protection of mlx5_ib_multiport_mutex lock. Such protection is not easily spotted and better to be guarded by lockdep annotation.

---
Based on -rc commit: 23eaf3b5c1a7 ("RDMA/mlx5: Release locks during notifier unregister")

---
 drivers/infiniband/hw/mlx5/main.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/infiniband/hw/mlx5/main.c +2 -0
index 7933534be931..63969484421c 100644
@@ -5835,6 +5835,8 @@ static void mlx5_ib_unbind_slave_port(struct mlx5_ib_dev *ibdev,
 	int err;
 	int i;
 
+	lockdep_assert_held(&mlx5_ib_multiport_mutex);
+
 	mlx5_ib_cleanup_cong_debugfs(ibdev, port_num);
 
 	spin_lock(&port->mp.mpi_lock);

--
2.20.1

#1 lore raw
Quoted 29 lines · Leon Romanovsky

From: Leon Romanovsky <[email protected]>

NULL-ing notifier_call is performed under protection of mlx5_ib_multiport_mutex lock. Such protection is not easily spotted and better to be guarded by lockdep annotation.

---
Based on -rc commit: 23eaf3b5c1a7 ("RDMA/mlx5: Release locks during notifier unregister")

---
 drivers/infiniband/hw/mlx5/main.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/infiniband/hw/mlx5/main.c +2 -0
index 7933534be931..63969484421c 100644
@@ -5835,6 +5835,8 @@ static void mlx5_ib_unbind_slave_port(struct
 mlx5_ib_dev *ibdev,
 	int err;
 	int i;
 
+	lockdep_assert_held(&mlx5_ib_multiport_mutex);
+
 	mlx5_ib_cleanup_cong_debugfs(ibdev, port_num);
 
Quoted 4 lines

spin_lock(&port->mp.mpi_lock);
--
2.20.1

Hi Leon,

This patch needed to catch both the unbind and the bind/init routine as they both require the multiport mutex be held. Can you respin please?

Signature · 3 lines
Doug Ledford <[email protected]>
    GPG KeyID: B826A3330E572FDD
    Fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD
#2 lore raw
Quoted 37 lines · Doug Ledford
Quoted 29 lines · Leon Romanovsky

From: Leon Romanovsky <[email protected]>

NULL-ing notifier_call is performed under protection of mlx5_ib_multiport_mutex lock. Such protection is not easily spotted and better to be guarded by lockdep annotation.

---
Based on -rc commit: 23eaf3b5c1a7 ("RDMA/mlx5: Release locks during notifier unregister")

---
 drivers/infiniband/hw/mlx5/main.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/infiniband/hw/mlx5/main.c +2 -0
index 7933534be931..63969484421c 100644
@@ -5835,6 +5835,8 @@ static void mlx5_ib_unbind_slave_port(struct
 mlx5_ib_dev *ibdev,
 	int err;
 	int i;
 
+	lockdep_assert_held(&mlx5_ib_multiport_mutex);
+
 	mlx5_ib_cleanup_cong_debugfs(ibdev, port_num);
 
Quoted 4 lines

spin_lock(&port->mp.mpi_lock);
--
2.20.1

Hi Leon,

Quoted 2 lines

This patch needed to catch both the unbind and the bind/init routine as they both require the multiport mutex be held. Can you respin please?

It has comment "5889 /* The mlx5_ib_multiport_mutex should be held when calling this function */", why do we need lockdep?

Just kidding, sending fixed patch now.

Thanks

Quoted 5 lines

--
Doug Ledford <[email protected]>

    GPG KeyID: B826A3330E572FDD
    Fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD