diff mbox series

[v2] scsi: Don't call memset after dma_alloc_coherent()

Message ID 20200820234952.317313-1-alex.dewar90@gmail.com
State New
Headers show
Series [v2] scsi: Don't call memset after dma_alloc_coherent() | expand

Commit Message

Alex Dewar Aug. 20, 2020, 11:49 p.m. UTC
dma_alloc_coherent() already zeroes memory, so the extra call to
memset() is unnecessary.

Issue identified with Coccinelle.

Signed-off-by: Alex Dewar <alex.dewar90@gmail.com>
---
v2: I've noticed a few other places in the scsi subsystem with this
pattern, so lets fix them all with one patch.
---
 drivers/scsi/mpt3sas/mpt3sas_base.c | 1 -
 drivers/scsi/mvsas/mv_init.c        | 4 ----
 drivers/scsi/pmcraid.c              | 1 -
 drivers/scsi/qla2xxx/qla_mbx.c      | 2 --
 4 files changed, 8 deletions(-)

Comments

Martin K. Petersen Sept. 2, 2020, 1:22 a.m. UTC | #1
Alex,

> dma_alloc_coherent() already zeroes memory, so the extra call to
> memset() is unnecessary.

One patch per driver, please.

Thanks!
Alex Dewar Sept. 2, 2020, 4:03 p.m. UTC | #2
On Tue, Sep 01, 2020 at 09:22:44PM -0400, Martin K. Petersen wrote:
> 
> Alex,
> 
> > dma_alloc_coherent() already zeroes memory, so the extra call to
> > memset() is unnecessary.
> 
> One patch per driver, please.

Nvm, someone's already beaten me to the punch!
> 
> Thanks!
> 
> -- 
> Martin K. Petersen	Oracle Linux Engineering
Martin K. Petersen Sept. 3, 2020, 1:20 a.m. UTC | #3
Alex,

> Nvm, someone's already beaten me to the punch!

Yep, that one was already fixed up. Thanks!
diff mbox series

Patch

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c
index b66d3f9b717f..36b6c0d67353 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -5259,7 +5259,6 @@  _base_allocate_memory_pools(struct MPT3SAS_ADAPTER *ioc)
 		_base_release_memory_pools(ioc);
 		goto retry_allocation;
 	}
-	memset(ioc->request, 0, sz);
 
 	if (retry_sz)
 		ioc_err(ioc, "request pool: dma_alloc_coherent succeed: hba_depth(%d), chains_per_io(%d), frame_sz(%d), total(%d kb)\n",
diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c
index 978f5283c883..6aa2697c4a15 100644
--- a/drivers/scsi/mvsas/mv_init.c
+++ b/drivers/scsi/mvsas/mv_init.c
@@ -246,19 +246,16 @@  static int mvs_alloc(struct mvs_info *mvi, struct Scsi_Host *shost)
 				     &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, 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,
 				     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;
 
@@ -267,7 +264,6 @@  static int mvs_alloc(struct mvs_info *mvi, struct Scsi_Host *shost)
 				       &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,
diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
index aa9ae2ae8579..d99568fdf4af 100644
--- a/drivers/scsi/pmcraid.c
+++ b/drivers/scsi/pmcraid.c
@@ -4716,7 +4716,6 @@  static int pmcraid_allocate_host_rrqs(struct pmcraid_instance *pinstance)
 			return -ENOMEM;
 		}
 
-		memset(pinstance->hrrq_start[i], 0, buffer_size);
 		pinstance->hrrq_curr[i] = pinstance->hrrq_start[i];
 		pinstance->hrrq_end[i] =
 			pinstance->hrrq_start[i] + PMCRAID_MAX_CMD - 1;
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 226f1428d3e5..e00f604bbf7a 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -4925,8 +4925,6 @@  qla25xx_set_els_cmds_supported(scsi_qla_host_t *vha)
 		return QLA_MEMORY_ALLOC_FAILED;
 	}
 
-	memset(els_cmd_map, 0, ELS_CMD_MAP_SIZE);
-
 	/* List of Purex ELS */
 	cmd_opcode[0] = ELS_FPIN;
 	cmd_opcode[1] = ELS_RDP;