Skip to content

Commit 6207b37

Browse files
committed
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma
Pull rdma updates from Jason Gunthorpe: "Very small update this cycle: - Minor code improvements in fi, rxe, ipoib, mana, cxgb4, mlx5, irdma, rxe, rtrs, mana - Simplify the hns hem mechanism - Fix EFA's MSI-X allocation in resource constrained configurations - Fix a KASN splat in srpt - Narrow hns's congestion control selection to QPs granularity and allow userspace to select it - Solve a parallel module loading race between the CM module and a driver module - Flexible array cleanup - Dump hns's SCC Conext to 'rdma res' for debugging - Make mana build page lists for HW objects that require a 0 offset correctly - Stuck CM ID debugging" * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma: (29 commits) RDMA/cm: add timeout to cm_destroy_id wait RDMA/mana_ib: Use virtual address in dma regions for MRs RDMA/mana_ib: Fix bug in creation of dma regions RDMA/hns: Append SCC context to the raw dump of QPC RDMA/uverbs: Avoid -Wflex-array-member-not-at-end warnings RDMA/hns: Support userspace configuring congestion control algorithm with QP granularity RDMA/rtrs-clt: Check strnlen return len in sysfs mpath_policy_store() RDMA/uverbs: Remove flexible arrays from struct *_filter RDMA/device: Fix a race between mad_client and cm_client init RDMA/hns: Fix mis-modifying default congestion control algorithm RDMA/rxe: Remove unused 'iova' parameter from rxe_mr_init_user RDMA/srpt: Do not register event handler until srpt device is fully setup RDMA/irdma: Remove duplicate assignment RDMA/efa: Limit EQs to available MSI-X vectors RDMA/mlx5: Delete unused mlx5_ib_copy_pas prototype RDMA/cxgb4: Delete unused c4iw_ep_redirect prototype RDMA/mana_ib: Introduce mana_ib_install_cq_cb helper function RDMA/mana_ib: Introduce mana_ib_get_netdev helper function RDMA/mana_ib: Introduce mdev_to_gc helper function RDMA/hns: Simplify 'struct hns_roce_hem' allocation ...
2 parents 65b6424 + 96d9cbe commit 6207b37

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+899
-698
lines changed

drivers/infiniband/core/cm.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ MODULE_AUTHOR("Sean Hefty");
3434
MODULE_DESCRIPTION("InfiniBand CM");
3535
MODULE_LICENSE("Dual BSD/GPL");
3636

37+
#define CM_DESTROY_ID_WAIT_TIMEOUT 10000 /* msecs */
3738
static const char * const ibcm_rej_reason_strs[] = {
3839
[IB_CM_REJ_NO_QP] = "no QP",
3940
[IB_CM_REJ_NO_EEC] = "no EEC",
@@ -1025,10 +1026,20 @@ static void cm_reset_to_idle(struct cm_id_private *cm_id_priv)
10251026
}
10261027
}
10271028

1029+
static noinline void cm_destroy_id_wait_timeout(struct ib_cm_id *cm_id)
1030+
{
1031+
struct cm_id_private *cm_id_priv;
1032+
1033+
cm_id_priv = container_of(cm_id, struct cm_id_private, id);
1034+
pr_err("%s: cm_id=%p timed out. state=%d refcnt=%d\n", __func__,
1035+
cm_id, cm_id->state, refcount_read(&cm_id_priv->refcount));
1036+
}
1037+
10281038
static void cm_destroy_id(struct ib_cm_id *cm_id, int err)
10291039
{
10301040
struct cm_id_private *cm_id_priv;
10311041
struct cm_work *work;
1042+
int ret;
10321043

10331044
cm_id_priv = container_of(cm_id, struct cm_id_private, id);
10341045
spin_lock_irq(&cm_id_priv->lock);
@@ -1135,7 +1146,14 @@ static void cm_destroy_id(struct ib_cm_id *cm_id, int err)
11351146

11361147
xa_erase(&cm.local_id_table, cm_local_id(cm_id->local_id));
11371148
cm_deref_id(cm_id_priv);
1138-
wait_for_completion(&cm_id_priv->comp);
1149+
do {
1150+
ret = wait_for_completion_timeout(&cm_id_priv->comp,
1151+
msecs_to_jiffies(
1152+
CM_DESTROY_ID_WAIT_TIMEOUT));
1153+
if (!ret) /* timeout happened */
1154+
cm_destroy_id_wait_timeout(cm_id);
1155+
} while (!ret);
1156+
11391157
while ((work = cm_dequeue_work(cm_id_priv)) != NULL)
11401158
cm_free_work(work);
11411159

drivers/infiniband/core/device.c

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,7 +1730,7 @@ static int assign_client_id(struct ib_client *client)
17301730
{
17311731
int ret;
17321732

1733-
down_write(&clients_rwsem);
1733+
lockdep_assert_held(&clients_rwsem);
17341734
/*
17351735
* The add/remove callbacks must be called in FIFO/LIFO order. To
17361736
* achieve this we assign client_ids so they are sorted in
@@ -1739,14 +1739,11 @@ static int assign_client_id(struct ib_client *client)
17391739
client->client_id = highest_client_id;
17401740
ret = xa_insert(&clients, client->client_id, client, GFP_KERNEL);
17411741
if (ret)
1742-
goto out;
1742+
return ret;
17431743

17441744
highest_client_id++;
17451745
xa_set_mark(&clients, client->client_id, CLIENT_REGISTERED);
1746-
1747-
out:
1748-
up_write(&clients_rwsem);
1749-
return ret;
1746+
return 0;
17501747
}
17511748

17521749
static void remove_client_id(struct ib_client *client)
@@ -1776,25 +1773,35 @@ int ib_register_client(struct ib_client *client)
17761773
{
17771774
struct ib_device *device;
17781775
unsigned long index;
1776+
bool need_unreg = false;
17791777
int ret;
17801778

17811779
refcount_set(&client->uses, 1);
17821780
init_completion(&client->uses_zero);
1781+
1782+
/*
1783+
* The devices_rwsem is held in write mode to ensure that a racing
1784+
* ib_register_device() sees a consisent view of clients and devices.
1785+
*/
1786+
down_write(&devices_rwsem);
1787+
down_write(&clients_rwsem);
17831788
ret = assign_client_id(client);
17841789
if (ret)
1785-
return ret;
1790+
goto out;
17861791

1787-
down_read(&devices_rwsem);
1792+
need_unreg = true;
17881793
xa_for_each_marked (&devices, index, device, DEVICE_REGISTERED) {
17891794
ret = add_client_context(device, client);
1790-
if (ret) {
1791-
up_read(&devices_rwsem);
1792-
ib_unregister_client(client);
1793-
return ret;
1794-
}
1795+
if (ret)
1796+
goto out;
17951797
}
1796-
up_read(&devices_rwsem);
1797-
return 0;
1798+
ret = 0;
1799+
out:
1800+
up_write(&clients_rwsem);
1801+
up_write(&devices_rwsem);
1802+
if (need_unreg && ret)
1803+
ib_unregister_client(client);
1804+
return ret;
17981805
}
17991806
EXPORT_SYMBOL(ib_register_client);
18001807

drivers/infiniband/core/uverbs_cmd.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2737,7 +2737,7 @@ int ib_uverbs_kern_spec_to_ib_spec_filter(enum ib_flow_spec_type type,
27372737

27382738
switch (ib_spec->type & ~IB_FLOW_SPEC_INNER) {
27392739
case IB_FLOW_SPEC_ETH:
2740-
ib_filter_sz = offsetof(struct ib_flow_eth_filter, real_sz);
2740+
ib_filter_sz = sizeof(struct ib_flow_eth_filter);
27412741
actual_filter_sz = spec_filter_size(kern_spec_mask,
27422742
kern_filter_sz,
27432743
ib_filter_sz);
@@ -2748,7 +2748,7 @@ int ib_uverbs_kern_spec_to_ib_spec_filter(enum ib_flow_spec_type type,
27482748
memcpy(&ib_spec->eth.mask, kern_spec_mask, actual_filter_sz);
27492749
break;
27502750
case IB_FLOW_SPEC_IPV4:
2751-
ib_filter_sz = offsetof(struct ib_flow_ipv4_filter, real_sz);
2751+
ib_filter_sz = sizeof(struct ib_flow_ipv4_filter);
27522752
actual_filter_sz = spec_filter_size(kern_spec_mask,
27532753
kern_filter_sz,
27542754
ib_filter_sz);
@@ -2759,7 +2759,7 @@ int ib_uverbs_kern_spec_to_ib_spec_filter(enum ib_flow_spec_type type,
27592759
memcpy(&ib_spec->ipv4.mask, kern_spec_mask, actual_filter_sz);
27602760
break;
27612761
case IB_FLOW_SPEC_IPV6:
2762-
ib_filter_sz = offsetof(struct ib_flow_ipv6_filter, real_sz);
2762+
ib_filter_sz = sizeof(struct ib_flow_ipv6_filter);
27632763
actual_filter_sz = spec_filter_size(kern_spec_mask,
27642764
kern_filter_sz,
27652765
ib_filter_sz);
@@ -2775,7 +2775,7 @@ int ib_uverbs_kern_spec_to_ib_spec_filter(enum ib_flow_spec_type type,
27752775
break;
27762776
case IB_FLOW_SPEC_TCP:
27772777
case IB_FLOW_SPEC_UDP:
2778-
ib_filter_sz = offsetof(struct ib_flow_tcp_udp_filter, real_sz);
2778+
ib_filter_sz = sizeof(struct ib_flow_tcp_udp_filter);
27792779
actual_filter_sz = spec_filter_size(kern_spec_mask,
27802780
kern_filter_sz,
27812781
ib_filter_sz);
@@ -2786,7 +2786,7 @@ int ib_uverbs_kern_spec_to_ib_spec_filter(enum ib_flow_spec_type type,
27862786
memcpy(&ib_spec->tcp_udp.mask, kern_spec_mask, actual_filter_sz);
27872787
break;
27882788
case IB_FLOW_SPEC_VXLAN_TUNNEL:
2789-
ib_filter_sz = offsetof(struct ib_flow_tunnel_filter, real_sz);
2789+
ib_filter_sz = sizeof(struct ib_flow_tunnel_filter);
27902790
actual_filter_sz = spec_filter_size(kern_spec_mask,
27912791
kern_filter_sz,
27922792
ib_filter_sz);
@@ -2801,7 +2801,7 @@ int ib_uverbs_kern_spec_to_ib_spec_filter(enum ib_flow_spec_type type,
28012801
return -EINVAL;
28022802
break;
28032803
case IB_FLOW_SPEC_ESP:
2804-
ib_filter_sz = offsetof(struct ib_flow_esp_filter, real_sz);
2804+
ib_filter_sz = sizeof(struct ib_flow_esp_filter);
28052805
actual_filter_sz = spec_filter_size(kern_spec_mask,
28062806
kern_filter_sz,
28072807
ib_filter_sz);
@@ -2812,7 +2812,7 @@ int ib_uverbs_kern_spec_to_ib_spec_filter(enum ib_flow_spec_type type,
28122812
memcpy(&ib_spec->esp.mask, kern_spec_mask, actual_filter_sz);
28132813
break;
28142814
case IB_FLOW_SPEC_GRE:
2815-
ib_filter_sz = offsetof(struct ib_flow_gre_filter, real_sz);
2815+
ib_filter_sz = sizeof(struct ib_flow_gre_filter);
28162816
actual_filter_sz = spec_filter_size(kern_spec_mask,
28172817
kern_filter_sz,
28182818
ib_filter_sz);
@@ -2823,7 +2823,7 @@ int ib_uverbs_kern_spec_to_ib_spec_filter(enum ib_flow_spec_type type,
28232823
memcpy(&ib_spec->gre.mask, kern_spec_mask, actual_filter_sz);
28242824
break;
28252825
case IB_FLOW_SPEC_MPLS:
2826-
ib_filter_sz = offsetof(struct ib_flow_mpls_filter, real_sz);
2826+
ib_filter_sz = sizeof(struct ib_flow_mpls_filter);
28272827
actual_filter_sz = spec_filter_size(kern_spec_mask,
28282828
kern_filter_sz,
28292829
ib_filter_sz);

0 commit comments

Comments
 (0)