aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Cohen <eli@mellanox.com>2017-02-14 00:25:38 -0500
committerDoug Ledford <dledford@redhat.com>2017-02-15 09:29:37 -0500
commitcdbe33d0f82d68ff74f05502a4c26e65ec7e90bb (patch)
tree5e179fb792e0a48418cb8a2fb9ea0fafe1f8c236
parenta748d60df32ec5da31626a140be1795eefa04282 (diff)
IB/mlx5: Fix configuration of port capabilities
When the "ib_virt" cap is set, configuration of port capabilities need to be done through mlx5_core_modify_hca_vport_context. Since modify_hca_vport_context accepts mask and value, there is no need to read the port capabilities and calculate the new cap values so we avoid the mutex when ib_virt is set. Signed-off-by: Eli Cohen <eli@mellanox.com> Reviewed-by: Matan Barak <matanb@mellanox.com> Signed-off-by: Leon Romanovsky <leon@kernel.org> Signed-off-by: Doug Ledford <dledford@redhat.com>
-rw-r--r--drivers/infiniband/hw/mlx5/main.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index 8fd35ebb13e3..4a043cf35b9a 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -995,6 +995,31 @@ static int mlx5_ib_modify_device(struct ib_device *ibdev, int mask,
995 return err; 995 return err;
996} 996}
997 997
998static int set_port_caps_atomic(struct mlx5_ib_dev *dev, u8 port_num, u32 mask,
999 u32 value)
1000{
1001 struct mlx5_hca_vport_context ctx = {};
1002 int err;
1003
1004 err = mlx5_query_hca_vport_context(dev->mdev, 0,
1005 port_num, 0, &ctx);
1006 if (err)
1007 return err;
1008
1009 if (~ctx.cap_mask1_perm & mask) {
1010 mlx5_ib_warn(dev, "trying to change bitmask 0x%X but change supported 0x%X\n",
1011 mask, ctx.cap_mask1_perm);
1012 return -EINVAL;
1013 }
1014
1015 ctx.cap_mask1 = value;
1016 ctx.cap_mask1_perm = mask;
1017 err = mlx5_core_modify_hca_vport_context(dev->mdev, 0,
1018 port_num, 0, &ctx);
1019
1020 return err;
1021}
1022
998static int mlx5_ib_modify_port(struct ib_device *ibdev, u8 port, int mask, 1023static int mlx5_ib_modify_port(struct ib_device *ibdev, u8 port, int mask,
999 struct ib_port_modify *props) 1024 struct ib_port_modify *props)
1000{ 1025{
@@ -1002,6 +1027,16 @@ static int mlx5_ib_modify_port(struct ib_device *ibdev, u8 port, int mask,
1002 struct ib_port_attr attr; 1027 struct ib_port_attr attr;
1003 u32 tmp; 1028 u32 tmp;
1004 int err; 1029 int err;
1030 u32 change_mask;
1031 u32 value;
1032 bool is_ib = (mlx5_ib_port_link_layer(ibdev, port) ==
1033 IB_LINK_LAYER_INFINIBAND);
1034
1035 if (MLX5_CAP_GEN(dev->mdev, ib_virt) && is_ib) {
1036 change_mask = props->clr_port_cap_mask | props->set_port_cap_mask;
1037 value = ~props->clr_port_cap_mask | props->set_port_cap_mask;
1038 return set_port_caps_atomic(dev, port, change_mask, value);
1039 }
1005 1040
1006 mutex_lock(&dev->cap_mask_mutex); 1041 mutex_lock(&dev->cap_mask_mutex);
1007 1042