2019-12-25 13:25:01

by Yu Kuai

[permalink] [raw]
Subject: [PATCH] scsi: don't memset to zero after dma_alloc_coherent

dma_alloc_coherent already zeros out memory, so memset to zero is not
needed.

Signed-off-by: yu kuai <[email protected]>
---
arch/sh/mm/consistent.c | 2 --
drivers/scsi/dpt_i2o.c | 4 ----
drivers/scsi/mpt3sas/mpt3sas_base.c | 1 -
drivers/scsi/mvsas/mv_init.c | 4 ----
drivers/scsi/pmcraid.c | 1 -
5 files changed, 12 deletions(-)

diff --git a/arch/sh/mm/consistent.c b/arch/sh/mm/consistent.c
index 3169a343a5ab..0de206c1acfe 100644
--- a/arch/sh/mm/consistent.c
+++ b/arch/sh/mm/consistent.c
@@ -57,8 +57,6 @@ int __init platform_resource_setup_memory(struct platform_device *pdev,
return -ENOMEM;
}

- memset(buf, 0, memsize);
-
r->flags = IORESOURCE_MEM;
r->start = dma_handle;
r->end = r->start + memsize - 1;
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index abc74fd474dc..b1b879beebfb 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -1331,7 +1331,6 @@ static s32 adpt_i2o_reset_hba(adpt_hba* pHba)
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;
@@ -2803,7 +2802,6 @@ static s32 adpt_i2o_init_outbound_q(adpt_hba* pHba)
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]);
@@ -2857,7 +2855,6 @@ static s32 adpt_i2o_init_outbound_q(adpt_hba* pHba)
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),
@@ -3092,7 +3089,6 @@ static int adpt_i2o_build_sys_table(void)
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;
diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c
index 45fd8dfb7c40..663dd4df03e3 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -5090,7 +5090,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 7af9173c4925..e77f4d5a049c 100644
--- a/drivers/scsi/mvsas/mv_init.c
+++ b/drivers/scsi/mvsas/mv_init.c
@@ -244,19 +244,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;

@@ -265,7 +262,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 7eb88fe1eb0b..6976013cf4c7 100644
--- a/drivers/scsi/pmcraid.c
+++ b/drivers/scsi/pmcraid.c
@@ -4718,7 +4718,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;
--
2.17.2


2019-12-26 11:05:48

by Sergei Shtylyov

[permalink] [raw]
Subject: Re: [PATCH] scsi: don't memset to zero after dma_alloc_coherent

Hello!

On 25.12.2019 16:23, yu kuai wrote:

> dma_alloc_coherent already zeros out memory, so memset to zero is not
> needed.
>
> Signed-off-by: yu kuai <[email protected]>
> ---
> arch/sh/mm/consistent.c | 2 --

How this one is related to SCSI?

> drivers/scsi/dpt_i2o.c | 4 ----
> drivers/scsi/mpt3sas/mpt3sas_base.c | 1 -
> drivers/scsi/mvsas/mv_init.c | 4 ----
> drivers/scsi/pmcraid.c | 1 -
> 5 files changed, 12 deletions(-)
[...]

MBR, Sergei

2019-12-26 11:14:49

by Yu Kuai

[permalink] [raw]
Subject: Re: [PATCH] scsi: don't memset to zero after dma_alloc_coherent



On 2019/12/26 19:03, Sergei Shtylyov wrote:
> Hello!
>
> On 25.12.2019 16:23, yu kuai wrote:
>
>> dma_alloc_coherent already zeros out memory, so memset to zero is not
>> needed.
>>
>> Signed-off-by: yu kuai <[email protected]>
>> ---
>>   arch/sh/mm/consistent.c             | 2 --
>
>    How this one is related to SCSI?
>
Thank you for your response!
I put them in the same patch because I thougt they are the same
situation. I'm sorry if it's not appropriate.

Yu Kuai

2019-12-26 11:18:14

by Sergei Shtylyov

[permalink] [raw]
Subject: Re: [PATCH] scsi: don't memset to zero after dma_alloc_coherent

On 26.12.2019 14:13, yukuai (C) wrote:

>>> dma_alloc_coherent already zeros out memory, so memset to zero is not
>>> needed.
>>>
>>> Signed-off-by: yu kuai <[email protected]>
>>> ---
>>>   arch/sh/mm/consistent.c             | 2 --
>>
>>     How this one is related to SCSI?
>>
> Thank you for your response!
> I put them in the same patch because I thougt they are the same situation. I'm
> sorry if it's not appropriate.

I'd recommend to split such patch to (at least) different subsystems, e.g.
arch/sh/ part, drivers/scsi/ part.

> Yu Kuai

MBR, Sergei

2019-12-26 11:34:09

by Yu Kuai

[permalink] [raw]
Subject: Re: [PATCH] scsi: don't memset to zero after dma_alloc_coherent



On 2019/12/26 19:16, Sergei Shtylyov wrote:
> On 26.12.2019 14:13, yukuai (C) wrote:
>
>>>> dma_alloc_coherent already zeros out memory, so memset to zero is not
>>>> needed.
>>>>
>>>> Signed-off-by: yu kuai <[email protected]>
>>>> ---
>>>>   arch/sh/mm/consistent.c             | 2 --
>>>
>>>     How this one is related to SCSI?
>>>
>> Thank you for your response!
>> I put them in the same patch because I thougt they are the same
>> situation. I'm sorry if it's not appropriate.
>
>    I'd recommend to split such patch to (at least) different
> subsystems, e.g. arch/sh/ part, drivers/scsi/ part.

I'll do that, thank you again for your advise!

Yu Kuai