RDMA/rxe: Protect QP state with qp->state_lock
authorBob Pearson <rpearsonhpe@gmail.com>
Wed, 5 Apr 2023 04:26:11 +0000 (23:26 -0500)
committerJason Gunthorpe <jgg@nvidia.com>
Mon, 17 Apr 2023 19:34:04 +0000 (16:34 -0300)
commitf605f26ea196a3b49bea249330cbd18dba61a33e
treefc7bb3a98ec7549d60e7be5ae6db058ad219bb4a
parent7b560b89a08d35c23dfc95dc44aee10651c8b9a0
RDMA/rxe: Protect QP state with qp->state_lock

Currently the rxe driver makes little effort to make the changes to qp
state (which includes qp->attr.qp_state, qp->attr.sq_draining and
qp->valid) atomic between different client threads and IO threads. In
particular a common template is for an RDMA application to call
ib_modify_qp() to move a qp to ERR state and then wait until all the
packet and work queues have drained before calling ib_destroy_qp(). None
of these state changes are protected by locks to assure that the changes
are executed atomically and that memory barriers are included. This has
been observed to lead to incorrect behavior around qp cleanup.

This patch continues the work of the previous patches in this series and
adds locking code around qp state changes and lookups.

Link: https://lore.kernel.org/r/20230405042611.6467-5-rpearsonhpe@gmail.com
Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/sw/rxe/rxe_comp.c
drivers/infiniband/sw/rxe/rxe_net.c
drivers/infiniband/sw/rxe/rxe_qp.c
drivers/infiniband/sw/rxe/rxe_recv.c
drivers/infiniband/sw/rxe/rxe_req.c
drivers/infiniband/sw/rxe/rxe_resp.c
drivers/infiniband/sw/rxe/rxe_verbs.c