Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma

Pull rdma fixes from Jason Gunthorpe:
"Mostly irdma and bnxt_re fixes:

- Missing error unwind in hf1

- For bnxt - fix fenching behavior to work on new chips, fail
unsupported SRQ resize back to userspace, propogate SRQ FW failure
back to userspace.

- Correctly fail unsupported SRQ resize back to userspace in bnxt

- Adjust a memcpy in mlx5 to not overflow a struct field.

- Prevent userspace from triggering mlx5 fw syndrome logging from
sysfs

- Use the correct access mode for MLX5_IB_METHOD_DEVX_OBJ_MODIFY to
avoid a userspace failure on modify

- For irdma - Don't UAF a concurrent tasklet during destroy, prevent
userspace from issuing invalid QP attrs, fix a possible CQ
overflow, capture a missing HW async error event

- sendmsg() triggerable memory access crash in hfi1

- Fix the srpt_service_guid parameter to not crash due to missing
function pointer

- Don't leak objects in error unwind in qedr

- Don't weirdly cast function pointers in srpt"

* tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma:
RDMA/srpt: fix function pointer cast warnings
RDMA/qedr: Fix qedr_create_user_qp error flow
RDMA/srpt: Support specifying the srpt_service_guid parameter
IB/hfi1: Fix sdma.h tx->num_descs off-by-one error
RDMA/irdma: Add AE for too many RNRS
RDMA/irdma: Set the CQ read threshold for GEN 1
RDMA/irdma: Validate max_send_wr and max_recv_wr
RDMA/irdma: Fix KASAN issue with tasklet
RDMA/mlx5: Relax DEVX access upon modify commands
IB/mlx5: Don't expose debugfs entries for RRoCE general parameters if not supported
RDMA/mlx5: Fix fortify source warning while accessing Eth segment
RDMA/bnxt_re: Add a missing check in bnxt_qplib_query_srq
RDMA/bnxt_re: Return error for SRQ resize
RDMA/bnxt_re: Fix unconditional fence for newer adapters
RDMA/bnxt_re: Remove a redundant check inside bnxt_re_vf_res_config
RDMA/bnxt_re: Avoid creating fence MR for newer adapters
IB/hfi1: Fix a memleak in init_credit_return

+84 -36
+28 -15
drivers/infiniband/hw/bnxt_re/ib_verbs.c
··· 401 401 struct bnxt_re_fence_data *fence = &pd->fence; 402 402 struct ib_mr *ib_mr = &fence->mr->ib_mr; 403 403 struct bnxt_qplib_swqe *wqe = &fence->bind_wqe; 404 + struct bnxt_re_dev *rdev = pd->rdev; 405 + 406 + if (bnxt_qplib_is_chip_gen_p5_p7(rdev->chip_ctx)) 407 + return; 404 408 405 409 memset(wqe, 0, sizeof(*wqe)); 406 410 wqe->type = BNXT_QPLIB_SWQE_TYPE_BIND_MW; ··· 459 455 struct device *dev = &rdev->en_dev->pdev->dev; 460 456 struct bnxt_re_mr *mr = fence->mr; 461 457 458 + if (bnxt_qplib_is_chip_gen_p5_p7(rdev->chip_ctx)) 459 + return; 460 + 462 461 if (fence->mw) { 463 462 bnxt_re_dealloc_mw(fence->mw); 464 463 fence->mw = NULL; ··· 492 485 dma_addr_t dma_addr = 0; 493 486 struct ib_mw *mw; 494 487 int rc; 488 + 489 + if (bnxt_qplib_is_chip_gen_p5_p7(rdev->chip_ctx)) 490 + return 0; 495 491 496 492 dma_addr = dma_map_single(dev, fence->va, BNXT_RE_FENCE_BYTES, 497 493 DMA_BIDIRECTIONAL); ··· 1827 1817 switch (srq_attr_mask) { 1828 1818 case IB_SRQ_MAX_WR: 1829 1819 /* SRQ resize is not supported */ 1830 - break; 1820 + return -EINVAL; 1831 1821 case IB_SRQ_LIMIT: 1832 1822 /* Change the SRQ threshold */ 1833 1823 if (srq_attr->srq_limit > srq->qplib_srq.max_wqe) ··· 1842 1832 /* On success, update the shadow */ 1843 1833 srq->srq_limit = srq_attr->srq_limit; 1844 1834 /* No need to Build and send response back to udata */ 1845 - break; 1835 + return 0; 1846 1836 default: 1847 1837 ibdev_err(&rdev->ibdev, 1848 1838 "Unsupported srq_attr_mask 0x%x", srq_attr_mask); 1849 1839 return -EINVAL; 1850 1840 } 1851 - return 0; 1852 1841 } 1853 1842 1854 1843 int bnxt_re_query_srq(struct ib_srq *ib_srq, struct ib_srq_attr *srq_attr) ··· 2565 2556 wqe->type = BNXT_QPLIB_SWQE_TYPE_LOCAL_INV; 2566 2557 wqe->local_inv.inv_l_key = wr->ex.invalidate_rkey; 2567 2558 2568 - /* Need unconditional fence for local invalidate 2569 - * opcode to work as expected. 2570 - */ 2571 - wqe->flags |= BNXT_QPLIB_SWQE_FLAGS_UC_FENCE; 2572 - 2573 2559 if (wr->send_flags & IB_SEND_SIGNALED) 2574 2560 wqe->flags |= BNXT_QPLIB_SWQE_FLAGS_SIGNAL_COMP; 2575 2561 if (wr->send_flags & IB_SEND_SOLICITED) ··· 2586 2582 wqe->frmr.page_list_len = mr->npages; 2587 2583 wqe->frmr.levels = qplib_frpl->hwq.level; 2588 2584 wqe->type = BNXT_QPLIB_SWQE_TYPE_REG_MR; 2589 - 2590 - /* Need unconditional fence for reg_mr 2591 - * opcode to function as expected. 2592 - */ 2593 - 2594 - wqe->flags |= BNXT_QPLIB_SWQE_FLAGS_UC_FENCE; 2595 2585 2596 2586 if (wr->wr.send_flags & IB_SEND_SIGNALED) 2597 2587 wqe->flags |= BNXT_QPLIB_SWQE_FLAGS_SIGNAL_COMP; ··· 2717 2719 return rc; 2718 2720 } 2719 2721 2722 + static void bnxt_re_legacy_set_uc_fence(struct bnxt_qplib_swqe *wqe) 2723 + { 2724 + /* Need unconditional fence for non-wire memory opcode 2725 + * to work as expected. 2726 + */ 2727 + if (wqe->type == BNXT_QPLIB_SWQE_TYPE_LOCAL_INV || 2728 + wqe->type == BNXT_QPLIB_SWQE_TYPE_FAST_REG_MR || 2729 + wqe->type == BNXT_QPLIB_SWQE_TYPE_REG_MR || 2730 + wqe->type == BNXT_QPLIB_SWQE_TYPE_BIND_MW) 2731 + wqe->flags |= BNXT_QPLIB_SWQE_FLAGS_UC_FENCE; 2732 + } 2733 + 2720 2734 int bnxt_re_post_send(struct ib_qp *ib_qp, const struct ib_send_wr *wr, 2721 2735 const struct ib_send_wr **bad_wr) 2722 2736 { ··· 2808 2798 rc = -EINVAL; 2809 2799 goto bad; 2810 2800 } 2811 - if (!rc) 2801 + if (!rc) { 2802 + if (!bnxt_qplib_is_chip_gen_p5_p7(qp->rdev->chip_ctx)) 2803 + bnxt_re_legacy_set_uc_fence(&wqe); 2812 2804 rc = bnxt_qplib_post_send(&qp->qplib_qp, &wqe); 2805 + } 2813 2806 bad: 2814 2807 if (rc) { 2815 2808 ibdev_err(&qp->rdev->ibdev,
-3
drivers/infiniband/hw/bnxt_re/main.c
··· 280 280 281 281 static void bnxt_re_vf_res_config(struct bnxt_re_dev *rdev) 282 282 { 283 - 284 - if (test_bit(BNXT_RE_FLAG_ERR_DEVICE_DETACHED, &rdev->flags)) 285 - return; 286 283 rdev->num_vfs = pci_sriov_get_totalvfs(rdev->en_dev->pdev); 287 284 if (!bnxt_qplib_is_chip_gen_p5_p7(rdev->chip_ctx)) { 288 285 bnxt_re_set_resource_limits(rdev);
+2 -1
drivers/infiniband/hw/bnxt_re/qplib_fp.c
··· 744 744 bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, &sbuf, sizeof(req), 745 745 sizeof(resp), 0); 746 746 rc = bnxt_qplib_rcfw_send_message(rcfw, &msg); 747 - srq->threshold = le16_to_cpu(sb->srq_limit); 747 + if (!rc) 748 + srq->threshold = le16_to_cpu(sb->srq_limit); 748 749 dma_free_coherent(&rcfw->pdev->dev, sbuf.size, 749 750 sbuf.sb, sbuf.dma_addr); 750 751
+5 -1
drivers/infiniband/hw/hfi1/pio.c
··· 2086 2086 "Unable to allocate credit return DMA range for NUMA %d\n", 2087 2087 i); 2088 2088 ret = -ENOMEM; 2089 - goto done; 2089 + goto free_cr_base; 2090 2090 } 2091 2091 } 2092 2092 set_dev_node(&dd->pcidev->dev, dd->node); ··· 2094 2094 ret = 0; 2095 2095 done: 2096 2096 return ret; 2097 + 2098 + free_cr_base: 2099 + free_credit_return(dd); 2100 + goto done; 2097 2101 } 2098 2102 2099 2103 void free_credit_return(struct hfi1_devdata *dd)
+1 -1
drivers/infiniband/hw/hfi1/sdma.c
··· 3158 3158 { 3159 3159 int rval = 0; 3160 3160 3161 - if ((unlikely(tx->num_desc + 1 == tx->desc_limit))) { 3161 + if ((unlikely(tx->num_desc == tx->desc_limit))) { 3162 3162 rval = _extend_sdma_tx_descs(dd, tx); 3163 3163 if (rval) { 3164 3164 __sdma_txclean(dd, tx);
+1
drivers/infiniband/hw/irdma/defs.h
··· 346 346 #define IRDMA_AE_LLP_TOO_MANY_KEEPALIVE_RETRIES 0x050b 347 347 #define IRDMA_AE_LLP_DOUBT_REACHABILITY 0x050c 348 348 #define IRDMA_AE_LLP_CONNECTION_ESTABLISHED 0x050e 349 + #define IRDMA_AE_LLP_TOO_MANY_RNRS 0x050f 349 350 #define IRDMA_AE_RESOURCE_EXHAUSTION 0x0520 350 351 #define IRDMA_AE_RESET_SENT 0x0601 351 352 #define IRDMA_AE_TERMINATE_SENT 0x0602
+8
drivers/infiniband/hw/irdma/hw.c
··· 387 387 case IRDMA_AE_LLP_TOO_MANY_RETRIES: 388 388 case IRDMA_AE_LCE_QP_CATASTROPHIC: 389 389 case IRDMA_AE_LCE_FUNCTION_CATASTROPHIC: 390 + case IRDMA_AE_LLP_TOO_MANY_RNRS: 390 391 case IRDMA_AE_LCE_CQ_CATASTROPHIC: 391 392 case IRDMA_AE_UDA_XMIT_DGRAM_TOO_LONG: 392 393 default: ··· 571 570 dev->irq_ops->irdma_dis_irq(dev, msix_vec->idx); 572 571 irq_update_affinity_hint(msix_vec->irq, NULL); 573 572 free_irq(msix_vec->irq, dev_id); 573 + if (rf == dev_id) { 574 + tasklet_kill(&rf->dpc_tasklet); 575 + } else { 576 + struct irdma_ceq *iwceq = (struct irdma_ceq *)dev_id; 577 + 578 + tasklet_kill(&iwceq->dpc_tasklet); 579 + } 574 580 } 575 581 576 582 /**
+5 -4
drivers/infiniband/hw/irdma/verbs.c
··· 839 839 840 840 if (init_attr->cap.max_inline_data > uk_attrs->max_hw_inline || 841 841 init_attr->cap.max_send_sge > uk_attrs->max_hw_wq_frags || 842 - init_attr->cap.max_recv_sge > uk_attrs->max_hw_wq_frags) 842 + init_attr->cap.max_recv_sge > uk_attrs->max_hw_wq_frags || 843 + init_attr->cap.max_send_wr > uk_attrs->max_hw_wq_quanta || 844 + init_attr->cap.max_recv_wr > uk_attrs->max_hw_rq_quanta) 843 845 return -EINVAL; 844 846 845 847 if (rdma_protocol_roce(&iwdev->ibdev, 1)) { ··· 2186 2184 info.cq_base_pa = iwcq->kmem.pa; 2187 2185 } 2188 2186 2189 - if (dev->hw_attrs.uk_attrs.hw_rev >= IRDMA_GEN_2) 2190 - info.shadow_read_threshold = min(info.cq_uk_init_info.cq_size / 2, 2191 - (u32)IRDMA_MAX_CQ_READ_THRESH); 2187 + info.shadow_read_threshold = min(info.cq_uk_init_info.cq_size / 2, 2188 + (u32)IRDMA_MAX_CQ_READ_THRESH); 2192 2189 2193 2190 if (irdma_sc_cq_init(cq, &info)) { 2194 2191 ibdev_dbg(&iwdev->ibdev, "VERBS: init cq fail\n");
+6
drivers/infiniband/hw/mlx5/cong.c
··· 458 458 dbg_cc_params->root = debugfs_create_dir("cc_params", mlx5_debugfs_get_dev_root(mdev)); 459 459 460 460 for (i = 0; i < MLX5_IB_DBG_CC_MAX; i++) { 461 + if ((i == MLX5_IB_DBG_CC_GENERAL_RTT_RESP_DSCP_VALID || 462 + i == MLX5_IB_DBG_CC_GENERAL_RTT_RESP_DSCP)) 463 + if (!MLX5_CAP_GEN(mdev, roce) || 464 + !MLX5_CAP_ROCE(mdev, roce_cc_general)) 465 + continue; 466 + 461 467 dbg_cc_params->params[i].offset = i; 462 468 dbg_cc_params->params[i].dev = dev; 463 469 dbg_cc_params->params[i].port_num = port_num;
+1 -1
drivers/infiniband/hw/mlx5/devx.c
··· 2949 2949 MLX5_IB_METHOD_DEVX_OBJ_MODIFY, 2950 2950 UVERBS_ATTR_IDR(MLX5_IB_ATTR_DEVX_OBJ_MODIFY_HANDLE, 2951 2951 UVERBS_IDR_ANY_OBJECT, 2952 - UVERBS_ACCESS_WRITE, 2952 + UVERBS_ACCESS_READ, 2953 2953 UA_MANDATORY), 2954 2954 UVERBS_ATTR_PTR_IN( 2955 2955 MLX5_IB_ATTR_DEVX_OBJ_MODIFY_CMD_IN,
+1 -1
drivers/infiniband/hw/mlx5/wr.c
··· 78 78 */ 79 79 copysz = min_t(u64, *cur_edge - (void *)eseg->inline_hdr.start, 80 80 left); 81 - memcpy(eseg->inline_hdr.start, pdata, copysz); 81 + memcpy(eseg->inline_hdr.data, pdata, copysz); 82 82 stride = ALIGN(sizeof(struct mlx5_wqe_eth_seg) - 83 83 sizeof(eseg->inline_hdr.start) + copysz, 16); 84 84 *size += stride / 16;
+10 -1
drivers/infiniband/hw/qedr/verbs.c
··· 1879 1879 /* RQ - read access only (0) */ 1880 1880 rc = qedr_init_user_queue(udata, dev, &qp->urq, ureq.rq_addr, 1881 1881 ureq.rq_len, true, 0, alloc_and_init); 1882 - if (rc) 1882 + if (rc) { 1883 + ib_umem_release(qp->usq.umem); 1884 + qp->usq.umem = NULL; 1885 + if (rdma_protocol_roce(&dev->ibdev, 1)) { 1886 + qedr_free_pbl(dev, &qp->usq.pbl_info, 1887 + qp->usq.pbl_tbl); 1888 + } else { 1889 + kfree(qp->usq.pbl_tbl); 1890 + } 1883 1891 return rc; 1892 + } 1884 1893 } 1885 1894 1886 1895 memset(&in_params, 0, sizeof(in_params));
+11 -6
drivers/infiniband/ulp/srpt/ib_srpt.c
··· 79 79 MODULE_PARM_DESC(srpt_srq_size, 80 80 "Shared receive queue (SRQ) size."); 81 81 82 + static int srpt_set_u64_x(const char *buffer, const struct kernel_param *kp) 83 + { 84 + return kstrtou64(buffer, 16, (u64 *)kp->arg); 85 + } 82 86 static int srpt_get_u64_x(char *buffer, const struct kernel_param *kp) 83 87 { 84 88 return sprintf(buffer, "0x%016llx\n", *(u64 *)kp->arg); 85 89 } 86 - module_param_call(srpt_service_guid, NULL, srpt_get_u64_x, &srpt_service_guid, 87 - 0444); 90 + module_param_call(srpt_service_guid, srpt_set_u64_x, srpt_get_u64_x, 91 + &srpt_service_guid, 0444); 88 92 MODULE_PARM_DESC(srpt_service_guid, 89 93 "Using this value for ioc_guid, id_ext, and cm_listen_id instead of using the node_guid of the first HCA."); 90 94 ··· 214 210 /** 215 211 * srpt_qp_event - QP event callback function 216 212 * @event: Description of the event that occurred. 217 - * @ch: SRPT RDMA channel. 213 + * @ptr: SRPT RDMA channel. 218 214 */ 219 - static void srpt_qp_event(struct ib_event *event, struct srpt_rdma_ch *ch) 215 + static void srpt_qp_event(struct ib_event *event, void *ptr) 220 216 { 217 + struct srpt_rdma_ch *ch = ptr; 218 + 221 219 pr_debug("QP event %d on ch=%p sess_name=%s-%d state=%s\n", 222 220 event->event, ch, ch->sess_name, ch->qp->qp_num, 223 221 get_ch_state_name(ch->state)); ··· 1813 1807 ch->cq_size = ch->rq_size + sq_size; 1814 1808 1815 1809 qp_init->qp_context = (void *)ch; 1816 - qp_init->event_handler 1817 - = (void(*)(struct ib_event *, void*))srpt_qp_event; 1810 + qp_init->event_handler = srpt_qp_event; 1818 1811 qp_init->send_cq = ch->cq; 1819 1812 qp_init->recv_cq = ch->cq; 1820 1813 qp_init->sq_sig_type = IB_SIGNAL_REQ_WR;
+1 -1
include/linux/mlx5/mlx5_ifc.h
··· 1103 1103 u8 sw_r_roce_src_udp_port[0x1]; 1104 1104 u8 fl_rc_qp_when_roce_disabled[0x1]; 1105 1105 u8 fl_rc_qp_when_roce_enabled[0x1]; 1106 - u8 reserved_at_7[0x1]; 1106 + u8 roce_cc_general[0x1]; 1107 1107 u8 qp_ooo_transmit_default[0x1]; 1108 1108 u8 reserved_at_9[0x15]; 1109 1109 u8 qp_ts_format[0x2];
+4 -1
include/linux/mlx5/qp.h
··· 269 269 union { 270 270 struct { 271 271 __be16 sz; 272 - u8 start[2]; 272 + union { 273 + u8 start[2]; 274 + DECLARE_FLEX_ARRAY(u8, data); 275 + }; 273 276 } inline_hdr; 274 277 struct { 275 278 __be16 type;