Skip to content

Commit d3b5cc1

Browse files
mark-blochjgunthorpe
authored andcommitted
RDMA/mlx5: Initialize roce port info before multiport master init
When working in mutliport RoCE mode it is possible to attach a slave before the master. In that case the slave is waiting for a master to be attached. When the master is attached it goes over the list of waiting slaves, finds a slave that is compatible and tries to bind it to itself. The call stack is: mlx5_ib_init_multiport_master() -> mlx5_ib_bind_slave_port() In the bind function we will create a netdev notifier, but this is done before we initialize the RoCE structure (this is done at a later stage by the master in the ROCE stage). Once events are delivered to that notifier we will use mlx5_ib_get_native_port_mdev() to get the actual port and as the native port is zero we will access an invalid index in the port structure. Move the RoCE structure initialization to an earlier stage. Fixes: 32f69e4 ("{net, IB}/mlx5: Manage port association for multiport RoCE") Signed-off-by: Mark Bloch <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 7f57510 commit d3b5cc1

File tree

1 file changed

+3
-7
lines changed
  • drivers/infiniband/hw/mlx5

1 file changed

+3
-7
lines changed

drivers/infiniband/hw/mlx5/main.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5904,6 +5904,9 @@ static int mlx5_ib_stage_init_init(struct mlx5_ib_dev *dev)
59045904
for (i = 0; i < dev->num_ports; i++) {
59055905
spin_lock_init(&dev->port[i].mp.mpi_lock);
59065906
rwlock_init(&dev->port[i].roce.netdev_lock);
5907+
dev->port[i].roce.dev = dev;
5908+
dev->port[i].roce.native_port_num = i + 1;
5909+
dev->port[i].roce.last_port_state = IB_PORT_DOWN;
59075910
}
59085911

59095912
err = mlx5_ib_init_multiport_master(dev);
@@ -6190,13 +6193,6 @@ static const struct ib_device_ops mlx5_ib_dev_common_roce_ops = {
61906193
static int mlx5_ib_stage_common_roce_init(struct mlx5_ib_dev *dev)
61916194
{
61926195
u8 port_num;
6193-
int i;
6194-
6195-
for (i = 0; i < dev->num_ports; i++) {
6196-
dev->port[i].roce.dev = dev;
6197-
dev->port[i].roce.native_port_num = i + 1;
6198-
dev->port[i].roce.last_port_state = IB_PORT_DOWN;
6199-
}
62006196

62016197
dev->ib_dev.uverbs_ex_cmd_mask |=
62026198
(1ull << IB_USER_VERBS_EX_CMD_CREATE_WQ) |

0 commit comments

Comments
 (0)