Skip to content

Commit 884fe9d

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: - Fix 64K ARM page size support in bnxt_re and efa - bnxt_re fixes for a memory leak, incorrect error handling and a remove a bogus FW failure when running on a VF - Update MAINTAINERS for hns and efa - Fix two rxe regressions added this merge window in error unwind and incorrect spinlock primitives - hns gets a better algorithm for allocating page tables to avoid running out of resources, and a timeout adjustment - Fix a text case failure in hns - Use after free in irdma and fix incorrect construction of a WQE causing mis-execution * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma: RDMA/irdma: Fix Local Invalidate fencing RDMA/irdma: Prevent QP use after free MAINTAINERS: Update maintainer of Amazon EFA driver RDMA/bnxt_re: Do not enable congestion control on VFs RDMA/bnxt_re: Fix return value of bnxt_re_process_raw_qp_pkt_rx RDMA/bnxt_re: Fix a possible memory leak RDMA/hns: Modify the value of long message loopback slice RDMA/hns: Fix base address table allocation RDMA/hns: Fix timeout attr in query qp for HIP08 RDMA/efa: Fix unsupported page sizes in device RDMA/rxe: Convert spin_{lock_bh,unlock_bh} to spin_{lock_irqsave,unlock_irqrestore} RDMA/rxe: Fix double unlock in rxe_qp.c MAINTAINERS: Update maintainers of HiSilicon RoCE RDMA/bnxt_re: Fix the page_size used during the MR creation
2 parents fd2186d + 5842d1d commit 884fe9d

File tree

18 files changed

+176
-99
lines changed

18 files changed

+176
-99
lines changed

MAINTAINERS

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,8 @@ F: Documentation/networking/device_drivers/ethernet/amazon/ena.rst
956956
F: drivers/net/ethernet/amazon/
957957

958958
AMAZON RDMA EFA DRIVER
959-
M: Gal Pressman <galpress@amazon.com>
959+
M: Michael Margolin <mrgolin@amazon.com>
960+
R: Gal Pressman <gal.pressman@linux.dev>
960961
R: Yossi Leybovich <sleybo@amazon.com>
961962
L: linux-rdma@vger.kernel.org
962963
S: Supported
@@ -9343,7 +9344,7 @@ F: include/linux/hisi_acc_qm.h
93439344

93449345
HISILICON ROCE DRIVER
93459346
M: Haoyue Xu <xuhaoyue1@hisilicon.com>
9346-
M: Wenpeng Liang <liangwenpeng@huawei.com>
9347+
M: Junxian Huang <huangjunxian6@hisilicon.com>
93479348
L: linux-rdma@vger.kernel.org
93489349
S: Maintained
93499350
F: Documentation/devicetree/bindings/infiniband/hisilicon-hns-roce.txt

drivers/infiniband/hw/bnxt_re/ib_verbs.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3341,9 +3341,7 @@ static int bnxt_re_process_raw_qp_pkt_rx(struct bnxt_re_qp *gsi_qp,
33413341
udwr.remote_qkey = gsi_sqp->qplib_qp.qkey;
33423342

33433343
/* post data received in the send queue */
3344-
rc = bnxt_re_post_send_shadow_qp(rdev, gsi_sqp, swr);
3345-
3346-
return 0;
3344+
return bnxt_re_post_send_shadow_qp(rdev, gsi_sqp, swr);
33473345
}
33483346

33493347
static void bnxt_re_process_res_rawqp1_wc(struct ib_wc *wc,

drivers/infiniband/hw/bnxt_re/main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,6 +1336,10 @@ static void bnxt_re_setup_cc(struct bnxt_re_dev *rdev, bool enable)
13361336
{
13371337
struct bnxt_qplib_cc_param cc_param = {};
13381338

1339+
/* Do not enable congestion control on VFs */
1340+
if (rdev->is_virtfn)
1341+
return;
1342+
13391343
/* Currently enabling only for GenP5 adapters */
13401344
if (!bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx))
13411345
return;

drivers/infiniband/hw/bnxt_re/qplib_fp.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2056,6 +2056,12 @@ int bnxt_qplib_create_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq)
20562056
u32 pg_sz_lvl;
20572057
int rc;
20582058

2059+
if (!cq->dpi) {
2060+
dev_err(&rcfw->pdev->dev,
2061+
"FP: CREATE_CQ failed due to NULL DPI\n");
2062+
return -EINVAL;
2063+
}
2064+
20592065
hwq_attr.res = res;
20602066
hwq_attr.depth = cq->max_wqe;
20612067
hwq_attr.stride = sizeof(struct cq_base);
@@ -2069,11 +2075,6 @@ int bnxt_qplib_create_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq)
20692075
CMDQ_BASE_OPCODE_CREATE_CQ,
20702076
sizeof(req));
20712077

2072-
if (!cq->dpi) {
2073-
dev_err(&rcfw->pdev->dev,
2074-
"FP: CREATE_CQ failed due to NULL DPI\n");
2075-
return -EINVAL;
2076-
}
20772078
req.dpi = cpu_to_le32(cq->dpi->dpi);
20782079
req.cq_handle = cpu_to_le64(cq->cq_handle);
20792080
req.cq_size = cpu_to_le32(cq->hwq.max_elements);

drivers/infiniband/hw/bnxt_re/qplib_res.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -215,17 +215,9 @@ int bnxt_qplib_alloc_init_hwq(struct bnxt_qplib_hwq *hwq,
215215
return -EINVAL;
216216
hwq_attr->sginfo->npages = npages;
217217
} else {
218-
unsigned long sginfo_num_pages = ib_umem_num_dma_blocks(
219-
hwq_attr->sginfo->umem, hwq_attr->sginfo->pgsize);
220-
218+
npages = ib_umem_num_dma_blocks(hwq_attr->sginfo->umem,
219+
hwq_attr->sginfo->pgsize);
221220
hwq->is_user = true;
222-
npages = sginfo_num_pages;
223-
npages = (npages * PAGE_SIZE) /
224-
BIT_ULL(hwq_attr->sginfo->pgshft);
225-
if ((sginfo_num_pages * PAGE_SIZE) %
226-
BIT_ULL(hwq_attr->sginfo->pgshft))
227-
if (!npages)
228-
npages++;
229221
}
230222

231223
if (npages == MAX_PBL_LVL_0_PGS && !hwq_attr->sginfo->nopte) {

drivers/infiniband/hw/bnxt_re/qplib_sp.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -617,16 +617,15 @@ int bnxt_qplib_reg_mr(struct bnxt_qplib_res *res, struct bnxt_qplib_mrw *mr,
617617
/* Free the hwq if it already exist, must be a rereg */
618618
if (mr->hwq.max_elements)
619619
bnxt_qplib_free_hwq(res, &mr->hwq);
620-
/* Use system PAGE_SIZE */
621620
hwq_attr.res = res;
622621
hwq_attr.depth = pages;
623-
hwq_attr.stride = buf_pg_size;
622+
hwq_attr.stride = sizeof(dma_addr_t);
624623
hwq_attr.type = HWQ_TYPE_MR;
625624
hwq_attr.sginfo = &sginfo;
626625
hwq_attr.sginfo->umem = umem;
627626
hwq_attr.sginfo->npages = pages;
628-
hwq_attr.sginfo->pgsize = PAGE_SIZE;
629-
hwq_attr.sginfo->pgshft = PAGE_SHIFT;
627+
hwq_attr.sginfo->pgsize = buf_pg_size;
628+
hwq_attr.sginfo->pgshft = ilog2(buf_pg_size);
630629
rc = bnxt_qplib_alloc_init_hwq(&mr->hwq, &hwq_attr);
631630
if (rc) {
632631
dev_err(&res->pdev->dev,

drivers/infiniband/hw/efa/efa_verbs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1403,7 +1403,7 @@ static int pbl_continuous_initialize(struct efa_dev *dev,
14031403
*/
14041404
static int pbl_indirect_initialize(struct efa_dev *dev, struct pbl_context *pbl)
14051405
{
1406-
u32 size_in_pages = DIV_ROUND_UP(pbl->pbl_buf_size_in_bytes, PAGE_SIZE);
1406+
u32 size_in_pages = DIV_ROUND_UP(pbl->pbl_buf_size_in_bytes, EFA_CHUNK_PAYLOAD_SIZE);
14071407
struct scatterlist *sgl;
14081408
int sg_dma_cnt, err;
14091409

drivers/infiniband/hw/hns/hns_roce_hw_v2.c

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4583,11 +4583,9 @@ static int modify_qp_init_to_rtr(struct ib_qp *ibqp,
45834583
mtu = ib_mtu_enum_to_int(ib_mtu);
45844584
if (WARN_ON(mtu <= 0))
45854585
return -EINVAL;
4586-
#define MAX_LP_MSG_LEN 16384
4587-
/* MTU * (2 ^ LP_PKTN_INI) shouldn't be bigger than 16KB */
4588-
lp_pktn_ini = ilog2(MAX_LP_MSG_LEN / mtu);
4589-
if (WARN_ON(lp_pktn_ini >= 0xF))
4590-
return -EINVAL;
4586+
#define MIN_LP_MSG_LEN 1024
4587+
/* mtu * (2 ^ lp_pktn_ini) should be in the range of 1024 to mtu */
4588+
lp_pktn_ini = ilog2(max(mtu, MIN_LP_MSG_LEN) / mtu);
45914589

45924590
if (attr_mask & IB_QP_PATH_MTU) {
45934591
hr_reg_write(context, QPC_MTU, ib_mtu);
@@ -5012,7 +5010,6 @@ static int hns_roce_v2_set_abs_fields(struct ib_qp *ibqp,
50125010
static bool check_qp_timeout_cfg_range(struct hns_roce_dev *hr_dev, u8 *timeout)
50135011
{
50145012
#define QP_ACK_TIMEOUT_MAX_HIP08 20
5015-
#define QP_ACK_TIMEOUT_OFFSET 10
50165013
#define QP_ACK_TIMEOUT_MAX 31
50175014

50185015
if (hr_dev->pci_dev->revision == PCI_REVISION_ID_HIP08) {
@@ -5021,7 +5018,7 @@ static bool check_qp_timeout_cfg_range(struct hns_roce_dev *hr_dev, u8 *timeout)
50215018
"local ACK timeout shall be 0 to 20.\n");
50225019
return false;
50235020
}
5024-
*timeout += QP_ACK_TIMEOUT_OFFSET;
5021+
*timeout += HNS_ROCE_V2_QP_ACK_TIMEOUT_OFS_HIP08;
50255022
} else if (hr_dev->pci_dev->revision > PCI_REVISION_ID_HIP08) {
50265023
if (*timeout > QP_ACK_TIMEOUT_MAX) {
50275024
ibdev_warn(&hr_dev->ib_dev,
@@ -5307,6 +5304,18 @@ static int hns_roce_v2_query_qpc(struct hns_roce_dev *hr_dev, u32 qpn,
53075304
return ret;
53085305
}
53095306

5307+
static u8 get_qp_timeout_attr(struct hns_roce_dev *hr_dev,
5308+
struct hns_roce_v2_qp_context *context)
5309+
{
5310+
u8 timeout;
5311+
5312+
timeout = (u8)hr_reg_read(context, QPC_AT);
5313+
if (hr_dev->pci_dev->revision == PCI_REVISION_ID_HIP08)
5314+
timeout -= HNS_ROCE_V2_QP_ACK_TIMEOUT_OFS_HIP08;
5315+
5316+
return timeout;
5317+
}
5318+
53105319
static int hns_roce_v2_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr,
53115320
int qp_attr_mask,
53125321
struct ib_qp_init_attr *qp_init_attr)
@@ -5384,7 +5393,7 @@ static int hns_roce_v2_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr,
53845393
qp_attr->max_dest_rd_atomic = 1 << hr_reg_read(&context, QPC_RR_MAX);
53855394

53865395
qp_attr->min_rnr_timer = (u8)hr_reg_read(&context, QPC_MIN_RNR_TIME);
5387-
qp_attr->timeout = (u8)hr_reg_read(&context, QPC_AT);
5396+
qp_attr->timeout = get_qp_timeout_attr(hr_dev, &context);
53885397
qp_attr->retry_cnt = hr_reg_read(&context, QPC_RETRY_NUM_INIT);
53895398
qp_attr->rnr_retry = hr_reg_read(&context, QPC_RNR_NUM_INIT);
53905399

drivers/infiniband/hw/hns/hns_roce_hw_v2.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
#define HNS_ROCE_V2_MAX_XRCD_NUM 0x1000000
4545
#define HNS_ROCE_V2_RSV_XRCD_NUM 0
4646

47+
#define HNS_ROCE_V2_QP_ACK_TIMEOUT_OFS_HIP08 10
48+
4749
#define HNS_ROCE_V3_SCCC_SZ 64
4850
#define HNS_ROCE_V3_GMV_ENTRY_SZ 32
4951

drivers/infiniband/hw/hns/hns_roce_mr.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
#include <linux/vmalloc.h>
3535
#include <rdma/ib_umem.h>
36+
#include <linux/math.h>
3637
#include "hns_roce_device.h"
3738
#include "hns_roce_cmd.h"
3839
#include "hns_roce_hem.h"
@@ -909,6 +910,44 @@ static int mtr_init_buf_cfg(struct hns_roce_dev *hr_dev,
909910
return page_cnt;
910911
}
911912

913+
static u64 cal_pages_per_l1ba(unsigned int ba_per_bt, unsigned int hopnum)
914+
{
915+
return int_pow(ba_per_bt, hopnum - 1);
916+
}
917+
918+
static unsigned int cal_best_bt_pg_sz(struct hns_roce_dev *hr_dev,
919+
struct hns_roce_mtr *mtr,
920+
unsigned int pg_shift)
921+
{
922+
unsigned long cap = hr_dev->caps.page_size_cap;
923+
struct hns_roce_buf_region *re;
924+
unsigned int pgs_per_l1ba;
925+
unsigned int ba_per_bt;
926+
unsigned int ba_num;
927+
int i;
928+
929+
for_each_set_bit_from(pg_shift, &cap, sizeof(cap) * BITS_PER_BYTE) {
930+
if (!(BIT(pg_shift) & cap))
931+
continue;
932+
933+
ba_per_bt = BIT(pg_shift) / BA_BYTE_LEN;
934+
ba_num = 0;
935+
for (i = 0; i < mtr->hem_cfg.region_count; i++) {
936+
re = &mtr->hem_cfg.region[i];
937+
if (re->hopnum == 0)
938+
continue;
939+
940+
pgs_per_l1ba = cal_pages_per_l1ba(ba_per_bt, re->hopnum);
941+
ba_num += DIV_ROUND_UP(re->count, pgs_per_l1ba);
942+
}
943+
944+
if (ba_num <= ba_per_bt)
945+
return pg_shift;
946+
}
947+
948+
return 0;
949+
}
950+
912951
static int mtr_alloc_mtt(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
913952
unsigned int ba_page_shift)
914953
{
@@ -917,6 +956,10 @@ static int mtr_alloc_mtt(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
917956

918957
hns_roce_hem_list_init(&mtr->hem_list);
919958
if (!cfg->is_direct) {
959+
ba_page_shift = cal_best_bt_pg_sz(hr_dev, mtr, ba_page_shift);
960+
if (!ba_page_shift)
961+
return -ERANGE;
962+
920963
ret = hns_roce_hem_list_request(hr_dev, &mtr->hem_list,
921964
cfg->region, cfg->region_count,
922965
ba_page_shift);

0 commit comments

Comments
 (0)