* [PATCH v2 0/4] Use dma_zalloc_coherent and kvcalloc to replace open code
@ 2018-08-02 11:28 ` zhong jiang
0 siblings, 0 replies; 12+ messages in thread
From: zhong jiang @ 2018-08-02 11:28 UTC (permalink / raw)
To: jejb, martin.petersen, aacraid
Cc: andy.shevchenko, joe, linux-scsi, linux-kernel
v1->v2:
According to Andy and Joe suggestions.
[patch 1/4] get rid of unnessary parens and use kvcalloc and kvfree to
replace the vmalloc and vfree.
[patch 2/4] modify the changelog as Andy's suggestion.
[patch 3/4] replace vmalloc and vfree by using kvcalloc adn kvfree.
[patch 4/4] do nothing. just add Andy's review-by.
zhong jiang (4):
driver/scsi/fnic/fnic_trace: Use kvcalloc instead of vmalloc+memset
drivers/scsi/dpt_i2o: Use dma_zalloc_coherent to repalce
dma_alloc_coherent+memset
drivers/scsi/snic/snic_trc: Use kvcalloc 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 | 7 +++----
drivers/scsi/mvsas/mv_init.c | 12 ++++--------
drivers/scsi/snic/snic_trc.c | 7 +++----
4 files changed, 14 insertions(+), 24 deletions(-)
--
1.7.12.4
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 0/4] Use dma_zalloc_coherent and kvcalloc to replace open code
@ 2018-08-02 11:28 ` zhong jiang
0 siblings, 0 replies; 12+ messages in thread
From: zhong jiang @ 2018-08-02 11:28 UTC (permalink / raw)
To: jejb, martin.petersen, aacraid
Cc: andy.shevchenko, joe, linux-scsi, linux-kernel
v1->v2:
According to Andy and Joe suggestions.
[patch 1/4] get rid of unnessary parens and use kvcalloc and kvfree to
replace the vmalloc and vfree.
[patch 2/4] modify the changelog as Andy's suggestion.
[patch 3/4] replace vmalloc and vfree by using kvcalloc adn kvfree.
[patch 4/4] do nothing. just add Andy's review-by.
zhong jiang (4):
driver/scsi/fnic/fnic_trace: Use kvcalloc instead of vmalloc+memset
drivers/scsi/dpt_i2o: Use dma_zalloc_coherent to repalce
dma_alloc_coherent+memset
drivers/scsi/snic/snic_trc: Use kvcalloc 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 | 7 +++----
drivers/scsi/mvsas/mv_init.c | 12 ++++--------
drivers/scsi/snic/snic_trc.c | 7 +++----
4 files changed, 14 insertions(+), 24 deletions(-)
--
1.7.12.4
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 1/4] driver/scsi/fnic/fnic_trace: Use kvcalloc instead of vmalloc+memset
2018-08-02 11:28 ` zhong jiang
@ 2018-08-02 11:28 ` zhong jiang
-1 siblings, 0 replies; 12+ messages in thread
From: zhong jiang @ 2018-08-02 11:28 UTC (permalink / raw)
To: jejb, martin.petersen, aacraid
Cc: andy.shevchenko, joe, linux-scsi, linux-kernel
The kvcalloc 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 | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/scsi/fnic/fnic_trace.c b/drivers/scsi/fnic/fnic_trace.c
index 8271785..57f67af 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)kvcalloc(trace_max_pages, PAGE_SIZE, GFP_KERNEL);
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,
@@ -484,7 +483,7 @@ int fnic_trace_buf_init(void)
printk(KERN_ERR PFX "Failed to allocate memory for"
" page_offset\n");
if (fnic_trace_buf_p) {
- vfree((void *)fnic_trace_buf_p);
+ kvfree((void *)fnic_trace_buf_p);
fnic_trace_buf_p = 0;
}
err = -ENOMEM;
@@ -529,7 +528,7 @@ void fnic_trace_free(void)
fnic_trace_entries.page_offset = NULL;
}
if (fnic_trace_buf_p) {
- vfree((void *)fnic_trace_buf_p);
+ kvfree((void *)fnic_trace_buf_p);
fnic_trace_buf_p = 0;
}
printk(KERN_INFO PFX "Successfully Freed Trace Buffer\n");
--
1.7.12.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2 1/4] driver/scsi/fnic/fnic_trace: Use kvcalloc instead of vmalloc+memset
@ 2018-08-02 11:28 ` zhong jiang
0 siblings, 0 replies; 12+ messages in thread
From: zhong jiang @ 2018-08-02 11:28 UTC (permalink / raw)
To: jejb, martin.petersen, aacraid
Cc: andy.shevchenko, joe, linux-scsi, linux-kernel
The kvcalloc 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 | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/scsi/fnic/fnic_trace.c b/drivers/scsi/fnic/fnic_trace.c
index 8271785..57f67af 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)kvcalloc(trace_max_pages, PAGE_SIZE, GFP_KERNEL);
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,
@@ -484,7 +483,7 @@ int fnic_trace_buf_init(void)
printk(KERN_ERR PFX "Failed to allocate memory for"
" page_offset\n");
if (fnic_trace_buf_p) {
- vfree((void *)fnic_trace_buf_p);
+ kvfree((void *)fnic_trace_buf_p);
fnic_trace_buf_p = 0;
}
err = -ENOMEM;
@@ -529,7 +528,7 @@ void fnic_trace_free(void)
fnic_trace_entries.page_offset = NULL;
}
if (fnic_trace_buf_p) {
- vfree((void *)fnic_trace_buf_p);
+ kvfree((void *)fnic_trace_buf_p);
fnic_trace_buf_p = 0;
}
printk(KERN_INFO PFX "Successfully Freed Trace Buffer\n");
--
1.7.12.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2 2/4] drivers/scsi/dpt_i2o: Use dma_zalloc_coherent to repalce dma_alloc_coherent+memset
2018-08-02 11:28 ` zhong jiang
@ 2018-08-02 11:28 ` zhong jiang
-1 siblings, 0 replies; 12+ messages in thread
From: zhong jiang @ 2018-08-02 11:28 UTC (permalink / raw)
To: jejb, martin.petersen, aacraid
Cc: andy.shevchenko, joe, 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 v2 2/4] drivers/scsi/dpt_i2o: Use dma_zalloc_coherent to repalce dma_alloc_coherent+memset
@ 2018-08-02 11:28 ` zhong jiang
0 siblings, 0 replies; 12+ messages in thread
From: zhong jiang @ 2018-08-02 11:28 UTC (permalink / raw)
To: jejb, martin.petersen, aacraid
Cc: andy.shevchenko, joe, 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 v2 3/4] drivers/scsi/snic/snic_trc: Use kvcalloc instead of vmalloc+memset
2018-08-02 11:28 ` zhong jiang
@ 2018-08-02 11:28 ` zhong jiang
-1 siblings, 0 replies; 12+ messages in thread
From: zhong jiang @ 2018-08-02 11:28 UTC (permalink / raw)
To: jejb, martin.petersen, aacraid
Cc: andy.shevchenko, joe, linux-scsi, linux-kernel
The kvcalloc is better than vmalloc() + memset() , So replace them.
Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
drivers/scsi/snic/snic_trc.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/scsi/snic/snic_trc.c b/drivers/scsi/snic/snic_trc.c
index fc60c93..e766fa2 100644
--- a/drivers/scsi/snic/snic_trc.c
+++ b/drivers/scsi/snic/snic_trc.c
@@ -125,8 +125,8 @@ struct snic_trc_data *
void *tbuf = NULL;
int tbuf_sz = 0, ret;
- tbuf_sz = (snic_trace_max_pages * PAGE_SIZE);
- tbuf = vmalloc(tbuf_sz);
+ tbuf_sz = snic_trace_max_pages * PAGE_SIZE;
+ tbuf = kvcalloc(snic_trace_max_pages, PAGE_SIZE, GFP_KERNEL);
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);
@@ -173,7 +172,7 @@ struct snic_trc_data *
snic_trc_debugfs_term();
if (trc->buf) {
- vfree(trc->buf);
+ kvfree(trc->buf);
trc->buf = NULL;
}
--
1.7.12.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2 3/4] drivers/scsi/snic/snic_trc: Use kvcalloc instead of vmalloc+memset
@ 2018-08-02 11:28 ` zhong jiang
0 siblings, 0 replies; 12+ messages in thread
From: zhong jiang @ 2018-08-02 11:28 UTC (permalink / raw)
To: jejb, martin.petersen, aacraid
Cc: andy.shevchenko, joe, linux-scsi, linux-kernel
The kvcalloc is better than vmalloc() + memset() , So replace them.
Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
drivers/scsi/snic/snic_trc.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/scsi/snic/snic_trc.c b/drivers/scsi/snic/snic_trc.c
index fc60c93..e766fa2 100644
--- a/drivers/scsi/snic/snic_trc.c
+++ b/drivers/scsi/snic/snic_trc.c
@@ -125,8 +125,8 @@ struct snic_trc_data *
void *tbuf = NULL;
int tbuf_sz = 0, ret;
- tbuf_sz = (snic_trace_max_pages * PAGE_SIZE);
- tbuf = vmalloc(tbuf_sz);
+ tbuf_sz = snic_trace_max_pages * PAGE_SIZE;
+ tbuf = kvcalloc(snic_trace_max_pages, PAGE_SIZE, GFP_KERNEL);
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);
@@ -173,7 +172,7 @@ struct snic_trc_data *
snic_trc_debugfs_term();
if (trc->buf) {
- vfree(trc->buf);
+ kvfree(trc->buf);
trc->buf = NULL;
}
--
1.7.12.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2 4/4] drivers/scsi/mvsas/mv_init: Use dma_zalloc_coherent to replace dma_alloc_coherent+memset
2018-08-02 11:28 ` zhong jiang
@ 2018-08-02 11:28 ` zhong jiang
-1 siblings, 0 replies; 12+ messages in thread
From: zhong jiang @ 2018-08-02 11:28 UTC (permalink / raw)
To: jejb, martin.petersen, aacraid
Cc: andy.shevchenko, joe, 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>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.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
* [PATCH v2 4/4] drivers/scsi/mvsas/mv_init: Use dma_zalloc_coherent to replace dma_alloc_coherent+memset
@ 2018-08-02 11:28 ` zhong jiang
0 siblings, 0 replies; 12+ messages in thread
From: zhong jiang @ 2018-08-02 11:28 UTC (permalink / raw)
To: jejb, martin.petersen, aacraid
Cc: andy.shevchenko, joe, 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>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.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 v2 0/4] Use dma_zalloc_coherent and kvcalloc to replace open code
2018-08-02 11:28 ` zhong jiang
@ 2018-08-23 11:25 ` zhong jiang
-1 siblings, 0 replies; 12+ messages in thread
From: zhong jiang @ 2018-08-23 11:25 UTC (permalink / raw)
To: jejb, martin.petersen, aacraid
Cc: andy.shevchenko, joe, linux-scsi, linux-kernel
HI, martin
Can you pick up the patchset? Thanks
Best wishes,
zhong jiang
On 2018/8/2 19:28, zhong jiang wrote:
>
> v1->v2:
>
> According to Andy and Joe suggestions.
> [patch 1/4] get rid of unnessary parens and use kvcalloc and kvfree to
> replace the vmalloc and vfree.
> [patch 2/4] modify the changelog as Andy's suggestion.
> [patch 3/4] replace vmalloc and vfree by using kvcalloc adn kvfree.
> [patch 4/4] do nothing. just add Andy's review-by.
>
>
> zhong jiang (4):
> driver/scsi/fnic/fnic_trace: Use kvcalloc instead of vmalloc+memset
> drivers/scsi/dpt_i2o: Use dma_zalloc_coherent to repalce
> dma_alloc_coherent+memset
> drivers/scsi/snic/snic_trc: Use kvcalloc 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 | 7 +++----
> drivers/scsi/mvsas/mv_init.c | 12 ++++--------
> drivers/scsi/snic/snic_trc.c | 7 +++----
> 4 files changed, 14 insertions(+), 24 deletions(-)
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2 0/4] Use dma_zalloc_coherent and kvcalloc to replace open code
@ 2018-08-23 11:25 ` zhong jiang
0 siblings, 0 replies; 12+ messages in thread
From: zhong jiang @ 2018-08-23 11:25 UTC (permalink / raw)
To: jejb, martin.petersen, aacraid
Cc: andy.shevchenko, joe, linux-scsi, linux-kernel
HI, martin
Can you pick up the patchset? Thanks
Best wishes,
zhong jiang
On 2018/8/2 19:28, zhong jiang wrote:
>
> v1->v2:
>
> According to Andy and Joe suggestions.
> [patch 1/4] get rid of unnessary parens and use kvcalloc and kvfree to
> replace the vmalloc and vfree.
> [patch 2/4] modify the changelog as Andy's suggestion.
> [patch 3/4] replace vmalloc and vfree by using kvcalloc adn kvfree.
> [patch 4/4] do nothing. just add Andy's review-by.
>
>
> zhong jiang (4):
> driver/scsi/fnic/fnic_trace: Use kvcalloc instead of vmalloc+memset
> drivers/scsi/dpt_i2o: Use dma_zalloc_coherent to repalce
> dma_alloc_coherent+memset
> drivers/scsi/snic/snic_trc: Use kvcalloc 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 | 7 +++----
> drivers/scsi/mvsas/mv_init.c | 12 ++++--------
> drivers/scsi/snic/snic_trc.c | 7 +++----
> 4 files changed, 14 insertions(+), 24 deletions(-)
>
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2018-08-23 11:25 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-02 11:28 [PATCH v2 0/4] Use dma_zalloc_coherent and kvcalloc to replace open code zhong jiang
2018-08-02 11:28 ` zhong jiang
2018-08-02 11:28 ` [PATCH v2 1/4] driver/scsi/fnic/fnic_trace: Use kvcalloc instead of vmalloc+memset zhong jiang
2018-08-02 11:28 ` zhong jiang
2018-08-02 11:28 ` [PATCH v2 2/4] drivers/scsi/dpt_i2o: Use dma_zalloc_coherent to repalce dma_alloc_coherent+memset zhong jiang
2018-08-02 11:28 ` zhong jiang
2018-08-02 11:28 ` [PATCH v2 3/4] drivers/scsi/snic/snic_trc: Use kvcalloc instead of vmalloc+memset zhong jiang
2018-08-02 11:28 ` zhong jiang
2018-08-02 11:28 ` [PATCH v2 4/4] drivers/scsi/mvsas/mv_init: Use dma_zalloc_coherent to replace dma_alloc_coherent+memset zhong jiang
2018-08-02 11:28 ` zhong jiang
2018-08-23 11:25 ` [PATCH v2 0/4] Use dma_zalloc_coherent and kvcalloc to replace open code zhong jiang
2018-08-23 11:25 ` zhong jiang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.