Skip to content

Commit c964ced

Browse files
committed
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma
Pull rdma fixes from Jason Gunthorpe: "Several miscellaneous fixes. A lot of bnxt_re activity, there will be more rc patches there coming. - Many bnxt_re bug fixes - Memory leaks, kasn, NULL pointer deref, soft lockups, error unwinding and some small functional issues - Error unwind bug in rdma netlink - Two issues with incorrect VLAN detection for iWarp - skb_splice_from_iter() splat in siw - Give SRP slab caches unique names to resolve the merge window WARN_ON regression" * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma: RDMA/bnxt_re: Fix the GID table length RDMA/bnxt_re: Fix a bug while setting up Level-2 PBL pages RDMA/bnxt_re: Change the sequence of updating the CQ toggle value RDMA/bnxt_re: Fix an error path in bnxt_re_add_device RDMA/bnxt_re: Avoid CPU lockups due fifo occupancy check loop RDMA/bnxt_re: Fix a possible NULL pointer dereference RDMA/bnxt_re: Return more meaningful error RDMA/bnxt_re: Fix incorrect dereference of srq in async event RDMA/bnxt_re: Fix out of bound check RDMA/bnxt_re: Fix the max CQ WQEs for older adapters RDMA/srpt: Make slab cache names unique RDMA/irdma: Fix misspelling of "accept*" RDMA/cxgb4: Fix RDMA_CM_EVENT_UNREACHABLE error for iWARP RDMA/siw: Add sendpage_ok() check to disable MSG_SPLICE_PAGES RDMA/core: Fix ENODEV error for iWARP test over vlan RDMA/nldev: Fix NULL pointer dereferences issue in rdma_nl_notify_event RDMA/bnxt_re: Fix the max WQEs used in Static WQE mode RDMA/bnxt_re: Add a check for memory allocation RDMA/bnxt_re: Fix incorrect AVID type in WQE structure RDMA/bnxt_re: Fix a possible memory leak
2 parents 667b1d4 + dc5006c commit c964ced

File tree

15 files changed

+133
-61
lines changed

15 files changed

+133
-61
lines changed

drivers/infiniband/core/addr.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ rdma_find_ndev_for_src_ip_rcu(struct net *net, const struct sockaddr *src_in)
269269
break;
270270
#endif
271271
}
272+
if (!ret && dev && is_vlan_dev(dev))
273+
dev = vlan_dev_real_dev(dev);
272274
return ret ? ERR_PTR(ret) : dev;
273275
}
274276

drivers/infiniband/core/nldev.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2816,6 +2816,8 @@ int rdma_nl_notify_event(struct ib_device *device, u32 port_num,
28162816
nlh = nlmsg_put(skb, 0, 0,
28172817
RDMA_NL_GET_TYPE(RDMA_NL_NLDEV, RDMA_NLDEV_CMD_MONITOR),
28182818
0, 0);
2819+
if (!nlh)
2820+
goto err_free;
28192821

28202822
switch (type) {
28212823
case RDMA_REGISTER_EVENT:

drivers/infiniband/hw/bnxt_re/hw_counters.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ int bnxt_re_ib_get_hw_stats(struct ib_device *ibdev,
366366
goto done;
367367
}
368368
}
369-
if (rdev->pacing.dbr_pacing)
369+
if (rdev->pacing.dbr_pacing && bnxt_qplib_is_chip_gen_p5_p7(rdev->chip_ctx))
370370
bnxt_re_copy_db_pacing_stats(rdev, stats);
371371
}
372372

drivers/infiniband/hw/bnxt_re/ib_verbs.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1307,7 +1307,11 @@ static int bnxt_re_init_sq_attr(struct bnxt_re_qp *qp,
13071307
0 : BNXT_QPLIB_RESERVED_QP_WRS;
13081308
entries = bnxt_re_init_depth(entries + diff + 1, uctx);
13091309
sq->max_wqe = min_t(u32, entries, dev_attr->max_qp_wqes + diff + 1);
1310-
sq->max_sw_wqe = bnxt_qplib_get_depth(sq, qplqp->wqe_mode, true);
1310+
if (qplqp->wqe_mode == BNXT_QPLIB_WQE_MODE_VARIABLE)
1311+
sq->max_sw_wqe = bnxt_qplib_get_depth(sq, qplqp->wqe_mode, true);
1312+
else
1313+
sq->max_sw_wqe = sq->max_wqe;
1314+
13111315
}
13121316
sq->q_full_delta = diff + 1;
13131317
/*

drivers/infiniband/hw/bnxt_re/main.c

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,11 @@ static int bnxt_re_setup_chip_ctx(struct bnxt_re_dev *rdev)
188188

189189
bnxt_re_set_db_offset(rdev);
190190
rc = bnxt_qplib_map_db_bar(&rdev->qplib_res);
191-
if (rc)
191+
if (rc) {
192+
kfree(rdev->chip_ctx);
193+
rdev->chip_ctx = NULL;
192194
return rc;
195+
}
193196

194197
if (bnxt_qplib_determine_atomics(en_dev->pdev))
195198
ibdev_info(&rdev->ibdev,
@@ -531,6 +534,7 @@ static bool is_dbr_fifo_full(struct bnxt_re_dev *rdev)
531534
static void __wait_for_fifo_occupancy_below_th(struct bnxt_re_dev *rdev)
532535
{
533536
struct bnxt_qplib_db_pacing_data *pacing_data = rdev->qplib_res.pacing_data;
537+
u32 retry_fifo_check = 1000;
534538
u32 fifo_occup;
535539

536540
/* loop shouldn't run infintely as the occupancy usually goes
@@ -544,6 +548,14 @@ static void __wait_for_fifo_occupancy_below_th(struct bnxt_re_dev *rdev)
544548

545549
if (fifo_occup < pacing_data->pacing_th)
546550
break;
551+
if (!retry_fifo_check--) {
552+
dev_info_once(rdev_to_dev(rdev),
553+
"%s: fifo_occup = 0x%xfifo_max_depth = 0x%x pacing_th = 0x%x\n",
554+
__func__, fifo_occup, pacing_data->fifo_max_depth,
555+
pacing_data->pacing_th);
556+
break;
557+
}
558+
547559
}
548560
}
549561

@@ -957,7 +969,7 @@ static int bnxt_re_register_ib(struct bnxt_re_dev *rdev)
957969
return ib_register_device(ibdev, "bnxt_re%d", &rdev->en_dev->pdev->dev);
958970
}
959971

960-
static struct bnxt_re_dev *bnxt_re_dev_add(struct bnxt_aux_priv *aux_priv,
972+
static struct bnxt_re_dev *bnxt_re_dev_add(struct auxiliary_device *adev,
961973
struct bnxt_en_dev *en_dev)
962974
{
963975
struct bnxt_re_dev *rdev;
@@ -973,6 +985,7 @@ static struct bnxt_re_dev *bnxt_re_dev_add(struct bnxt_aux_priv *aux_priv,
973985
rdev->nb.notifier_call = NULL;
974986
rdev->netdev = en_dev->net;
975987
rdev->en_dev = en_dev;
988+
rdev->adev = adev;
976989
rdev->id = rdev->en_dev->pdev->devfn;
977990
INIT_LIST_HEAD(&rdev->qp_list);
978991
mutex_init(&rdev->qp_lock);
@@ -1025,12 +1038,15 @@ static int bnxt_re_handle_unaffi_async_event(struct creq_func_event
10251038
static int bnxt_re_handle_qp_async_event(struct creq_qp_event *qp_event,
10261039
struct bnxt_re_qp *qp)
10271040
{
1028-
struct bnxt_re_srq *srq = container_of(qp->qplib_qp.srq, struct bnxt_re_srq,
1029-
qplib_srq);
10301041
struct creq_qp_error_notification *err_event;
1042+
struct bnxt_re_srq *srq = NULL;
10311043
struct ib_event event = {};
10321044
unsigned int flags;
10331045

1046+
if (qp->qplib_qp.srq)
1047+
srq = container_of(qp->qplib_qp.srq, struct bnxt_re_srq,
1048+
qplib_srq);
1049+
10341050
if (qp->qplib_qp.state == CMDQ_MODIFY_QP_NEW_STATE_ERR &&
10351051
rdma_is_kernel_res(&qp->ib_qp.res)) {
10361052
flags = bnxt_re_lock_cqs(qp);
@@ -1258,15 +1274,9 @@ static int bnxt_re_cqn_handler(struct bnxt_qplib_nq *nq,
12581274
{
12591275
struct bnxt_re_cq *cq = container_of(handle, struct bnxt_re_cq,
12601276
qplib_cq);
1261-
u32 *cq_ptr;
12621277

1263-
if (cq->ib_cq.comp_handler) {
1264-
if (cq->uctx_cq_page) {
1265-
cq_ptr = (u32 *)cq->uctx_cq_page;
1266-
*cq_ptr = cq->qplib_cq.toggle;
1267-
}
1278+
if (cq->ib_cq.comp_handler)
12681279
(*cq->ib_cq.comp_handler)(&cq->ib_cq, cq->ib_cq.cq_context);
1269-
}
12701280

12711281
return 0;
12721282
}
@@ -1823,7 +1833,6 @@ static void bnxt_re_update_en_info_rdev(struct bnxt_re_dev *rdev,
18231833
*/
18241834
rtnl_lock();
18251835
en_info->rdev = rdev;
1826-
rdev->adev = adev;
18271836
rtnl_unlock();
18281837
}
18291838

@@ -1840,7 +1849,7 @@ static int bnxt_re_add_device(struct auxiliary_device *adev, u8 op_type)
18401849
en_dev = en_info->en_dev;
18411850

18421851

1843-
rdev = bnxt_re_dev_add(aux_priv, en_dev);
1852+
rdev = bnxt_re_dev_add(adev, en_dev);
18441853
if (!rdev || !rdev_to_dev(rdev)) {
18451854
rc = -ENOMEM;
18461855
goto exit;
@@ -1865,12 +1874,14 @@ static int bnxt_re_add_device(struct auxiliary_device *adev, u8 op_type)
18651874
rdev->nb.notifier_call = NULL;
18661875
pr_err("%s: Cannot register to netdevice_notifier",
18671876
ROCE_DRV_MODULE_NAME);
1868-
return rc;
1877+
goto re_dev_unreg;
18691878
}
18701879
bnxt_re_setup_cc(rdev, true);
18711880

18721881
return 0;
18731882

1883+
re_dev_unreg:
1884+
ib_unregister_device(&rdev->ibdev);
18741885
re_dev_uninit:
18751886
bnxt_re_update_en_info_rdev(NULL, en_info, adev);
18761887
bnxt_re_dev_uninit(rdev, BNXT_RE_COMPLETE_REMOVE);
@@ -2014,15 +2025,7 @@ static int bnxt_re_probe(struct auxiliary_device *adev,
20142025
auxiliary_set_drvdata(adev, en_info);
20152026

20162027
rc = bnxt_re_add_device(adev, BNXT_RE_COMPLETE_INIT);
2017-
if (rc)
2018-
goto err;
20192028
mutex_unlock(&bnxt_re_mutex);
2020-
return 0;
2021-
2022-
err:
2023-
mutex_unlock(&bnxt_re_mutex);
2024-
bnxt_re_remove(adev);
2025-
20262029
return rc;
20272030
}
20282031

drivers/infiniband/hw/bnxt_re/qplib_fp.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ static void bnxt_qplib_service_nq(struct tasklet_struct *t)
327327
case NQ_BASE_TYPE_CQ_NOTIFICATION:
328328
{
329329
struct nq_cn *nqcne = (struct nq_cn *)nqe;
330+
struct bnxt_re_cq *cq_p;
330331

331332
q_handle = le32_to_cpu(nqcne->cq_handle_low);
332333
q_handle |= (u64)le32_to_cpu(nqcne->cq_handle_high)
@@ -337,6 +338,10 @@ static void bnxt_qplib_service_nq(struct tasklet_struct *t)
337338
cq->toggle = (le16_to_cpu(nqe->info10_type) &
338339
NQ_CN_TOGGLE_MASK) >> NQ_CN_TOGGLE_SFT;
339340
cq->dbinfo.toggle = cq->toggle;
341+
cq_p = container_of(cq, struct bnxt_re_cq, qplib_cq);
342+
if (cq_p->uctx_cq_page)
343+
*((u32 *)cq_p->uctx_cq_page) = cq->toggle;
344+
340345
bnxt_qplib_armen_db(&cq->dbinfo,
341346
DBC_DBC_TYPE_CQ_ARMENA);
342347
spin_lock_bh(&cq->compl_lock);

drivers/infiniband/hw/bnxt_re/qplib_fp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ struct bnxt_qplib_swqe {
170170
};
171171
u32 q_key;
172172
u32 dst_qp;
173-
u16 avid;
173+
u32 avid;
174174
} send;
175175

176176
/* Send Raw Ethernet and QP1 */

drivers/infiniband/hw/bnxt_re/qplib_rcfw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ static int __bnxt_qplib_rcfw_send_message(struct bnxt_qplib_rcfw *rcfw,
525525
/* failed with status */
526526
dev_err(&rcfw->pdev->dev, "cmdq[%#x]=%#x status %#x\n",
527527
cookie, opcode, evnt->status);
528-
rc = -EFAULT;
528+
rc = -EIO;
529529
}
530530

531531
return rc;

drivers/infiniband/hw/bnxt_re/qplib_res.c

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ int bnxt_qplib_alloc_init_hwq(struct bnxt_qplib_hwq *hwq,
244244
sginfo.pgsize = npde * pg_size;
245245
sginfo.npages = 1;
246246
rc = __alloc_pbl(res, &hwq->pbl[PBL_LVL_0], &sginfo);
247+
if (rc)
248+
goto fail;
247249

248250
/* Alloc PBL pages */
249251
sginfo.npages = npbl;
@@ -255,22 +257,9 @@ int bnxt_qplib_alloc_init_hwq(struct bnxt_qplib_hwq *hwq,
255257
dst_virt_ptr =
256258
(dma_addr_t **)hwq->pbl[PBL_LVL_0].pg_arr;
257259
src_phys_ptr = hwq->pbl[PBL_LVL_1].pg_map_arr;
258-
if (hwq_attr->type == HWQ_TYPE_MR) {
259-
/* For MR it is expected that we supply only 1 contigous
260-
* page i.e only 1 entry in the PDL that will contain
261-
* all the PBLs for the user supplied memory region
262-
*/
263-
for (i = 0; i < hwq->pbl[PBL_LVL_1].pg_count;
264-
i++)
265-
dst_virt_ptr[0][i] = src_phys_ptr[i] |
266-
flag;
267-
} else {
268-
for (i = 0; i < hwq->pbl[PBL_LVL_1].pg_count;
269-
i++)
270-
dst_virt_ptr[PTR_PG(i)][PTR_IDX(i)] =
271-
src_phys_ptr[i] |
272-
PTU_PDE_VALID;
273-
}
260+
for (i = 0; i < hwq->pbl[PBL_LVL_1].pg_count; i++)
261+
dst_virt_ptr[0][i] = src_phys_ptr[i] | flag;
262+
274263
/* Alloc or init PTEs */
275264
rc = __alloc_pbl(res, &hwq->pbl[PBL_LVL_2],
276265
hwq_attr->sginfo);

drivers/infiniband/hw/bnxt_re/qplib_sp.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ int bnxt_qplib_get_dev_attr(struct bnxt_qplib_rcfw *rcfw,
140140
min_t(u32, sb->max_sge_var_wqe, BNXT_VAR_MAX_SGE) : 6;
141141
attr->max_cq = le32_to_cpu(sb->max_cq);
142142
attr->max_cq_wqes = le32_to_cpu(sb->max_cqe);
143+
if (!bnxt_qplib_is_chip_gen_p7(rcfw->res->cctx))
144+
attr->max_cq_wqes = min_t(u32, BNXT_QPLIB_MAX_CQ_WQES, attr->max_cq_wqes);
143145
attr->max_cq_sges = attr->max_qp_sges;
144146
attr->max_mr = le32_to_cpu(sb->max_mr);
145147
attr->max_mw = le32_to_cpu(sb->max_mw);
@@ -157,7 +159,14 @@ int bnxt_qplib_get_dev_attr(struct bnxt_qplib_rcfw *rcfw,
157159
if (!bnxt_qplib_is_chip_gen_p7(rcfw->res->cctx))
158160
attr->l2_db_size = (sb->l2_db_space_size + 1) *
159161
(0x01 << RCFW_DBR_BASE_PAGE_SHIFT);
160-
attr->max_sgid = BNXT_QPLIB_NUM_GIDS_SUPPORTED;
162+
/*
163+
* Read the max gid supported by HW.
164+
* For each entry in HW GID in HW table, we consume 2
165+
* GID entries in the kernel GID table. So max_gid reported
166+
* to stack can be up to twice the value reported by the HW, up to 256 gids.
167+
*/
168+
attr->max_sgid = le32_to_cpu(sb->max_gid);
169+
attr->max_sgid = min_t(u32, BNXT_QPLIB_NUM_GIDS_SUPPORTED, 2 * attr->max_sgid);
161170
attr->dev_cap_flags = le16_to_cpu(sb->dev_cap_flags);
162171
attr->dev_cap_flags2 = le16_to_cpu(sb->dev_cap_ext_flags_2);
163172

drivers/infiniband/hw/bnxt_re/qplib_sp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ struct bnxt_qplib_dev_attr {
5656
u32 max_qp_wqes;
5757
u32 max_qp_sges;
5858
u32 max_cq;
59+
#define BNXT_QPLIB_MAX_CQ_WQES 0xfffff
5960
u32 max_cq_wqes;
6061
u32 max_cq_sges;
6162
u32 max_mr;

drivers/infiniband/hw/cxgb4/cm.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2086,7 +2086,7 @@ static int import_ep(struct c4iw_ep *ep, int iptype, __u8 *peer_ip,
20862086
err = -ENOMEM;
20872087
if (n->dev->flags & IFF_LOOPBACK) {
20882088
if (iptype == 4)
2089-
pdev = ip_dev_find(&init_net, *(__be32 *)peer_ip);
2089+
pdev = __ip_dev_find(&init_net, *(__be32 *)peer_ip, false);
20902090
else if (IS_ENABLED(CONFIG_IPV6))
20912091
for_each_netdev(&init_net, pdev) {
20922092
if (ipv6_chk_addr(&init_net,
@@ -2101,12 +2101,12 @@ static int import_ep(struct c4iw_ep *ep, int iptype, __u8 *peer_ip,
21012101
err = -ENODEV;
21022102
goto out;
21032103
}
2104+
if (is_vlan_dev(pdev))
2105+
pdev = vlan_dev_real_dev(pdev);
21042106
ep->l2t = cxgb4_l2t_get(cdev->rdev.lldi.l2t,
21052107
n, pdev, rt_tos2priority(tos));
2106-
if (!ep->l2t) {
2107-
dev_put(pdev);
2108+
if (!ep->l2t)
21082109
goto out;
2109-
}
21102110
ep->mtu = pdev->mtu;
21112111
ep->tx_chan = cxgb4_port_chan(pdev);
21122112
ep->smac_idx = ((struct port_info *)netdev_priv(pdev))->smt_idx;
@@ -2119,7 +2119,6 @@ static int import_ep(struct c4iw_ep *ep, int iptype, __u8 *peer_ip,
21192119
ep->rss_qid = cdev->rdev.lldi.rxq_ids[
21202120
cxgb4_port_idx(pdev) * step];
21212121
set_tcp_window(ep, (struct port_info *)netdev_priv(pdev));
2122-
dev_put(pdev);
21232122
} else {
21242123
pdev = get_real_dev(n->dev);
21252124
ep->l2t = cxgb4_l2t_get(cdev->rdev.lldi.l2t,

drivers/infiniband/hw/irdma/cm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3631,7 +3631,7 @@ void irdma_free_lsmm_rsrc(struct irdma_qp *iwqp)
36313631
/**
36323632
* irdma_accept - registered call for connection to be accepted
36333633
* @cm_id: cm information for passive connection
3634-
* @conn_param: accpet parameters
3634+
* @conn_param: accept parameters
36353635
*/
36363636
int irdma_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
36373637
{

drivers/infiniband/sw/siw/siw_qp_tx.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,8 @@ static int siw_tcp_sendpages(struct socket *s, struct page **page, int offset,
331331
msg.msg_flags &= ~MSG_MORE;
332332

333333
tcp_rate_check_app_limited(sk);
334+
if (!sendpage_ok(page[i]))
335+
msg.msg_flags &= ~MSG_SPLICE_PAGES;
334336
bvec_set_page(&bvec, page[i], bytes, offset);
335337
iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, size);
336338

0 commit comments

Comments
 (0)