Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 9 Sep 2021 18:14:14 +0000 (11:14 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 9 Sep 2021 18:14:14 +0000 (11:14 -0700)
Pull rdma fixes from Jason Gunthorpe:
 "I don't usually send a second PR in the merge window, but the fix to
  mlx5 is significant enough that it should start going through the
  process ASAP. Along with it comes some of the usual -rc stuff that
  would normally wait for a -rc2 or so.

  Summary:

  Important error case regression fixes in mlx5:

   - Wrong size used when computing the error path smaller allocation
     request leads to corruption

   - Confusing but ultimately harmless alignment mis-calculation

  Static checker warning fixes:

   - NULL pointer subtraction in qib

   - kcalloc in bnxt_re

   - Missing static on global variable in hfi1"

* tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma:
  IB/hfi1: make hist static
  RDMA/bnxt_re: Prefer kcalloc over open coded arithmetic
  IB/qib: Fix null pointer subtraction compiler warning
  RDMA/mlx5: Fix xlt_chunk_align calculation
  RDMA/mlx5: Fix number of allocated XLT entries

drivers/infiniband/hw/bnxt_re/ib_verbs.c
drivers/infiniband/hw/hfi1/trace.c
drivers/infiniband/hw/mlx5/mr.c
drivers/infiniband/hw/qib/qib_sysfs.c

index 3048862..408dfbc 100644 (file)
@@ -1309,7 +1309,7 @@ out:
 static int bnxt_re_create_shadow_gsi(struct bnxt_re_qp *qp,
                                     struct bnxt_re_pd *pd)
 {
-       struct bnxt_re_sqp_entries *sqp_tbl = NULL;
+       struct bnxt_re_sqp_entries *sqp_tbl;
        struct bnxt_re_dev *rdev;
        struct bnxt_re_qp *sqp;
        struct bnxt_re_ah *sah;
@@ -1317,7 +1317,7 @@ static int bnxt_re_create_shadow_gsi(struct bnxt_re_qp *qp,
 
        rdev = qp->rdev;
        /* Create a shadow QP to handle the QP1 traffic */
-       sqp_tbl = kzalloc(sizeof(*sqp_tbl) * BNXT_RE_MAX_GSI_SQP_ENTRIES,
+       sqp_tbl = kcalloc(BNXT_RE_MAX_GSI_SQP_ENTRIES, sizeof(*sqp_tbl),
                          GFP_KERNEL);
        if (!sqp_tbl)
                return -ENOMEM;
index d9b5bbb..8302469 100644 (file)
@@ -488,7 +488,7 @@ struct hfi1_ctxt_hist {
        atomic_t data[255];
 };
 
-struct hfi1_ctxt_hist hist = {
+static struct hfi1_ctxt_hist hist = {
        .count = ATOMIC_INIT(0)
 };
 
index a520ac8..3be36eb 100644 (file)
@@ -995,7 +995,7 @@ static struct mlx5_ib_mr *alloc_cacheable_mr(struct ib_pd *pd,
 static void *mlx5_ib_alloc_xlt(size_t *nents, size_t ent_size, gfp_t gfp_mask)
 {
        const size_t xlt_chunk_align =
-               MLX5_UMR_MTT_ALIGNMENT / sizeof(ent_size);
+               MLX5_UMR_MTT_ALIGNMENT / ent_size;
        size_t size;
        void *res = NULL;
 
@@ -1024,7 +1024,7 @@ static void *mlx5_ib_alloc_xlt(size_t *nents, size_t ent_size, gfp_t gfp_mask)
 
        if (size > MLX5_SPARE_UMR_CHUNK) {
                size = MLX5_SPARE_UMR_CHUNK;
-               *nents = get_order(size) / ent_size;
+               *nents = size / ent_size;
                res = (void *)__get_free_pages(gfp_mask | __GFP_NOWARN,
                                               get_order(size));
                if (res)
index d57e49d..452e235 100644 (file)
@@ -403,9 +403,11 @@ static ssize_t diagc_attr_store(struct ib_device *ibdev, u32 port_num,
 }
 
 #define QIB_DIAGC_ATTR(N)                                                      \
+       static_assert(&((struct qib_ibport *)0)->rvp.n_##N != (u64 *)NULL);    \
        static struct qib_diagc_attr qib_diagc_attr_##N = {                    \
                .attr = __ATTR(N, 0664, diagc_attr_show, diagc_attr_store),    \
-               .counter = &((struct qib_ibport *)0)->rvp.n_##N - (u64 *)0,    \
+               .counter =                                                     \
+                       offsetof(struct qib_ibport, rvp.n_##N) / sizeof(u64)   \
        }
 
 QIB_DIAGC_ATTR(rc_resends);