From 0da942e88d2dd6d4d0c6c16086e8f902b90e06ca Mon Sep 17 00:00:00 2001 From: Leon Romanovsky Date: Sun, 22 Sep 2019 15:55:20 +0300 Subject: [PATCH 1/5] mlx5: Don't assume that input is rounded to power two The simple arithmetic can be done in order to stop assume that code provided to ilog32() used in mlx5 is rounded to power two. Reviewed-by: Yishai Hadas Signed-off-by: Leon Romanovsky --- providers/mlx5/dr_devx.c | 4 ++-- providers/mlx5/dr_send.c | 4 ++-- providers/mlx5/srq.c | 2 +- providers/mlx5/verbs.c | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/providers/mlx5/dr_devx.c b/providers/mlx5/dr_devx.c index ee1b5486e..cc8c20d34 100644 --- a/providers/mlx5/dr_devx.c +++ b/providers/mlx5/dr_devx.c @@ -324,9 +324,9 @@ struct mlx5dv_devx_obj *dr_devx_create_qp(struct ibv_context *ctx, DEVX_SET(qpc, qpc, uar_page, attr->page_id); DEVX_SET(qpc, qpc, cqn_snd, attr->cqn); DEVX_SET(qpc, qpc, cqn_rcv, attr->cqn); - DEVX_SET(qpc, qpc, log_sq_size, ilog32(attr->sq_wqe_cnt) - 1); + DEVX_SET(qpc, qpc, log_sq_size, ilog32(attr->sq_wqe_cnt - 1)); DEVX_SET(qpc, qpc, log_rq_stride, attr->rq_wqe_shift - 4); - DEVX_SET(qpc, qpc, log_rq_size, ilog32(attr->rq_wqe_cnt) - 1); + DEVX_SET(qpc, qpc, log_rq_size, ilog32(attr->rq_wqe_cnt - 1)); DEVX_SET(qpc, qpc, dbr_umem_id, attr->db_umem_id); DEVX_SET(create_qp_in, in, wq_umem_id, attr->buff_umem_id); diff --git a/providers/mlx5/dr_send.c b/providers/mlx5/dr_send.c index dd9d6eda3..32a60fd95 100644 --- a/providers/mlx5/dr_send.c +++ b/providers/mlx5/dr_send.c @@ -210,8 +210,8 @@ static int dr_calc_rq_size(struct dr_qp *dr_qp, wq_size = roundup_pow_of_two(attr->cap.max_recv_wr) * wqe_size; wq_size = max(wq_size, MLX5_SEND_WQE_BB); dr_qp->rq.wqe_cnt = wq_size / wqe_size; - dr_qp->rq.wqe_shift = ilog32(wqe_size) - 1; - dr_qp->rq.max_post = 1 << (ilog32(wq_size / wqe_size) - 1); + dr_qp->rq.wqe_shift = ilog32(wqe_size - 1); + dr_qp->rq.max_post = 1 << ilog32(wq_size / wqe_size - 1); dr_qp->rq.max_gs = wqe_size / sizeof(struct mlx5_wqe_data_seg); return wq_size; diff --git a/providers/mlx5/srq.c b/providers/mlx5/srq.c index 2124480cd..1c15656f6 100644 --- a/providers/mlx5/srq.c +++ b/providers/mlx5/srq.c @@ -291,7 +291,7 @@ int mlx5_alloc_srq_buf(struct ibv_context *context, struct mlx5_srq *srq, srq->max_gs = (size - sizeof(struct mlx5_wqe_srq_next_seg)) / sizeof(struct mlx5_wqe_data_seg); - srq->wqe_shift = ilog32(size) - 1; + srq->wqe_shift = ilog32(size - 1); srq->max = align_queue_size(max_wr); buf_size = srq->max * size; diff --git a/providers/mlx5/verbs.c b/providers/mlx5/verbs.c index a6cd3afe3..aa8920825 100644 --- a/providers/mlx5/verbs.c +++ b/providers/mlx5/verbs.c @@ -1400,8 +1400,8 @@ static int mlx5_calc_rwq_size(struct mlx5_context *ctx, wq_size = roundup_pow_of_two(attr->max_wr) * wqe_size; wq_size = max(wq_size, MLX5_SEND_WQE_BB); rwq->rq.wqe_cnt = wq_size / wqe_size; - rwq->rq.wqe_shift = ilog32(wqe_size) - 1; - rwq->rq.max_post = 1 << (ilog32(wq_size / wqe_size) - 1); + rwq->rq.wqe_shift = ilog32(wqe_size - 1); + rwq->rq.max_post = 1 << ilog32(wq_size / wqe_size - 1); scat_spc = wqe_size - ((rwq->wq_sig) ? sizeof(struct mlx5_rwqe_sig) : 0) - is_mprq * sizeof(struct mlx5_wqe_srq_next_seg); @@ -1436,8 +1436,8 @@ static int mlx5_calc_rq_size(struct mlx5_context *ctx, if (wqe_size) { wq_size = max(wq_size, MLX5_SEND_WQE_BB); qp->rq.wqe_cnt = wq_size / wqe_size; - qp->rq.wqe_shift = ilog32(wqe_size) - 1; - qp->rq.max_post = 1 << (ilog32(wq_size / wqe_size) - 1); + qp->rq.wqe_shift = ilog32(wqe_size - 1); + qp->rq.max_post = 1 << ilog32(wq_size / wqe_size - 1); scat_spc = wqe_size - (qp->wq_sig ? sizeof(struct mlx5_rwqe_sig) : 0); qp->rq.max_gs = scat_spc / sizeof(struct mlx5_wqe_data_seg); From 71df3e5ac0d5d636b95b861669d7fe59fd9cbe21 Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Tue, 13 Aug 2019 20:32:06 +0300 Subject: [PATCH 2/5] cbuild: Run gpg with a home directy in the tmpdir To avoid interaction with the user's gpg home directory. Signed-off-by: Jason Gunthorpe Signed-off-by: Leon Romanovsky --- buildlib/cbuild | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/buildlib/cbuild b/buildlib/cbuild index c9522841d..742a9e225 100755 --- a/buildlib/cbuild +++ b/buildlib/cbuild @@ -221,13 +221,15 @@ class APTEnvironment(Environment): # key for the toolchain ppa. Fetch it in the host and just import the # gpg data directly into the trusted keyring. kb = os.path.join(tmpdir,"%s.kb.gpg"%(keyid)); - subprocess.check_call(["gpg","--no-default-keyring","--keyring",kb,"--always-trust", - "--recv-key",keyid]); + env = {k:v for k,v in os.environ.items()}; + env["HOME"] = tmpdir; + subprocess.check_call(["gpg","--keyserver", "keyserver.ubuntu.com", "--no-default-keyring","--keyring",kb,"--always-trust", + "--recv-key",keyid],env=env); kr = os.path.join(gpgd,"%s.gpg"%(keyid)); with open(kr,"wb") as F: F.write(subprocess.check_output(["gpg","--no-default-keyring", "--keyring",kb, - "--export",keyid])); + "--export",keyid],env=env)); os.unlink(kb); self.add_source_list(tmpdir,keyid + ".list",srcline); From 0b09980860a05ec5feb25f7849c2d703db5c157e Mon Sep 17 00:00:00 2001 From: Honggang Li Date: Thu, 19 Sep 2019 14:40:45 +0800 Subject: [PATCH 3/5] srp_daemon: fix a double free segment fault for ibsrpdm Command: ./ibsrpdm -d /dev/infiniband/umadX Invalid free() / delete / delete[] / realloc() at 0x4C320DC: free (vg_replace_malloc.c:540) by 0x403BBB: free_config (srp_daemon.c:1811) by 0x4031BE: ibsrpdm (srp_daemon.c:2113) by 0x4031BE: main (srp_daemon.c:2153) Address 0x5ee5fd0 is 0 bytes inside a block of size 16 free'd at 0x4C320DC: free (vg_replace_malloc.c:540) by 0x404851: translate_umad_to_ibdev_and_port (srp_daemon.c:729) by 0x404851: set_conf_dev_and_port (srp_daemon.c:1586) by 0x403171: ibsrpdm (srp_daemon.c:2092) by 0x403171: main (srp_daemon.c:2153) Block was alloc'd at at 0x4C30EDB: malloc (vg_replace_malloc.c:309) by 0x40478D: translate_umad_to_ibdev_and_port (srp_daemon.c:698) by 0x40478D: set_conf_dev_and_port (srp_daemon.c:1586) by 0x403171: ibsrpdm (srp_daemon.c:2092) by 0x403171: main (srp_daemon.c:2153) Signed-off-by: Honggang Li Reviewed-by: Bart Van Assche Signed-off-by: Leon Romanovsky --- srp_daemon/srp_daemon.c | 1 + 1 file changed, 1 insertion(+) diff --git a/srp_daemon/srp_daemon.c b/srp_daemon/srp_daemon.c index 337b21c7d..f0bcf9231 100644 --- a/srp_daemon/srp_daemon.c +++ b/srp_daemon/srp_daemon.c @@ -727,6 +727,7 @@ static int translate_umad_to_ibdev_and_port(char *umad_dev, char **ibdev, if (ret) { free(*ibport); free(*ibdev); + *ibdev = NULL; } free(class_dev_path); From d865b664efe73abc0f2959a86f18e56564c4d0b2 Mon Sep 17 00:00:00 2001 From: Honggang Li Date: Mon, 16 Sep 2019 09:33:45 +0800 Subject: [PATCH 4/5] redhat: BuildRequires python3 python2 is obsoleted by python3 in RHEL8 and Fedora-30. Signed-off-by: Honggang Li Signed-off-by: Leon Romanovsky --- redhat/rdma-core.spec | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/redhat/rdma-core.spec b/redhat/rdma-core.spec index f07919cce..731a4e10f 100644 --- a/redhat/rdma-core.spec +++ b/redhat/rdma-core.spec @@ -29,8 +29,12 @@ BuildRequires: systemd-devel BuildRequires: python3-devel BuildRequires: python3-Cython %else +%if 0%{?rhel} == 8 || 0%{?fedora} >= 30 +BuildRequires: python3 +%else BuildRequires: python %endif +%endif %if 0%{?fedora} >= 21 BuildRequires: perl-generators %endif From 4f4d0a6f45d36318931829ba23a8b54f68f42b3d Mon Sep 17 00:00:00 2001 From: Leon Romanovsky Date: Tue, 24 Sep 2019 11:13:55 +0300 Subject: [PATCH 5/5] ibdiag: Remove wrongly added ibtypes.py file ibtypes.py was not supposed to be added from the beginning, hence remove it. Signed-off-by: Leon Romanovsky --- ibtypes.py | 61 ------------------------------------------------------ 1 file changed, 61 deletions(-) delete mode 100644 ibtypes.py diff --git a/ibtypes.py b/ibtypes.py deleted file mode 100644 index 119a023e5..000000000 --- a/ibtypes.py +++ /dev/null @@ -1,61 +0,0 @@ -import re -import sys - -def global_ln(ln): - g = re.match(r"^#define\s+(\S+)\s+CL_HTON(\d+)\((.*)\)",ln) - if g: - print("#define %s htobe%s(%s)"%(g.group(1),g.group(2),g.group(3))) - return global_ln - g = re.match(r"^#define\s+(\S+)\s+\(CL_HTON(\d+)\((.*)\)\)",ln) - if g: - print("#define %s htobe%s(%s)"%(g.group(1),g.group(2),g.group(3))) - return global_ln - g = re.match(r"^#define\s+(\S+)\s+(0x\w+)",ln) - if g: - print("#define %s %s"%(g.group(1),g.group(2))) - return global_ln - g = re.match(r"^#define\s+(\S+)\s+\((0x\w+)\)",ln) - if g: - print("#define %s %s"%(g.group(1),g.group(2))) - return global_ln - g = re.match(r"^#define\s+(\S+)\s+(\d+)",ln) - if g: - print("#define %s %s"%(g.group(1),g.group(2))) - return global_ln - g = re.match(r"^#define\s+(\S+)\s+\((\d+)\)",ln) - if g: - print("#define %s %s"%(g.group(1),g.group(2))) - return global_ln - - g = re.match(r"^typedef\s+(union|struct)\s+_\S+\s+{",ln); - if g: - print("typedef %s {"%(g.group(1))); - return in_struct; - - print(ln,file=FO); - return global_ln - -def in_struct(ln): - g = re.match(r"^}\s+PACK_SUFFIX\s+(\S+);",ln); - if g: - print("} __attribute__((packed)) %s;"%(g.group(1))); - return global_ln; - g = re.match(r"^}\s+(\S+);",ln); - if g: - print("} %s;"%(g.group(1))); - return global_ln; - - ln = ln.replace("PACK_SUFFIX","__attribute__((packed))"); - ln = ln.replace("ib_gid_prefix_t","__be64"); - ln = ln.replace("ib_net64_t","__be64"); - ln = ln.replace("ib_net32_t","__be32"); - ln = ln.replace("ib_net16_t","__be16"); - ln = ln.replace("boolean_t","bool"); - print(ln) - return in_struct; - -mode = global_ln -with open(sys.argv[1]) as FI, open(sys.argv[2],"wt") as FO: - for ln in FI: - ln = ln.rstrip(); - mode = mode(ln);