Skip to content

Commit af808ec

Browse files
vsdhanaljgunthorpe
authored andcommitted
IB/SA: Check dlid before SA agent queries for ClassPortInfo
SA queries SM for class port info when there is a LID_CHANGE event. When a base lid is configured before fm is started ie when smlid is not yet assigned, SA handles the LID_CHANGE event and tries query SM with lid 0. This will cause an hang. [ 1106.958820] INFO: task kworker/2:0:23 blocked for more than 120 seconds. [ 1106.965082] Tainted: G O 4.12.0+ #1 [ 1106.969602] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. [ 1106.977227] kworker/2:0 D 0 23 2 0x00000000 [ 1106.977250] Workqueue: infiniband update_ib_cpi [ib_core] [ 1106.977261] Call Trace: [ 1106.977273] __schedule+0x28e/0x860 [ 1106.977285] schedule+0x36/0x80 [ 1106.977298] schedule_timeout+0x1a3/0x2e0 [ 1106.977310] ? radix_tree_iter_tag_clear+0x1b/0x20 [ 1106.977322] ? idr_alloc+0x64/0x90 [ 1106.977334] wait_for_completion+0xe3/0x140 [ 1106.977347] ? wake_up_q+0x80/0x80 [ 1106.977369] update_ib_cpi+0x163/0x210 [ib_core] [ 1106.977381] process_one_work+0x147/0x370 [ 1106.977394] worker_thread+0x4a/0x390 [ 1106.977406] kthread+0x109/0x140 [ 1106.977418] ? process_one_work+0x370/0x370 [ 1106.977430] ? kthread_park+0x60/0x60 [ 1106.977443] ret_from_fork+0x22/0x30 Always ensure a proper smlid is assigned before querying SM for cpi. Fixes: ee1c60b ("IB/SA: Modify SA to implicitly cache Class Port info") Reviewed-by: Ira Weiny <[email protected]> Signed-off-by: Venkata Sandeep Dhanalakota <[email protected]> Signed-off-by: Dennis Dalessandro <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent adb1c0d commit af808ec

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

drivers/infiniband/core/sa_query.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,7 @@ EXPORT_SYMBOL(ib_init_ah_attr_from_path);
13451345

13461346
static int alloc_mad(struct ib_sa_query *query, gfp_t gfp_mask)
13471347
{
1348+
struct rdma_ah_attr ah_attr;
13481349
unsigned long flags;
13491350

13501351
spin_lock_irqsave(&query->port->ah_lock, flags);
@@ -1356,6 +1357,15 @@ static int alloc_mad(struct ib_sa_query *query, gfp_t gfp_mask)
13561357
query->sm_ah = query->port->sm_ah;
13571358
spin_unlock_irqrestore(&query->port->ah_lock, flags);
13581359

1360+
/*
1361+
* Always check if sm_ah has valid dlid assigned,
1362+
* before querying for class port info
1363+
*/
1364+
if ((rdma_query_ah(query->sm_ah->ah, &ah_attr) < 0) ||
1365+
!rdma_is_valid_unicast_lid(&ah_attr)) {
1366+
kref_put(&query->sm_ah->ref, free_sm_ah);
1367+
return -EAGAIN;
1368+
}
13591369
query->mad_buf = ib_create_send_mad(query->port->agent, 1,
13601370
query->sm_ah->pkey_index,
13611371
0, IB_MGMT_SA_HDR, IB_MGMT_SA_DATA,

include/rdma/opa_addr.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,20 @@ static inline u32 opa_get_mcast_base(u32 nr_top_bits)
114114
return (be32_to_cpu(OPA_LID_PERMISSIVE) << (32 - nr_top_bits));
115115
}
116116

117+
/* Check for a valid unicast LID for non-SM traffic types */
118+
static inline bool rdma_is_valid_unicast_lid(struct rdma_ah_attr *attr)
119+
{
120+
if (attr->type == RDMA_AH_ATTR_TYPE_IB) {
121+
if (!rdma_ah_get_dlid(attr) ||
122+
rdma_ah_get_dlid(attr) >=
123+
be32_to_cpu(IB_MULTICAST_LID_BASE))
124+
return false;
125+
} else if (attr->type == RDMA_AH_ATTR_TYPE_OPA) {
126+
if (!rdma_ah_get_dlid(attr) ||
127+
rdma_ah_get_dlid(attr) >=
128+
opa_get_mcast_base(OPA_MCAST_NR))
129+
return false;
130+
}
131+
return true;
132+
}
117133
#endif /* OPA_ADDR_H */

0 commit comments

Comments
 (0)