IB/mlx4: use kvmalloc_array to allocate wrid
authorLi Dongyang <dongyang.li@anu.edu.au>
Wed, 16 Aug 2017 13:31:23 +0000 (23:31 +1000)
committerDoug Ledford <dledford@redhat.com>
Tue, 22 Aug 2017 20:48:35 +0000 (16:48 -0400)
We could use kvmalloc_array instead of the
kmalloc and __vmalloc combination.
After this we don't need to include linux/vmalloc.h

Signed-off-by: Li Dongyang <dongyang.li@anu.edu.au>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/mlx4/qp.c
drivers/infiniband/hw/mlx4/srq.c

index e42acfb205887046a2073ad88033f76ccd997460..b40d50c643e1116cdeb8b28a9d2fe8376462bc12 100644 (file)
@@ -36,7 +36,6 @@
 #include <net/ip.h>
 #include <linux/slab.h>
 #include <linux/netdevice.h>
-#include <linux/vmalloc.h>
 
 #include <rdma/ib_cache.h>
 #include <rdma/ib_pack.h>
@@ -1174,16 +1173,10 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
                if (err)
                        goto err_mtt;
 
-               qp->sq.wrid = kmalloc_array(qp->sq.wqe_cnt, sizeof(u64),
-                                       GFP_KERNEL | __GFP_NOWARN);
-               if (!qp->sq.wrid)
-                       qp->sq.wrid = __vmalloc(qp->sq.wqe_cnt * sizeof(u64),
-                                               GFP_KERNEL, PAGE_KERNEL);
-               qp->rq.wrid = kmalloc_array(qp->rq.wqe_cnt, sizeof(u64),
-                                       GFP_KERNEL | __GFP_NOWARN);
-               if (!qp->rq.wrid)
-                       qp->rq.wrid = __vmalloc(qp->rq.wqe_cnt * sizeof(u64),
-                                               GFP_KERNEL, PAGE_KERNEL);
+               qp->sq.wrid = kvmalloc_array(qp->sq.wqe_cnt,
+                                            sizeof(u64), GFP_KERNEL);
+               qp->rq.wrid = kvmalloc_array(qp->rq.wqe_cnt,
+                                            sizeof(u64), GFP_KERNEL);
                if (!qp->sq.wrid || !qp->rq.wrid) {
                        err = -ENOMEM;
                        goto err_wrid;
index 0facaf5f6d2376d395a739726b740b1d6f352435..dd7a2fce9df4b4a60211630bf37ba3f75558fa04 100644 (file)
@@ -34,7 +34,6 @@
 #include <linux/mlx4/qp.h>
 #include <linux/mlx4/srq.h>
 #include <linux/slab.h>
-#include <linux/vmalloc.h>
 
 #include "mlx4_ib.h"
 #include <rdma/mlx4-abi.h>
@@ -171,15 +170,11 @@ struct ib_srq *mlx4_ib_create_srq(struct ib_pd *pd,
                if (err)
                        goto err_mtt;
 
-               srq->wrid = kmalloc_array(srq->msrq.max, sizeof(u64),
-                                       GFP_KERNEL | __GFP_NOWARN);
+               srq->wrid = kvmalloc_array(srq->msrq.max,
+                                          sizeof(u64), GFP_KERNEL);
                if (!srq->wrid) {
-                       srq->wrid = __vmalloc(srq->msrq.max * sizeof(u64),
-                                             GFP_KERNEL, PAGE_KERNEL);
-                       if (!srq->wrid) {
-                               err = -ENOMEM;
-                               goto err_mtt;
-                       }
+                       err = -ENOMEM;
+                       goto err_mtt;
                }
        }