IB/cm: Improve the calling of cm_init_av_for_lap and cm_init_av_by_path
authorMark Zhang <markzhang@nvidia.com>
Wed, 2 Jun 2021 10:27:07 +0000 (13:27 +0300)
committerJason Gunthorpe <jgg@nvidia.com>
Wed, 2 Jun 2021 18:41:58 +0000 (15:41 -0300)
commit7345201c39633fc4c82dae7315da7154efaf2459
tree76776d8a446588ef1b482c3342253446362588c0
parent70076a414efc75894344d2adabf68254e38be71a
IB/cm: Improve the calling of cm_init_av_for_lap and cm_init_av_by_path

The cm_init_av_for_lap() and cm_init_av_by_path() function calls have the
following issues:

1. Both of them might sleep and should not be called under spinlock.
2. The access of cm_id_priv->av should be under cm_id_priv->lock, which
   means it can't be initialized directly.

This patch splits the calling of 2 functions into two parts: first one
initializes an AV outside of the spinlock, the second one copies AV to
cm_id_priv->av under spinlock.

Fixes: e1444b5a163e ("IB/cm: Fix automatic path migration support")
Link: https://lore.kernel.org/r/038fb8ad932869b4548b0c7708cab7f76af06f18.1622629024.git.leonro@nvidia.com
Signed-off-by: Mark Zhang <markzhang@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/core/cm.c