Skip to contentSkip to conversation

infiniband/hw/hns/hns_roce_hw_v2.c: Use dma_zalloc_coherent

PATCH In review Sabyasachi Gupta 2 participants 3 messages Nov 9, 2018 – Nov 12, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 infiniband/hw/hns/hns_roce_hw_v2.c: Use dma_zalloc_coherent

Replaced dma_alloc_coherent + memset with dma_zalloc_coherent

---
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +1 -2
index a4c62ae..c9966ec 100644
@@ -4972,13 +4972,12 @@ static int hns_roce_mhop_alloc_eq(struct hns_roce_dev *hr_dev,
 				eqe_alloc = i * (buf_chk_sz / eq->eqe_size);
 				size = (eq->entries - eqe_alloc) * eq->eqe_size;
 			}
-			eq->buf[i] = dma_alloc_coherent(dev, size,
+			eq->buf[i] = dma_zalloc_coherent(dev, size,
 							&(eq->buf_dma[i]),
 							GFP_KERNEL);
 			if (!eq->buf[i])
 				goto err_dma_alloc_buf;
 
-			memset(eq->buf[i], 0, size);
 			*(eq->bt_l0 + i) = eq->buf_dma[i];
 
 			eq_buf_cnt++;
Signature · 1 line
2.7.4
#1 lore raw
Quoted 2 lines · Sabyasachi Gupta

Replaced dma_alloc_coherent + memset with dma_zalloc_coherent

There are few other places in this file where same is applicable. Can we get those changes in same patch ?

Quoted 28 lines
---
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +1 -3
index a4c62ae..c9966ec 100644
@@ -4972,13 +4972,12 @@ static int hns_roce_mhop_alloc_eq(struct hns_roce_dev *hr_dev,
                                eqe_alloc = i * (buf_chk_sz / eq->eqe_size);
                                size = (eq->entries - eqe_alloc) * eq->eqe_size;
                        }
-                       eq->buf[i] = dma_alloc_coherent(dev, size,
+                       eq->buf[i] = dma_zalloc_coherent(dev, size,
                                                        &(eq->buf_dma[i]),
                                                        GFP_KERNEL);
                        if (!eq->buf[i])
                                goto err_dma_alloc_buf;
 
-                       memset(eq->buf[i], 0, size);
                        *(eq->bt_l0 + i) = eq->buf_dma[i];
 
                        eq_buf_cnt++;
--

2.7.4

#2 lore raw
Quoted 9 lines · Souptick Joarder
Quoted 2 lines · Sabyasachi Gupta

Replaced dma_alloc_coherent + memset with dma_zalloc_coherent

There are few other places in this file where same is applicable. Can we get those changes in same patch ?

Quoted 1 line

as all the changes are now in linux-next I am going to drop this patch

Quoted 27 lines
Quoted 27 lines
---
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +1 -3
index a4c62ae..c9966ec 100644
@@ -4972,13 +4972,12 @@ static int hns_roce_mhop_alloc_eq(struct hns_roce_dev *hr_dev,
                                eqe_alloc = i * (buf_chk_sz / eq->eqe_size);
                                size = (eq->entries - eqe_alloc) * eq->eqe_size;
                        }
-                       eq->buf[i] = dma_alloc_coherent(dev, size,
+                       eq->buf[i] = dma_zalloc_coherent(dev, size,
                                                        &(eq->buf_dma[i]),
                                                        GFP_KERNEL);
                        if (!eq->buf[i])
                                goto err_dma_alloc_buf;
 
-                       memset(eq->buf[i], 0, size);
                        *(eq->bt_l0 + i) = eq->buf_dma[i];
 
                        eq_buf_cnt++;
--

2.7.4