Skip to contentSkip to conversation

scsi/mvsas/mv_sas.c: Use dma_pool_zalloc

PATCH Applied Sabyasachi Gupta 4 participants 4 messages Oct 18, 2018 – Oct 24, 2018 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi/mvsas/mv_sas.c: Use dma_pool_zalloc

Replaced dma_pool_alloc + memset with dma_pool_zalloc

---
 drivers/scsi/mvsas/mv_sas.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/mvsas/mv_sas.c +1 -2
index cff43bd..d00d37d 100644
@@ -790,12 +790,11 @@ static int mvs_task_prep(struct sas_task *task, struct mvs_info *mvi, int is_tmf
 	slot->n_elem = n_elem;
 	slot->slot_tag = tag;
 
-	slot->buf = dma_pool_alloc(mvi->dma_pool, GFP_ATOMIC, &slot->buf_dma);
+	slot->buf = dma_pool_zalloc(mvi->dma_pool, GFP_ATOMIC, &slot->buf_dma);
 	if (!slot->buf) {
 		rc = -ENOMEM;
 		goto err_out_tag;
 	}
-	memset(slot->buf, 0, MVS_SLOT_BUF_SZ);
 
 	tei.task = task;
 	tei.hdr = &mvi->slot[tag];
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Sabyasachi Gupta

Replaced dma_pool_alloc + memset with dma_pool_zalloc

Thanks!

Quoted 3 lines
---
 drivers/scsi/mvsas/mv_sas.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
Signature · 15 lines
Jack Wang
Linux Kernel Developer

ProfitBricks GmbH
Greifswalder Str. 207
D - 10405 Berlin

Tel:       +49 30 577 008  042
Fax:      +49 30 577 008 299
Email:    [email protected]
URL:      https://www.profitbricks.de

Sitz der Gesellschaft: Berlin
Registergericht: Amtsgericht Charlottenburg, HRB 125506 B
Geschäftsführer: Achim Weiss, Matthias Steinberg, Christoph Steffens
#2 lore raw
In reply to Sabyasachi Gupta
Quoted 12 lines · Sabyasachi Gupta

Replaced dma_pool_alloc + memset with dma_pool_zalloc

---
 drivers/scsi/mvsas/mv_sas.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/mvsas/mv_sas.c +0 -0
index cff43bd..d00d37d 100644
@@ -790,12 +790,11 @@ static int mvs_task_prep(struct sas_task *task, struct mvs_info *mvi, int is_tmf
 	slot->n_elem = n_elem;

drivers/scsi/mvsas/mv_sas.c static int mvs_task_prep(struct sas_task *task, struct mvs_info *mvi, int is_tmf · line 798

Quoted 10 lines
drivers/scsi/mvsas/mv_sas.c +1 -2
 	slot->slot_tag = tag;
 
-	slot->buf = dma_pool_alloc(mvi->dma_pool, GFP_ATOMIC, &slot->buf_dma);
+	slot->buf = dma_pool_zalloc(mvi->dma_pool, GFP_ATOMIC, &slot->buf_dma);
 	if (!slot->buf) {
 		rc = -ENOMEM;
 		goto err_out_tag;
 	}
-	memset(slot->buf, 0, MVS_SLOT_BUF_SZ);
 

How about also fixing these, below, up to use dma_zalloc_coherent() or even dmam_alloc_coherent() [as they're manually free'd at removal]:

static int mvs_alloc(struct mvs_info *mvi, struct Scsi_Host *shost)

{
    int i = 0, slot_nr;
    char pool_name[32];
...
    /*
     * alloc and init our DMA areas
     */
    mvi->tx = dma_alloc_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);

...

Thanks,
John

Quoted 3 lines
drivers/scsi/mvsas/mv_sas.c +0 -0
 	tei.task = task;
 	tei.hdr = &mvi->slot[tag];