Skip to contentSkip to conversation

scsi/mvsas/mv_init.c: Use dma_zalloc_coherent

PATCH In review Sabyasachi Gupta 3 participants 9 messages Nov 21, 2018 – Jan 7, 2019 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi/mvsas/mv_init.c: Use dma_zalloc_coherent

Replace dma_alloc_coherent + memset with dma_zalloc_coherent

---
 drivers/scsi/mvsas/mv_init.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/scsi/mvsas/mv_init.c +4 -8
index 3ac3437..495bddb 100644
@@ -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,
Signature · 1 line
2.7.4
#1 lore raw
Quoted 4 lines · Sabyasachi Gupta

Replace dma_alloc_coherent + memset with dma_zalloc_coherent

Any comment on this patch?

Quoted 49 lines
---
 drivers/scsi/mvsas/mv_init.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/scsi/mvsas/mv_init.c +4 -9
index 3ac3437..495bddb 100644
@@ -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,
--

2.7.4

#2 lore raw
Quoted 9 lines · Sabyasachi Gupta
Quoted 4 lines · Sabyasachi Gupta

Replace dma_alloc_coherent + memset with dma_zalloc_coherent

Any comment on this patch?

Any comment on this patch?

Quoted 50 lines
Quoted 50 lines
---
 drivers/scsi/mvsas/mv_init.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/scsi/mvsas/mv_init.c +4 -9
index 3ac3437..495bddb 100644
@@ -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,
--

2.7.4

#3 lore raw
Quoted 7 lines · Sabyasachi Gupta
Quoted 4 lines · Sabyasachi Gupta
Quoted 1 line · Sabyasachi Gupta
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Replace dma_alloc_coherent + memset with dma_zalloc_coherent

Any comment on this patch?

Any comment on this patch?

Any comment on this patch?

Quoted 51 lines
Quoted 51 lines
Quoted 51 lines

---
 drivers/scsi/mvsas/mv_init.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/scsi/mvsas/mv_init.c +4 -9
index 3ac3437..495bddb 100644
@@ -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,
--

2.7.4

#4 lore raw
Quoted 11 lines · Sabyasachi Gupta
Quoted 9 lines · Sabyasachi Gupta
Quoted 6 lines · Sabyasachi Gupta
Quoted 3 lines · Sabyasachi Gupta

Replace dma_alloc_coherent + memset with dma_zalloc_coherent

If you're going to make this change, then how about change these to the managed version, so that we can avoid the explicit free'ing at driver removal?

Quoted 14 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Any comment on this patch?

Any comment on this patch?

Any comment on this patch?

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

---
 drivers/scsi/mvsas/mv_init.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/scsi/mvsas/mv_init.c +0 -0
index 3ac3437..495bddb 100644
Quoted 8 lines
Quoted 8 lines

drivers/scsi/mvsas/mv_init.c static int mvs_alloc(struct mvs_info *mvi, struct Scsi_Host *shost) · line 258

Quoted 8 lines
drivers/scsi/mvsas/mv_init.c +1 -1
@@ -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);

I'm guessing that this does not pass checkpatch with --strict option.

Thanks,
John

Quoted 36 lines
Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
drivers/scsi/mvsas/mv_init.c +3 -7
        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);
 
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/scsi/mvsas/mv_init.c +0 -1
        mvi->bulk_buffer = dma_alloc_coherent(mvi->dev,
                                       TRASH_BUCKET_SIZE,
--

2.7.4

.

#5 lore raw
Quoted 11 lines · John Garry
Quoted 9 lines · Sabyasachi Gupta
Quoted 7 lines · Sabyasachi Gupta
Quoted 4 lines · Sabyasachi Gupta
Quoted 1 line · Sabyasachi Gupta
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Replace dma_alloc_coherent + memset with dma_zalloc_coherent

If you're going to make this change, then how about change these to the managed version, so that we can avoid the explicit free'ing at driver removal?

I can't get it

Quoted 30 lines
Quoted 15 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Any comment on this patch?

Any comment on this patch?

Any comment on this patch?

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

---
 drivers/scsi/mvsas/mv_init.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/scsi/mvsas/mv_init.c +0 -0
index 3ac3437..495bddb 100644
Quoted 8 lines
Quoted 8 lines

drivers/scsi/mvsas/mv_init.c static int mvs_alloc(struct mvs_info *mvi, struct Scsi_Host *shost) · line 258

Quoted 8 lines
drivers/scsi/mvsas/mv_init.c +1 -1
@@ -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);

I'm guessing that this does not pass checkpatch with --strict option.

Quoted 2 lines

Thanks,
John

I have not not checked with --strict option

Quoted 39 lines
Quoted 37 lines
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
drivers/scsi/mvsas/mv_init.c +3 -7
        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);
 
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/scsi/mvsas/mv_init.c +0 -1
        mvi->bulk_buffer = dma_alloc_coherent(mvi->dev,
                                       TRASH_BUCKET_SIZE,
--

2.7.4

.

#6 lore raw
Quoted 12 lines · Sabyasachi Gupta
Quoted 11 lines · John Garry
Quoted 9 lines · Sabyasachi Gupta
Quoted 7 lines · Sabyasachi Gupta
Quoted 4 lines · Sabyasachi Gupta
Quoted 1 line · Sabyasachi Gupta
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Replace dma_alloc_coherent + memset with dma_zalloc_coherent

If you're going to make this change, then how about change these to the managed version, so that we can avoid the explicit free'ing at driver removal?

I can't get it

Please see dmam_alloc_coherent(). You can set __GFP_ZERO in the gfp argument to memset(0).

I would say that this is a more useful change.

Quoted 31 lines
Quoted 31 lines
Quoted 16 lines
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Any comment on this patch?

Any comment on this patch?

Any comment on this patch?

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

---
 drivers/scsi/mvsas/mv_init.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/scsi/mvsas/mv_init.c +0 -0
index 3ac3437..495bddb 100644
Quoted 8 lines
Quoted 8 lines

drivers/scsi/mvsas/mv_init.c static int mvs_alloc(struct mvs_info *mvi, struct Scsi_Host *shost) · line 258

Quoted 8 lines
drivers/scsi/mvsas/mv_init.c +1 -1
@@ -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);

I'm guessing that this does not pass checkpatch with --strict option.

Quoted 4 lines
Quoted 2 lines

Thanks,
John

I have not not checked with --strict option

It may warn that you're not maintaining alignment.

Quoted 43 lines
Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
drivers/scsi/mvsas/mv_init.c +3 -7
        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);
 
Quoted 10 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/scsi/mvsas/mv_init.c +0 -1
        mvi->bulk_buffer = dma_alloc_coherent(mvi->dev,
                                       TRASH_BUCKET_SIZE,
--

2.7.4

.

.

#7 lore raw
Quoted 17 lines · John Garry
Quoted 15 lines · Sabyasachi Gupta
Quoted 14 lines · John Garry
Quoted 11 lines · Sabyasachi Gupta
Quoted 9 lines · Sabyasachi Gupta
Quoted 6 lines · Sabyasachi Gupta
Quoted 3 lines · Sabyasachi Gupta

Replace dma_alloc_coherent + memset with dma_zalloc_coherent

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

If you're going to make this change, then how about change these to the managed version, so that we can avoid the explicit free'ing at driver removal?

I can't get it

Please see dmam_alloc_coherent(). You can set __GFP_ZERO in the gfp argument to memset(0).

and dma_zalloc_coherent() did the same. So both are same right ? No ?

Quoted 86 lines

I would say that this is a more useful change.

Quoted 31 lines
Quoted 31 lines
Quoted 16 lines
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Any comment on this patch?

Any comment on this patch?

Any comment on this patch?

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

---
 drivers/scsi/mvsas/mv_init.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/scsi/mvsas/mv_init.c +0 -0
index 3ac3437..495bddb 100644
Quoted 8 lines
Quoted 8 lines

drivers/scsi/mvsas/mv_init.c static int mvs_alloc(struct mvs_info *mvi, struct Scsi_Host *shost) · line 258

Quoted 8 lines
drivers/scsi/mvsas/mv_init.c +1 -1
@@ -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);

I'm guessing that this does not pass checkpatch with --strict option.

Quoted 4 lines
Quoted 2 lines

Thanks,
John

I have not not checked with --strict option

It may warn that you're not maintaining alignment.

Quoted 43 lines
Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
drivers/scsi/mvsas/mv_init.c +3 -7
        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);
 
Quoted 10 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/scsi/mvsas/mv_init.c +0 -1
        mvi->bulk_buffer = dma_alloc_coherent(mvi->dev,
                                       TRASH_BUCKET_SIZE,
--

2.7.4

.

.

#8 lore raw
Quoted 22 lines · Souptick Joarder
Quoted 21 lines · John Garry
Quoted 19 lines · Sabyasachi Gupta
Quoted 17 lines · John Garry
Quoted 11 lines · Sabyasachi Gupta
Quoted 9 lines · Sabyasachi Gupta
Quoted 6 lines · Sabyasachi Gupta
Quoted 3 lines · Sabyasachi Gupta

Replace dma_alloc_coherent + memset with dma_zalloc_coherent

If you're going to make this change, then how about change these to the managed version, so that we can avoid the explicit free'ing at driver removal?

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

I can't get it

Please see dmam_alloc_coherent(). You can set __GFP_ZERO in the gfp argument to memset(0).

and dma_zalloc_coherent() did the same. So both are same right ? No ?

Firstly I would to say that I am not so keen on changes like this since (I assume) it will not be tested at all.

However, having said that, the reason to use dmam_alloc_coherent() is that you can also drop the dma_free_coherent() in mvs_free(). But changes like that would actually require some code analysis effort...

John

Quoted 89 lines
Quoted 34 lines

I would say that this is a more useful change.

Quoted 31 lines
Quoted 31 lines
Quoted 16 lines
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Any comment on this patch?

Any comment on this patch?

Any comment on this patch?

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

---
 drivers/scsi/mvsas/mv_init.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/scsi/mvsas/mv_init.c +0 -0
index 3ac3437..495bddb 100644
Quoted 8 lines
Quoted 8 lines

drivers/scsi/mvsas/mv_init.c static int mvs_alloc(struct mvs_info *mvi, struct Scsi_Host *shost) · line 258

Quoted 8 lines
drivers/scsi/mvsas/mv_init.c +1 -1
@@ -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);

I'm guessing that this does not pass checkpatch with --strict option.

Quoted 52 lines
Quoted 4 lines
Quoted 2 lines

Thanks,
John

I have not not checked with --strict option

It may warn that you're not maintaining alignment.

Quoted 43 lines
Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
drivers/scsi/mvsas/mv_init.c +3 -7
        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);
 
Quoted 10 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/scsi/mvsas/mv_init.c +0 -1
        mvi->bulk_buffer = dma_alloc_coherent(mvi->dev,
                                       TRASH_BUCKET_SIZE,
--

2.7.4

.

.

.