Re: [PATCH] scsi: megaraid: Use zeroing memory allocator than allocator/memset

2018-01-04 Thread Himanshu Jha
Hi Shivashran,

On Thu, Jan 04, 2018 at 04:52:54PM +0530, Shivasharan Srikanteshwara wrote:
> > -Original Message-
> > From: Himanshu Jha [mailto:himanshujha199...@gmail.com]
> > Sent: Saturday, December 30, 2017 9:18 PM
> > To: martin.peter...@oracle.com; j...@linux.vnet.ibm.com
> > Cc: kashyap.de...@broadcom.com; sumit.sax...@broadcom.com;
> > shivasharan.srikanteshw...@broadcom.com;
> > megaraidlinux@broadcom.com; linux-s...@vger.kernel.org; linux-
> > ker...@vger.kernel.org; mcg...@kernel.org; Himanshu Jha
> > <himanshujha199...@gmail.com>
> > Subject: [PATCH] scsi: megaraid: Use zeroing memory allocator than
> > allocator/memset
> >
> > Use pci_zalloc_consistent for allocating zeroed memory and remove
> > unnecessary memset function.
> >
> > Done using Coccinelle.
> > Generated-by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci
> > 0-day tested with no failures.
> >
> > Suggested-by: Luis R. Rodriguez <mcg...@kernel.org>
> > Signed-off-by: Himanshu Jha <himanshujha199...@gmail.com>
> > ---
> >  drivers/scsi/megaraid/megaraid_sas_base.c   | 19 ++-
> >  drivers/scsi/megaraid/megaraid_sas_fusion.c |  5 ++---
> >  2 files changed, 8 insertions(+), 16 deletions(-)
> >
> 
> Hi Himanshu,
> I can see one more allocation done in megasas_get_seq_num() that could
> make use of these changes.

Yes, I missed that case! Thanks for pointing that out.

> Also, there is a driver update patchset that I am planning to post today.
> Adding this patch first might require additional rebasing of this
> patchset.
> Would you be ok if I send a separate patch for this along with the change
> mentioned above once my patch series gets committed?
> That would save me some rebasing effort. :-)

Yeah, sure! I have no objections for it. But this patch was not in the
patchseries that I sent a while ago https://lkml.org/lkml/2017/12/30/77

Thanks
Himanshu Jha


Re: [PATCH] scsi: megaraid: Use zeroing memory allocator than allocator/memset

2018-01-04 Thread Himanshu Jha
Hi Shivashran,

On Thu, Jan 04, 2018 at 04:52:54PM +0530, Shivasharan Srikanteshwara wrote:
> > -Original Message-
> > From: Himanshu Jha [mailto:himanshujha199...@gmail.com]
> > Sent: Saturday, December 30, 2017 9:18 PM
> > To: martin.peter...@oracle.com; j...@linux.vnet.ibm.com
> > Cc: kashyap.de...@broadcom.com; sumit.sax...@broadcom.com;
> > shivasharan.srikanteshw...@broadcom.com;
> > megaraidlinux@broadcom.com; linux-s...@vger.kernel.org; linux-
> > ker...@vger.kernel.org; mcg...@kernel.org; Himanshu Jha
> > 
> > Subject: [PATCH] scsi: megaraid: Use zeroing memory allocator than
> > allocator/memset
> >
> > Use pci_zalloc_consistent for allocating zeroed memory and remove
> > unnecessary memset function.
> >
> > Done using Coccinelle.
> > Generated-by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci
> > 0-day tested with no failures.
> >
> > Suggested-by: Luis R. Rodriguez 
> > Signed-off-by: Himanshu Jha 
> > ---
> >  drivers/scsi/megaraid/megaraid_sas_base.c   | 19 ++-
> >  drivers/scsi/megaraid/megaraid_sas_fusion.c |  5 ++---
> >  2 files changed, 8 insertions(+), 16 deletions(-)
> >
> 
> Hi Himanshu,
> I can see one more allocation done in megasas_get_seq_num() that could
> make use of these changes.

Yes, I missed that case! Thanks for pointing that out.

> Also, there is a driver update patchset that I am planning to post today.
> Adding this patch first might require additional rebasing of this
> patchset.
> Would you be ok if I send a separate patch for this along with the change
> mentioned above once my patch series gets committed?
> That would save me some rebasing effort. :-)

Yeah, sure! I have no objections for it. But this patch was not in the
patchseries that I sent a while ago https://lkml.org/lkml/2017/12/30/77

Thanks
Himanshu Jha


RE: [PATCH] scsi: megaraid: Use zeroing memory allocator than allocator/memset

2018-01-04 Thread Shivasharan Srikanteshwara
> -Original Message-
> From: Himanshu Jha [mailto:himanshujha199...@gmail.com]
> Sent: Saturday, December 30, 2017 9:18 PM
> To: martin.peter...@oracle.com; j...@linux.vnet.ibm.com
> Cc: kashyap.de...@broadcom.com; sumit.sax...@broadcom.com;
> shivasharan.srikanteshw...@broadcom.com;
> megaraidlinux@broadcom.com; linux-s...@vger.kernel.org; linux-
> ker...@vger.kernel.org; mcg...@kernel.org; Himanshu Jha
> <himanshujha199...@gmail.com>
> Subject: [PATCH] scsi: megaraid: Use zeroing memory allocator than
> allocator/memset
>
> Use pci_zalloc_consistent for allocating zeroed memory and remove
> unnecessary memset function.
>
> Done using Coccinelle.
> Generated-by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci
> 0-day tested with no failures.
>
> Suggested-by: Luis R. Rodriguez <mcg...@kernel.org>
> Signed-off-by: Himanshu Jha <himanshujha199...@gmail.com>
> ---
>  drivers/scsi/megaraid/megaraid_sas_base.c   | 19 ++-
>  drivers/scsi/megaraid/megaraid_sas_fusion.c |  5 ++---
>  2 files changed, 8 insertions(+), 16 deletions(-)
>

Hi Himanshu,
I can see one more allocation done in megasas_get_seq_num() that could
make use of these changes.
Rest of the changes looks fine.

Also, there is a driver update patchset that I am planning to post today.
Adding this patch first might require additional rebasing of this
patchset.
Would you be ok if I send a separate patch for this along with the change
mentioned above once my patch series gets committed?
That would save me some rebasing effort. :-)

Thanks,
Shivasharan


RE: [PATCH] scsi: megaraid: Use zeroing memory allocator than allocator/memset

2018-01-04 Thread Shivasharan Srikanteshwara
> -Original Message-
> From: Himanshu Jha [mailto:himanshujha199...@gmail.com]
> Sent: Saturday, December 30, 2017 9:18 PM
> To: martin.peter...@oracle.com; j...@linux.vnet.ibm.com
> Cc: kashyap.de...@broadcom.com; sumit.sax...@broadcom.com;
> shivasharan.srikanteshw...@broadcom.com;
> megaraidlinux@broadcom.com; linux-s...@vger.kernel.org; linux-
> ker...@vger.kernel.org; mcg...@kernel.org; Himanshu Jha
> 
> Subject: [PATCH] scsi: megaraid: Use zeroing memory allocator than
> allocator/memset
>
> Use pci_zalloc_consistent for allocating zeroed memory and remove
> unnecessary memset function.
>
> Done using Coccinelle.
> Generated-by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci
> 0-day tested with no failures.
>
> Suggested-by: Luis R. Rodriguez 
> Signed-off-by: Himanshu Jha 
> ---
>  drivers/scsi/megaraid/megaraid_sas_base.c   | 19 ++-
>  drivers/scsi/megaraid/megaraid_sas_fusion.c |  5 ++---
>  2 files changed, 8 insertions(+), 16 deletions(-)
>

Hi Himanshu,
I can see one more allocation done in megasas_get_seq_num() that could
make use of these changes.
Rest of the changes looks fine.

Also, there is a driver update patchset that I am planning to post today.
Adding this patch first might require additional rebasing of this
patchset.
Would you be ok if I send a separate patch for this along with the change
mentioned above once my patch series gets committed?
That would save me some rebasing effort. :-)

Thanks,
Shivasharan


[PATCH] scsi: megaraid: Use zeroing memory allocator than allocator/memset

2017-12-30 Thread Himanshu Jha
Use pci_zalloc_consistent for allocating zeroed
memory and remove unnecessary memset function.

Done using Coccinelle.
Generated-by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci
0-day tested with no failures.

Suggested-by: Luis R. Rodriguez 
Signed-off-by: Himanshu Jha 
---
 drivers/scsi/megaraid/megaraid_sas_base.c   | 19 ++-
 drivers/scsi/megaraid/megaraid_sas_fusion.c |  5 ++---
 2 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index 2c8cfa2..62959d0 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -,10 +,9 @@ static int megasas_get_ld_vf_affiliation_111(struct 
megasas_instance *instance,
memset(instance->vf_affiliation_111, 0,
   sizeof(struct MR_LD_VF_AFFILIATION_111));
else {
-   new_affiliation_111 =
-   pci_alloc_consistent(instance->pdev,
-sizeof(struct 
MR_LD_VF_AFFILIATION_111),
-_affiliation_111_h);
+   new_affiliation_111 =
+   pci_zalloc_consistent(instance->pdev,
+   sizeof(struct MR_LD_VF_AFFILIATION_111),
+   _affiliation_111_h);
if (!new_affiliation_111) {
dev_printk(KERN_DEBUG, >pdev->dev, "SR-IOV: 
Couldn't allocate "
   "memory for new affiliation for scsi%d\n",
@@ -2233,8 +2232,6 @@ static int megasas_get_ld_vf_affiliation_111(struct 
megasas_instance *instance,
megasas_return_cmd(instance, cmd);
return -ENOMEM;
}
-   memset(new_affiliation_111, 0,
-  sizeof(struct MR_LD_VF_AFFILIATION_111));
}
 
memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE);
@@ -2331,11 +2328,9 @@ static int megasas_get_ld_vf_affiliation_12(struct 
megasas_instance *instance,
memset(instance->vf_affiliation, 0, (MAX_LOGICAL_DRIVES + 1) *
   sizeof(struct MR_LD_VF_AFFILIATION));
else {
-   new_affiliation =
-   pci_alloc_consistent(instance->pdev,
-(MAX_LOGICAL_DRIVES + 1) *
-sizeof(struct 
MR_LD_VF_AFFILIATION),
-_affiliation_h);
+   new_affiliation =
+   pci_zalloc_consistent(instance->pdev,
+   (MAX_LOGICAL_DRIVES + 1) *
+   sizeof(struct 
MR_LD_VF_AFFILIATION),
+   _affiliation_h);
if (!new_affiliation) {
dev_printk(KERN_DEBUG, >pdev->dev, "SR-IOV: 
Couldn't allocate "
   "memory for new affiliation for scsi%d\n",
@@ -2343,8 +2338,6 @@ static int megasas_get_ld_vf_affiliation_12(struct 
megasas_instance *instance,
megasas_return_cmd(instance, cmd);
return -ENOMEM;
}
-   memset(new_affiliation, 0, (MAX_LOGICAL_DRIVES + 1) *
-  sizeof(struct MR_LD_VF_AFFILIATION));
}
 
memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE);
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 65dc4fe..5f61b93 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -690,15 +690,14 @@ megasas_alloc_rdpq_fusion(struct megasas_instance 
*instance)
array_size = sizeof(struct MPI2_IOC_INIT_RDPQ_ARRAY_ENTRY) *
 MAX_MSIX_QUEUES_FUSION;
 
-   fusion->rdpq_virt = pci_alloc_consistent(instance->pdev, array_size,
->rdpq_phys);
+   fusion->rdpq_virt = pci_zalloc_consistent(instance->pdev, array_size,
+ >rdpq_phys);
if (!fusion->rdpq_virt) {
dev_err(>pdev->dev,
"Failed from %s %d\n",  __func__, __LINE__);
return -ENOMEM;
}
 
-   memset(fusion->rdpq_virt, 0, array_size);
msix_count = instance->msix_vectors > 0 ? instance->msix_vectors : 1;
 
fusion->reply_frames_desc_pool = dma_pool_create("mr_rdpq",
-- 
2.7.4



[PATCH] scsi: megaraid: Use zeroing memory allocator than allocator/memset

2017-12-30 Thread Himanshu Jha
Use pci_zalloc_consistent for allocating zeroed
memory and remove unnecessary memset function.

Done using Coccinelle.
Generated-by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci
0-day tested with no failures.

Suggested-by: Luis R. Rodriguez 
Signed-off-by: Himanshu Jha 
---
 drivers/scsi/megaraid/megaraid_sas_base.c   | 19 ++-
 drivers/scsi/megaraid/megaraid_sas_fusion.c |  5 ++---
 2 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index 2c8cfa2..62959d0 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -,10 +,9 @@ static int megasas_get_ld_vf_affiliation_111(struct 
megasas_instance *instance,
memset(instance->vf_affiliation_111, 0,
   sizeof(struct MR_LD_VF_AFFILIATION_111));
else {
-   new_affiliation_111 =
-   pci_alloc_consistent(instance->pdev,
-sizeof(struct 
MR_LD_VF_AFFILIATION_111),
-_affiliation_111_h);
+   new_affiliation_111 =
+   pci_zalloc_consistent(instance->pdev,
+   sizeof(struct MR_LD_VF_AFFILIATION_111),
+   _affiliation_111_h);
if (!new_affiliation_111) {
dev_printk(KERN_DEBUG, >pdev->dev, "SR-IOV: 
Couldn't allocate "
   "memory for new affiliation for scsi%d\n",
@@ -2233,8 +2232,6 @@ static int megasas_get_ld_vf_affiliation_111(struct 
megasas_instance *instance,
megasas_return_cmd(instance, cmd);
return -ENOMEM;
}
-   memset(new_affiliation_111, 0,
-  sizeof(struct MR_LD_VF_AFFILIATION_111));
}
 
memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE);
@@ -2331,11 +2328,9 @@ static int megasas_get_ld_vf_affiliation_12(struct 
megasas_instance *instance,
memset(instance->vf_affiliation, 0, (MAX_LOGICAL_DRIVES + 1) *
   sizeof(struct MR_LD_VF_AFFILIATION));
else {
-   new_affiliation =
-   pci_alloc_consistent(instance->pdev,
-(MAX_LOGICAL_DRIVES + 1) *
-sizeof(struct 
MR_LD_VF_AFFILIATION),
-_affiliation_h);
+   new_affiliation =
+   pci_zalloc_consistent(instance->pdev,
+   (MAX_LOGICAL_DRIVES + 1) *
+   sizeof(struct 
MR_LD_VF_AFFILIATION),
+   _affiliation_h);
if (!new_affiliation) {
dev_printk(KERN_DEBUG, >pdev->dev, "SR-IOV: 
Couldn't allocate "
   "memory for new affiliation for scsi%d\n",
@@ -2343,8 +2338,6 @@ static int megasas_get_ld_vf_affiliation_12(struct 
megasas_instance *instance,
megasas_return_cmd(instance, cmd);
return -ENOMEM;
}
-   memset(new_affiliation, 0, (MAX_LOGICAL_DRIVES + 1) *
-  sizeof(struct MR_LD_VF_AFFILIATION));
}
 
memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE);
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 65dc4fe..5f61b93 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -690,15 +690,14 @@ megasas_alloc_rdpq_fusion(struct megasas_instance 
*instance)
array_size = sizeof(struct MPI2_IOC_INIT_RDPQ_ARRAY_ENTRY) *
 MAX_MSIX_QUEUES_FUSION;
 
-   fusion->rdpq_virt = pci_alloc_consistent(instance->pdev, array_size,
->rdpq_phys);
+   fusion->rdpq_virt = pci_zalloc_consistent(instance->pdev, array_size,
+ >rdpq_phys);
if (!fusion->rdpq_virt) {
dev_err(>pdev->dev,
"Failed from %s %d\n",  __func__, __LINE__);
return -ENOMEM;
}
 
-   memset(fusion->rdpq_virt, 0, array_size);
msix_count = instance->msix_vectors > 0 ? instance->msix_vectors : 1;
 
fusion->reply_frames_desc_pool = dma_pool_create("mr_rdpq",
-- 
2.7.4