Skip to contentSkip to conversation

scsi: Remove unnecessary calls to memset after dma_alloc_coherent

PATCH Markus Elfring 2 participants 5 messages Apr 4, 2020 – Apr 9, 2020 SCSI

lore
Share & tools
lore
#0 lore raw
Quoted 2 lines

dma_alloc_coherent() now zeroes memory after allocation, so additional calls to memset() afterwards are unnecessary. Remove them.

I suggest to reconsider the distribution of recipients also for this patch according to the fields “Cc” and “To”.

…

Quoted 1 line

+++ b/drivers/scsi/dpt_i2o.c

…

Quoted 9 lines
(quoted diff) +2 -2
@@ -3067,13 +3064,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_len, &sys_tbl_pa, GFP_KERNEL);
+	sys_tbl = dma_alloc_coherent(&pHba->pDev->dev, sys_tbl_len,
+				     &sys_tbl_pa, GFP_KERNEL);
 	if (!sys_tbl) {

…

Quoted 2 lines

+++ b/drivers/scsi/mvsas/mv_init.c

(quoted diff) +0 -0
@@ -244,28 +244,22 @@ static int mvs_alloc(struct mvs_info *mvi, struct Scsi_Host *shost)

…

Quoted 5 lines
(quoted diff) +1 -2
-	mvi->slot = dma_alloc_coherent(mvi->dev,
-				       sizeof(*mvi->slot) * slot_nr,
+	mvi->slot = dma_alloc_coherent(mvi->dev, sizeof(*mvi->slot) * slot_nr,
 				       &mvi->slot_dma, GFP_KERNEL);
 	if (!mvi->slot)

…

Quoted 8 lines

+++ b/drivers/scsi/qla2xxx/qla_isr.c

(quoted diff) +1 -1
@@ -79,7 +79,7 @@ qla24xx_process_abts(struct scsi_qla_host *vha, void *pkt)
 	    (uint8_t *)abts, sizeof(*abts));
 
 	rsp_els = dma_alloc_coherent(&ha->pdev->dev, sizeof(*rsp_els), &dma,
-	    GFP_KERNEL);
+				     GFP_KERNEL);
 	if (!rsp_els) {

…

Review qla25xx_set_els_cmds_supported(scsi_qla_host_t *vha) · line 4891

Quoted 8 lines

+++ b/drivers/scsi/qla2xxx/qla_mbx.c

(quoted diff) +1 -1
@@ -4887,15 +4887,13 @@ qla25xx_set_els_cmds_supported(scsi_qla_host_t *vha)
 	    "Entered %s.\n", __func__);
 
 	els_cmd_map = dma_alloc_coherent(&ha->pdev->dev, ELS_CMD_MAP_SIZE,
-	    &els_cmd_map_dma, GFP_KERNEL);
+					 &els_cmd_map_dma, GFP_KERNEL);
 	if (!els_cmd_map) {

…

I find it safer to integrate such source code reformattings by another update step which will be separated from the proposed deletion of unwanted function calls.

Regards,
Markus

#1 lore raw
Quoted 5 lines · Markus Elfring
Quoted 2 lines

dma_alloc_coherent() now zeroes memory after allocation, so additional calls to memset() afterwards are unnecessary. Remove them.

I suggest to reconsider the distribution of recipients also for this patch according to the fields “Cc” and “To”.

Thanks. I'll do this in a v2/RESEND.

Quoted 43 lines

…

Quoted 1 line

+++ b/drivers/scsi/dpt_i2o.c

…

Quoted 9 lines
(quoted diff) +2 -2
@@ -3067,13 +3064,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_len, &sys_tbl_pa, GFP_KERNEL);
+	sys_tbl = dma_alloc_coherent(&pHba->pDev->dev, sys_tbl_len,
+				     &sys_tbl_pa, GFP_KERNEL);
 	if (!sys_tbl) {

…

Quoted 2 lines

+++ b/drivers/scsi/mvsas/mv_init.c

(quoted diff) +0 -0
@@ -244,28 +244,22 @@ static int mvs_alloc(struct mvs_info *mvi, struct Scsi_Host *shost)

…

Quoted 5 lines
(quoted diff) +1 -2
-	mvi->slot = dma_alloc_coherent(mvi->dev,
-				       sizeof(*mvi->slot) * slot_nr,
+	mvi->slot = dma_alloc_coherent(mvi->dev, sizeof(*mvi->slot) * slot_nr,
 				       &mvi->slot_dma, GFP_KERNEL);
 	if (!mvi->slot)

…

Quoted 8 lines

+++ b/drivers/scsi/qla2xxx/qla_isr.c

(quoted diff) +1 -1
@@ -79,7 +79,7 @@ qla24xx_process_abts(struct scsi_qla_host *vha, void *pkt)
 	    (uint8_t *)abts, sizeof(*abts));
 
 	rsp_els = dma_alloc_coherent(&ha->pdev->dev, sizeof(*rsp_els), &dma,
-	    GFP_KERNEL);
+				     GFP_KERNEL);
 	if (!rsp_els) {

…

Quoted 8 lines

+++ b/drivers/scsi/qla2xxx/qla_mbx.c

(quoted diff) +1 -1
@@ -4887,15 +4887,13 @@ qla25xx_set_els_cmds_supported(scsi_qla_host_t *vha)
 	    "Entered %s.\n", __func__);
 
 	els_cmd_map = dma_alloc_coherent(&ha->pdev->dev, ELS_CMD_MAP_SIZE,
-	    &els_cmd_map_dma, GFP_KERNEL);
+					 &els_cmd_map_dma, GFP_KERNEL);
 	if (!els_cmd_map) {

…

Quoted 3 lines

I find it safer to integrate such source code reformattings by another update step which will be separated from the proposed deletion of unwanted function calls.

Good point. This whitespace was autoformatted by Coccinelle, probably due to my bad SmPL skills.

Best,
Alex

Quoted 3 lines

Regards,
Markus

#2 lore raw
Quoted 11 lines
Quoted 11 lines

…

Quoted 8 lines

+++ b/drivers/scsi/qla2xxx/qla_mbx.c

(quoted diff) +1 -1
@@ -4887,15 +4887,13 @@ qla25xx_set_els_cmds_supported(scsi_qla_host_t *vha)
 	    "Entered %s.\n", __func__);
 
 	els_cmd_map = dma_alloc_coherent(&ha->pdev->dev, ELS_CMD_MAP_SIZE,
-	    &els_cmd_map_dma, GFP_KERNEL);
+					 &els_cmd_map_dma, GFP_KERNEL);
 	if (!els_cmd_map) {

…

Quoted 6 lines
Quoted 3 lines

I find it safer to integrate such source code reformattings by another update step which will be separated from the proposed deletion of unwanted function calls.

Good point. This whitespace was autoformatted by Coccinelle, probably due to my bad SmPL skills.

Some system factors can be involved here.

* The source code formatting can occasionally be improvable in further ways (despite of help by a software like Coccinelle).

* A change mixture can become more challenging.

* Would you like to extend your skills in corresponding areas anyhow?

Regards,
Markus

#3 lore raw
Quoted 18 lines · Markus Elfring
Quoted 11 lines
Quoted 11 lines

…

Quoted 8 lines

+++ b/drivers/scsi/qla2xxx/qla_mbx.c

(quoted diff) +1 -1
@@ -4887,15 +4887,13 @@ qla25xx_set_els_cmds_supported(scsi_qla_host_t *vha)
 	    "Entered %s.\n", __func__);
 
 	els_cmd_map = dma_alloc_coherent(&ha->pdev->dev, ELS_CMD_MAP_SIZE,
-	    &els_cmd_map_dma, GFP_KERNEL);
+					 &els_cmd_map_dma, GFP_KERNEL);
 	if (!els_cmd_map) {

…

Quoted 6 lines
Quoted 3 lines

I find it safer to integrate such source code reformattings by another update step which will be separated from the proposed deletion of unwanted function calls.

Good point. This whitespace was autoformatted by Coccinelle, probably due to my bad SmPL skills.

Quoted 8 lines

Some system factors can be involved here.

* The source code formatting can occasionally be improvable in further ways (despite of help by a software like Coccinelle).

* A change mixture can become more challenging.

* Would you like to extend your skills in corresponding areas anyhow?

Sure, I'd love to. Are there any resources you'd recommend? I'm just starting out with kernel stuff and would be grateful for any pointers you can offer :-)

Best,
Alex

Quoted 3 lines

Regards,
Markus

#4 lore raw
Quoted 3 lines
Quoted 1 line

* Would you like to extend your skills in corresponding areas anyhow?

Sure, I'd love to. Are there any resources you'd recommend?

How helpful do you find the available software documentation (and other communication interfaces)?

Regards,
Markus