2017-12-31 12:32:54

by Himanshu Jha

[permalink] [raw]
Subject: [PATCH] RDMA/bnxt_re: Use zeroing memory allocator than allocator/memset

Use dma_zalloc_coherent for allocating zeroed
memory and remove unnecessary memset function.

Done using Coccinelle.
Generated-by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci
0-day tested with no failures.

Suggested-by: Luis R. Rodriguez <[email protected]>
Signed-off-by: Himanshu Jha <[email protected]>
---
drivers/infiniband/hw/bnxt_re/qplib_res.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/infiniband/hw/bnxt_re/qplib_res.c b/drivers/infiniband/hw/bnxt_re/qplib_res.c
index 4e10170..ad37d54 100644
--- a/drivers/infiniband/hw/bnxt_re/qplib_res.c
+++ b/drivers/infiniband/hw/bnxt_re/qplib_res.c
@@ -104,13 +104,12 @@ static int __alloc_pbl(struct pci_dev *pdev, struct bnxt_qplib_pbl *pbl,

if (!sghead) {
for (i = 0; i < pages; i++) {
- pbl->pg_arr[i] = dma_alloc_coherent(&pdev->dev,
- pbl->pg_size,
- &pbl->pg_map_arr[i],
- GFP_KERNEL);
+ pbl->pg_arr[i] = dma_zalloc_coherent(&pdev->dev,
+ pbl->pg_size,
+ &pbl->pg_map_arr[i],
+ GFP_KERNEL);
if (!pbl->pg_arr[i])
goto fail;
- memset(pbl->pg_arr[i], 0, pbl->pg_size);
pbl->pg_count++;
}
} else {
--
2.7.4


2018-01-02 21:06:43

by Jason Gunthorpe

[permalink] [raw]
Subject: Re: [PATCH] RDMA/bnxt_re: Use zeroing memory allocator than allocator/memset

On Sun, Dec 31, 2017 at 06:02:38PM +0530, Himanshu Jha wrote:
> Use dma_zalloc_coherent for allocating zeroed
> memory and remove unnecessary memset function.
>
> Done using Coccinelle.
> Generated-by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci
> 0-day tested with no failures.
>
> Suggested-by: Luis R. Rodriguez <[email protected]>
> Signed-off-by: Himanshu Jha <[email protected]>
> drivers/infiniband/hw/bnxt_re/qplib_res.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)

Applied to for-next thanks

Jason