linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] use dma_zalloc_coherent and vzalloc to replace open code
@ 2018-08-01 13:26 zhong jiang
  2018-08-01 13:26 ` [PATCH 1/4] driver/scsi/fnic/fnic_trace: Use vzalloc to zero instead of vmalloc+memset zhong jiang
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: zhong jiang @ 2018-08-01 13:26 UTC (permalink / raw)
  To: john.garry, jejb, martin.petersen, aacraid
  Cc: andy.shevchenko, linux-scsi, linux-kernel


zhong jiang (4):
  driver/scsi/fnic/fnic_trace: Use vzalloc to zero instead of
    vmalloc+memset
  drivers/scsi/dpt_i2o: Use dma_zalloc_coherent to repalce
    dma_alloc_coherent+memset
  drivers/scsi/snic/snic_trc: Use vzalloc instead of vmalloc+memset
  drivers/scsi/mvsas/mv_init: Use dma_zalloc_coherent to replace
    dma_alloc_coherent+memset

 drivers/scsi/dpt_i2o.c         | 12 ++++--------
 drivers/scsi/fnic/fnic_trace.c |  3 +--
 drivers/scsi/mvsas/mv_init.c   | 12 ++++--------
 drivers/scsi/snic/snic_trc.c   |  3 +--
 4 files changed, 10 insertions(+), 20 deletions(-)

-- 
1.7.12.4


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/4] driver/scsi/fnic/fnic_trace: Use vzalloc to zero instead of vmalloc+memset
  2018-08-01 13:26 [PATCH 0/4] use dma_zalloc_coherent and vzalloc to replace open code zhong jiang
@ 2018-08-01 13:26 ` zhong jiang
  2018-08-01 15:30   ` Andy Shevchenko
  2018-08-01 13:26 ` [PATCH 2/4] drivers/scsi/dpt_i2o: Use dma_zalloc_coherent to repalce dma_alloc_coherent+memset zhong jiang
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 12+ messages in thread
From: zhong jiang @ 2018-08-01 13:26 UTC (permalink / raw)
  To: john.garry, jejb, martin.petersen, aacraid
  Cc: andy.shevchenko, linux-scsi, linux-kernel

The vzalloc is better than vmalloc+memset, so replace them to make
the code concise.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
 drivers/scsi/fnic/fnic_trace.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/fnic/fnic_trace.c b/drivers/scsi/fnic/fnic_trace.c
index 8271785..1c42556 100644
--- a/drivers/scsi/fnic/fnic_trace.c
+++ b/drivers/scsi/fnic/fnic_trace.c
@@ -468,14 +468,13 @@ int fnic_trace_buf_init(void)
 	fnic_max_trace_entries = (trace_max_pages * PAGE_SIZE)/
 					  FNIC_ENTRY_SIZE_BYTES;
 
-	fnic_trace_buf_p = (unsigned long)vmalloc((trace_max_pages * PAGE_SIZE));
+	fnic_trace_buf_p = (unsigned long)vzalloc((trace_max_pages * PAGE_SIZE));
 	if (!fnic_trace_buf_p) {
 		printk(KERN_ERR PFX "Failed to allocate memory "
 				  "for fnic_trace_buf_p\n");
 		err = -ENOMEM;
 		goto err_fnic_trace_buf_init;
 	}
-	memset((void *)fnic_trace_buf_p, 0, (trace_max_pages * PAGE_SIZE));
 
 	fnic_trace_entries.page_offset =
 		vmalloc(array_size(fnic_max_trace_entries,
-- 
1.7.12.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/4] drivers/scsi/dpt_i2o: Use dma_zalloc_coherent to repalce dma_alloc_coherent+memset
  2018-08-01 13:26 [PATCH 0/4] use dma_zalloc_coherent and vzalloc to replace open code zhong jiang
  2018-08-01 13:26 ` [PATCH 1/4] driver/scsi/fnic/fnic_trace: Use vzalloc to zero instead of vmalloc+memset zhong jiang
@ 2018-08-01 13:26 ` zhong jiang
  2018-08-01 15:32   ` Andy Shevchenko
  2018-08-01 13:26 ` [PATCH 3/4] drivers/scsi/snic/snic_trc: Use vzalloc instead of vmalloc+memset zhong jiang
  2018-08-01 13:26 ` [PATCH 4/4] drivers/scsi/mvsas/mv_init: Use dma_zalloc_coherent to replace dma_alloc_coherent+memset zhong jiang
  3 siblings, 1 reply; 12+ messages in thread
From: zhong jiang @ 2018-08-01 13:26 UTC (permalink / raw)
  To: john.garry, jejb, martin.petersen, aacraid
  Cc: andy.shevchenko, linux-scsi, linux-kernel

we prefer to dma_zalloc_coherent rather than open code dma_alloc_coherent+memset
, so just replace them.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
 drivers/scsi/dpt_i2o.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index 37de8fb..056383a 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -1370,13 +1370,12 @@ static s32 adpt_i2o_reset_hba(adpt_hba* pHba)
 		schedule_timeout_uninterruptible(1);
 	} while (m == EMPTY_QUEUE);
 
-	status = dma_alloc_coherent(&pHba->pDev->dev, 4, &addr, GFP_KERNEL);
+	status = dma_zalloc_coherent(&pHba->pDev->dev, 4, &addr, GFP_KERNEL);
 	if(status == NULL) {
 		adpt_send_nop(pHba, m);
 		printk(KERN_ERR"IOP reset failed - no free memory.\n");
 		return -ENOMEM;
 	}
-	memset(status,0,4);
 
 	msg[0]=EIGHT_WORD_MSG_SIZE|SGL_OFFSET_0;
 	msg[1]=I2O_CMD_ADAPTER_RESET<<24|HOST_TID<<12|ADAPTER_TID;
@@ -2836,14 +2835,13 @@ static s32 adpt_i2o_init_outbound_q(adpt_hba* pHba)
 
 	msg=(u32 __iomem *)(pHba->msg_addr_virt+m);
 
-	status = dma_alloc_coherent(&pHba->pDev->dev, 4, &addr, GFP_KERNEL);
+	status = dma_zalloc_coherent(&pHba->pDev->dev, 4, &addr, GFP_KERNEL);
 	if (!status) {
 		adpt_send_nop(pHba, m);
 		printk(KERN_WARNING"%s: IOP reset failed - no free memory.\n",
 			pHba->name);
 		return -ENOMEM;
 	}
-	memset(status, 0, 4);
 
 	writel(EIGHT_WORD_MSG_SIZE| SGL_OFFSET_6, &msg[0]);
 	writel(I2O_CMD_OUTBOUND_INIT<<24 | HOST_TID<<12 | ADAPTER_TID, &msg[1]);
@@ -2890,14 +2888,13 @@ static s32 adpt_i2o_init_outbound_q(adpt_hba* pHba)
 			pHba->reply_pool, pHba->reply_pool_pa);
 	}
 
-	pHba->reply_pool = dma_alloc_coherent(&pHba->pDev->dev,
+	pHba->reply_pool = dma_zalloc_coherent(&pHba->pDev->dev,
 				pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4,
 				&pHba->reply_pool_pa, GFP_KERNEL);
 	if (!pHba->reply_pool) {
 		printk(KERN_ERR "%s: Could not allocate reply pool\n", pHba->name);
 		return -ENOMEM;
 	}
-	memset(pHba->reply_pool, 0 , pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4);
 
 	for(i = 0; i < pHba->reply_fifo_size; i++) {
 		writel(pHba->reply_pool_pa + (i * REPLY_FRAME_SIZE * 4),
@@ -3126,13 +3123,12 @@ static int adpt_i2o_build_sys_table(void)
 	sys_tbl_len = sizeof(struct i2o_sys_tbl) +	// Header + IOPs
 				(hba_count) * sizeof(struct i2o_sys_tbl_entry);
 
-	sys_tbl = dma_alloc_coherent(&pHba->pDev->dev,
+	sys_tbl = dma_zalloc_coherent(&pHba->pDev->dev,
 				sys_tbl_len, &sys_tbl_pa, GFP_KERNEL);
 	if (!sys_tbl) {
 		printk(KERN_WARNING "SysTab Set failed. Out of memory.\n");	
 		return -ENOMEM;
 	}
-	memset(sys_tbl, 0, sys_tbl_len);
 
 	sys_tbl->num_entries = hba_count;
 	sys_tbl->version = I2OVERSION;
-- 
1.7.12.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/4] drivers/scsi/snic/snic_trc: Use vzalloc instead of vmalloc+memset
  2018-08-01 13:26 [PATCH 0/4] use dma_zalloc_coherent and vzalloc to replace open code zhong jiang
  2018-08-01 13:26 ` [PATCH 1/4] driver/scsi/fnic/fnic_trace: Use vzalloc to zero instead of vmalloc+memset zhong jiang
  2018-08-01 13:26 ` [PATCH 2/4] drivers/scsi/dpt_i2o: Use dma_zalloc_coherent to repalce dma_alloc_coherent+memset zhong jiang
@ 2018-08-01 13:26 ` zhong jiang
  2018-08-01 15:33   ` Andy Shevchenko
  2018-08-01 13:26 ` [PATCH 4/4] drivers/scsi/mvsas/mv_init: Use dma_zalloc_coherent to replace dma_alloc_coherent+memset zhong jiang
  3 siblings, 1 reply; 12+ messages in thread
From: zhong jiang @ 2018-08-01 13:26 UTC (permalink / raw)
  To: john.garry, jejb, martin.petersen, aacraid
  Cc: andy.shevchenko, linux-scsi, linux-kernel

The vzmalloc is better than vmalloc+memset, so replace them.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
 drivers/scsi/snic/snic_trc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/snic/snic_trc.c b/drivers/scsi/snic/snic_trc.c
index fc60c93..876c490 100644
--- a/drivers/scsi/snic/snic_trc.c
+++ b/drivers/scsi/snic/snic_trc.c
@@ -126,7 +126,7 @@ struct snic_trc_data *
 	int tbuf_sz = 0, ret;
 
 	tbuf_sz = (snic_trace_max_pages * PAGE_SIZE);
-	tbuf = vmalloc(tbuf_sz);
+	tbuf = vzmalloc(tbuf_sz);
 	if (!tbuf) {
 		SNIC_ERR("Failed to Allocate Trace Buffer Size. %d\n", tbuf_sz);
 		SNIC_ERR("Trace Facility not enabled.\n");
@@ -135,7 +135,6 @@ struct snic_trc_data *
 		return ret;
 	}
 
-	memset(tbuf, 0, tbuf_sz);
 	trc->buf = (struct snic_trc_data *) tbuf;
 	spin_lock_init(&trc->lock);
 
-- 
1.7.12.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 4/4] drivers/scsi/mvsas/mv_init: Use dma_zalloc_coherent to replace dma_alloc_coherent+memset
  2018-08-01 13:26 [PATCH 0/4] use dma_zalloc_coherent and vzalloc to replace open code zhong jiang
                   ` (2 preceding siblings ...)
  2018-08-01 13:26 ` [PATCH 3/4] drivers/scsi/snic/snic_trc: Use vzalloc instead of vmalloc+memset zhong jiang
@ 2018-08-01 13:26 ` zhong jiang
  2018-08-01 15:34   ` Andy Shevchenko
  2018-08-01 23:55   ` John Garry
  3 siblings, 2 replies; 12+ messages in thread
From: zhong jiang @ 2018-08-01 13:26 UTC (permalink / raw)
  To: john.garry, jejb, martin.petersen, aacraid
  Cc: andy.shevchenko, linux-scsi, linux-kernel

The dma_zalloc_coherent is better than dma_alloc_coherent+memset,
so replace them.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
 drivers/scsi/mvsas/mv_init.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c
index 8c91637..da62e18 100644
--- a/drivers/scsi/mvsas/mv_init.c
+++ b/drivers/scsi/mvsas/mv_init.c
@@ -253,33 +253,29 @@ static int mvs_alloc(struct mvs_info *mvi, struct Scsi_Host *shost)
 	/*
 	 * alloc and init our DMA areas
 	 */
-	mvi->tx = dma_alloc_coherent(mvi->dev,
+	mvi->tx = dma_zalloc_coherent(mvi->dev,
 				     sizeof(*mvi->tx) * MVS_CHIP_SLOT_SZ,
 				     &mvi->tx_dma, GFP_KERNEL);
 	if (!mvi->tx)
 		goto err_out;
-	memset(mvi->tx, 0, sizeof(*mvi->tx) * MVS_CHIP_SLOT_SZ);
-	mvi->rx_fis = dma_alloc_coherent(mvi->dev, MVS_RX_FISL_SZ,
+	mvi->rx_fis = dma_zalloc_coherent(mvi->dev, MVS_RX_FISL_SZ,
 					 &mvi->rx_fis_dma, GFP_KERNEL);
 	if (!mvi->rx_fis)
 		goto err_out;
-	memset(mvi->rx_fis, 0, MVS_RX_FISL_SZ);
 
-	mvi->rx = dma_alloc_coherent(mvi->dev,
+	mvi->rx = dma_zalloc_coherent(mvi->dev,
 				     sizeof(*mvi->rx) * (MVS_RX_RING_SZ + 1),
 				     &mvi->rx_dma, GFP_KERNEL);
 	if (!mvi->rx)
 		goto err_out;
-	memset(mvi->rx, 0, sizeof(*mvi->rx) * (MVS_RX_RING_SZ + 1));
 	mvi->rx[0] = cpu_to_le32(0xfff);
 	mvi->rx_cons = 0xfff;
 
-	mvi->slot = dma_alloc_coherent(mvi->dev,
+	mvi->slot = dma_zalloc_coherent(mvi->dev,
 				       sizeof(*mvi->slot) * slot_nr,
 				       &mvi->slot_dma, GFP_KERNEL);
 	if (!mvi->slot)
 		goto err_out;
-	memset(mvi->slot, 0, sizeof(*mvi->slot) * slot_nr);
 
 	mvi->bulk_buffer = dma_alloc_coherent(mvi->dev,
 				       TRASH_BUCKET_SIZE,
-- 
1.7.12.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/4] driver/scsi/fnic/fnic_trace: Use vzalloc to zero instead of vmalloc+memset
  2018-08-01 13:26 ` [PATCH 1/4] driver/scsi/fnic/fnic_trace: Use vzalloc to zero instead of vmalloc+memset zhong jiang
@ 2018-08-01 15:30   ` Andy Shevchenko
  2018-08-01 15:47     ` Joe Perches
  2018-08-02  6:16     ` zhong jiang
  0 siblings, 2 replies; 12+ messages in thread
From: Andy Shevchenko @ 2018-08-01 15:30 UTC (permalink / raw)
  To: zhong jiang
  Cc: John Garry, James E . J . Bottomley, Martin K. Petersen, aacraid,
	linux-scsi, Linux Kernel Mailing List

On Wed, Aug 1, 2018 at 4:26 PM, zhong jiang <zhongjiang@huawei.com> wrote:
> The vzalloc is better than vmalloc+memset, so replace them to make
> the code concise.

> -       fnic_trace_buf_p = (unsigned long)vmalloc((trace_max_pages * PAGE_SIZE));
> +       fnic_trace_buf_p = (unsigned long)vzalloc((trace_max_pages * PAGE_SIZE));

At the same time you may get rid of unnecessary parens.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/4] drivers/scsi/dpt_i2o: Use dma_zalloc_coherent to repalce dma_alloc_coherent+memset
  2018-08-01 13:26 ` [PATCH 2/4] drivers/scsi/dpt_i2o: Use dma_zalloc_coherent to repalce dma_alloc_coherent+memset zhong jiang
@ 2018-08-01 15:32   ` Andy Shevchenko
  0 siblings, 0 replies; 12+ messages in thread
From: Andy Shevchenko @ 2018-08-01 15:32 UTC (permalink / raw)
  To: zhong jiang
  Cc: John Garry, James E . J . Bottomley, Martin K. Petersen, aacraid,
	linux-scsi, Linux Kernel Mailing List

On Wed, Aug 1, 2018 at 4:26 PM, zhong jiang <zhongjiang@huawei.com> wrote:
> we prefer to dma_zalloc_coherent rather than open code dma_alloc_coherent+memset
> , so just replace them.

Capitalize your sentences along with proper use of function()
references and comma(s).

... dma_alloc_coherent() + memset(), ...

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/4] drivers/scsi/snic/snic_trc: Use vzalloc instead of vmalloc+memset
  2018-08-01 13:26 ` [PATCH 3/4] drivers/scsi/snic/snic_trc: Use vzalloc instead of vmalloc+memset zhong jiang
@ 2018-08-01 15:33   ` Andy Shevchenko
  0 siblings, 0 replies; 12+ messages in thread
From: Andy Shevchenko @ 2018-08-01 15:33 UTC (permalink / raw)
  To: zhong jiang
  Cc: John Garry, James E . J . Bottomley, Martin K. Petersen, aacraid,
	linux-scsi, Linux Kernel Mailing List

On Wed, Aug 1, 2018 at 4:26 PM, zhong jiang <zhongjiang@huawei.com> wrote:
> The vzmalloc is better than vmalloc+memset, so replace them.
>

FWIW,
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> Signed-off-by: zhong jiang <zhongjiang@huawei.com>
> ---
>  drivers/scsi/snic/snic_trc.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/scsi/snic/snic_trc.c b/drivers/scsi/snic/snic_trc.c
> index fc60c93..876c490 100644
> --- a/drivers/scsi/snic/snic_trc.c
> +++ b/drivers/scsi/snic/snic_trc.c
> @@ -126,7 +126,7 @@ struct snic_trc_data *
>         int tbuf_sz = 0, ret;
>
>         tbuf_sz = (snic_trace_max_pages * PAGE_SIZE);
> -       tbuf = vmalloc(tbuf_sz);
> +       tbuf = vzmalloc(tbuf_sz);
>         if (!tbuf) {
>                 SNIC_ERR("Failed to Allocate Trace Buffer Size. %d\n", tbuf_sz);
>                 SNIC_ERR("Trace Facility not enabled.\n");
> @@ -135,7 +135,6 @@ struct snic_trc_data *
>                 return ret;
>         }
>
> -       memset(tbuf, 0, tbuf_sz);
>         trc->buf = (struct snic_trc_data *) tbuf;
>         spin_lock_init(&trc->lock);
>
> --
> 1.7.12.4
>



-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 4/4] drivers/scsi/mvsas/mv_init: Use dma_zalloc_coherent to replace dma_alloc_coherent+memset
  2018-08-01 13:26 ` [PATCH 4/4] drivers/scsi/mvsas/mv_init: Use dma_zalloc_coherent to replace dma_alloc_coherent+memset zhong jiang
@ 2018-08-01 15:34   ` Andy Shevchenko
  2018-08-01 23:55   ` John Garry
  1 sibling, 0 replies; 12+ messages in thread
From: Andy Shevchenko @ 2018-08-01 15:34 UTC (permalink / raw)
  To: zhong jiang
  Cc: John Garry, James E . J . Bottomley, Martin K. Petersen, aacraid,
	linux-scsi, Linux Kernel Mailing List

On Wed, Aug 1, 2018 at 4:26 PM, zhong jiang <zhongjiang@huawei.com> wrote:
> The dma_zalloc_coherent is better than dma_alloc_coherent+memset,
> so replace them.
>

FWIW,
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>


> Signed-off-by: zhong jiang <zhongjiang@huawei.com>
> ---
>  drivers/scsi/mvsas/mv_init.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c
> index 8c91637..da62e18 100644
> --- a/drivers/scsi/mvsas/mv_init.c
> +++ b/drivers/scsi/mvsas/mv_init.c
> @@ -253,33 +253,29 @@ static int mvs_alloc(struct mvs_info *mvi, struct Scsi_Host *shost)
>         /*
>          * alloc and init our DMA areas
>          */
> -       mvi->tx = dma_alloc_coherent(mvi->dev,
> +       mvi->tx = dma_zalloc_coherent(mvi->dev,
>                                      sizeof(*mvi->tx) * MVS_CHIP_SLOT_SZ,
>                                      &mvi->tx_dma, GFP_KERNEL);
>         if (!mvi->tx)
>                 goto err_out;
> -       memset(mvi->tx, 0, sizeof(*mvi->tx) * MVS_CHIP_SLOT_SZ);
> -       mvi->rx_fis = dma_alloc_coherent(mvi->dev, MVS_RX_FISL_SZ,
> +       mvi->rx_fis = dma_zalloc_coherent(mvi->dev, MVS_RX_FISL_SZ,
>                                          &mvi->rx_fis_dma, GFP_KERNEL);
>         if (!mvi->rx_fis)
>                 goto err_out;
> -       memset(mvi->rx_fis, 0, MVS_RX_FISL_SZ);
>
> -       mvi->rx = dma_alloc_coherent(mvi->dev,
> +       mvi->rx = dma_zalloc_coherent(mvi->dev,
>                                      sizeof(*mvi->rx) * (MVS_RX_RING_SZ + 1),
>                                      &mvi->rx_dma, GFP_KERNEL);
>         if (!mvi->rx)
>                 goto err_out;
> -       memset(mvi->rx, 0, sizeof(*mvi->rx) * (MVS_RX_RING_SZ + 1));
>         mvi->rx[0] = cpu_to_le32(0xfff);
>         mvi->rx_cons = 0xfff;
>
> -       mvi->slot = dma_alloc_coherent(mvi->dev,
> +       mvi->slot = dma_zalloc_coherent(mvi->dev,
>                                        sizeof(*mvi->slot) * slot_nr,
>                                        &mvi->slot_dma, GFP_KERNEL);
>         if (!mvi->slot)
>                 goto err_out;
> -       memset(mvi->slot, 0, sizeof(*mvi->slot) * slot_nr);
>
>         mvi->bulk_buffer = dma_alloc_coherent(mvi->dev,
>                                        TRASH_BUCKET_SIZE,
> --
> 1.7.12.4
>



-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/4] driver/scsi/fnic/fnic_trace: Use vzalloc to zero instead of vmalloc+memset
  2018-08-01 15:30   ` Andy Shevchenko
@ 2018-08-01 15:47     ` Joe Perches
  2018-08-02  6:16     ` zhong jiang
  1 sibling, 0 replies; 12+ messages in thread
From: Joe Perches @ 2018-08-01 15:47 UTC (permalink / raw)
  To: Andy Shevchenko, zhong jiang
  Cc: John Garry, James E . J . Bottomley, Martin K. Petersen, aacraid,
	linux-scsi, Linux Kernel Mailing List

On Wed, 2018-08-01 at 18:30 +0300, Andy Shevchenko wrote:
> On Wed, Aug 1, 2018 at 4:26 PM, zhong jiang <zhongjiang@huawei.com> wrote:
> > The vzalloc is better than vmalloc+memset, so replace them to make
> > the code concise.
> > -       fnic_trace_buf_p = (unsigned long)vmalloc((trace_max_pages * PAGE_SIZE));
> > +       fnic_trace_buf_p = (unsigned long)vzalloc((trace_max_pages * PAGE_SIZE));
> 
> At the same time you may get rid of unnecessary parens.

And at the same time, perhaps use kvcalloc and kvfree
instead of always using vmalloc as the allocation size
can be less than the allowable for a single kmalloc.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 4/4] drivers/scsi/mvsas/mv_init: Use dma_zalloc_coherent to replace dma_alloc_coherent+memset
  2018-08-01 13:26 ` [PATCH 4/4] drivers/scsi/mvsas/mv_init: Use dma_zalloc_coherent to replace dma_alloc_coherent+memset zhong jiang
  2018-08-01 15:34   ` Andy Shevchenko
@ 2018-08-01 23:55   ` John Garry
  1 sibling, 0 replies; 12+ messages in thread
From: John Garry @ 2018-08-01 23:55 UTC (permalink / raw)
  To: zhong jiang, jejb, martin.petersen, aacraid
  Cc: andy.shevchenko, linux-scsi, linux-kernel

On 01/08/2018 14:26, zhong jiang wrote:
> The dma_zalloc_coherent is better than dma_alloc_coherent+memset,
> so replace them.
>
> Signed-off-by: zhong jiang <zhongjiang@huawei.com>
> ---
>  drivers/scsi/mvsas/mv_init.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c
> index 8c91637..da62e18 100644
> --- a/drivers/scsi/mvsas/mv_init.c
> +++ b/drivers/scsi/mvsas/mv_init.c
> @@ -253,33 +253,29 @@ static int mvs_alloc(struct mvs_info *mvi, struct Scsi_Host *shost)
>  	/*
>  	 * alloc and init our DMA areas
>  	 */
> -	mvi->tx = dma_alloc_coherent(mvi->dev,
> +	mvi->tx = dma_zalloc_coherent(mvi->dev,
>  				     sizeof(*mvi->tx) * MVS_CHIP_SLOT_SZ,
>  				     &mvi->tx_dma, GFP_KERNEL);
>  	if (!mvi->tx)
>  		goto err_out;
> -	memset(mvi->tx, 0, sizeof(*mvi->tx) * MVS_CHIP_SLOT_SZ);
> -	mvi->rx_fis = dma_alloc_coherent(mvi->dev, MVS_RX_FISL_SZ,
> +	mvi->rx_fis = dma_zalloc_coherent(mvi->dev, MVS_RX_FISL_SZ,
>  					 &mvi->rx_fis_dma, GFP_KERNEL);

Nit: Please ensure that you maintain alignment between the opening brace 
and each new line.

Thanks,

>  	if (!mvi->rx_fis)
>  		goto err_out;
> -	memset(mvi->rx_fis, 0, MVS_RX_FISL_SZ);
>
> -	mvi->rx = dma_alloc_coherent(mvi->dev,
> +	mvi->rx = dma_zalloc_coherent(mvi->dev,
>  				     sizeof(*mvi->rx) * (MVS_RX_RING_SZ + 1),
>  				     &mvi->rx_dma, GFP_KERNEL);
>  	if (!mvi->rx)
>  		goto err_out;
> -	memset(mvi->rx, 0, sizeof(*mvi->rx) * (MVS_RX_RING_SZ + 1));
>  	mvi->rx[0] = cpu_to_le32(0xfff);
>  	mvi->rx_cons = 0xfff;
>
> -	mvi->slot = dma_alloc_coherent(mvi->dev,
> +	mvi->slot = dma_zalloc_coherent(mvi->dev,
>  				       sizeof(*mvi->slot) * slot_nr,
>  				       &mvi->slot_dma, GFP_KERNEL);
>  	if (!mvi->slot)
>  		goto err_out;
> -	memset(mvi->slot, 0, sizeof(*mvi->slot) * slot_nr);
>
>  	mvi->bulk_buffer = dma_alloc_coherent(mvi->dev,
>  				       TRASH_BUCKET_SIZE,
>



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/4] driver/scsi/fnic/fnic_trace: Use vzalloc to zero instead of vmalloc+memset
  2018-08-01 15:30   ` Andy Shevchenko
  2018-08-01 15:47     ` Joe Perches
@ 2018-08-02  6:16     ` zhong jiang
  1 sibling, 0 replies; 12+ messages in thread
From: zhong jiang @ 2018-08-02  6:16 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: John Garry, James E . J . Bottomley, Martin K. Petersen, aacraid,
	linux-scsi, Linux Kernel Mailing List

On 2018/8/1 23:30, Andy Shevchenko wrote:
> On Wed, Aug 1, 2018 at 4:26 PM, zhong jiang <zhongjiang@huawei.com> wrote:
>> The vzalloc is better than vmalloc+memset, so replace them to make
>> the code concise.
>> -       fnic_trace_buf_p = (unsigned long)vmalloc((trace_max_pages * PAGE_SIZE));
>> +       fnic_trace_buf_p = (unsigned long)vzalloc((trace_max_pages * PAGE_SIZE));
> At the same time you may get rid of unnecessary parens.
>
Thanks , I will repost with the change.

Thanks
zhong jiang


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2018-08-02  6:17 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-01 13:26 [PATCH 0/4] use dma_zalloc_coherent and vzalloc to replace open code zhong jiang
2018-08-01 13:26 ` [PATCH 1/4] driver/scsi/fnic/fnic_trace: Use vzalloc to zero instead of vmalloc+memset zhong jiang
2018-08-01 15:30   ` Andy Shevchenko
2018-08-01 15:47     ` Joe Perches
2018-08-02  6:16     ` zhong jiang
2018-08-01 13:26 ` [PATCH 2/4] drivers/scsi/dpt_i2o: Use dma_zalloc_coherent to repalce dma_alloc_coherent+memset zhong jiang
2018-08-01 15:32   ` Andy Shevchenko
2018-08-01 13:26 ` [PATCH 3/4] drivers/scsi/snic/snic_trc: Use vzalloc instead of vmalloc+memset zhong jiang
2018-08-01 15:33   ` Andy Shevchenko
2018-08-01 13:26 ` [PATCH 4/4] drivers/scsi/mvsas/mv_init: Use dma_zalloc_coherent to replace dma_alloc_coherent+memset zhong jiang
2018-08-01 15:34   ` Andy Shevchenko
2018-08-01 23:55   ` John Garry

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).