mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Rangankar, Manish" <Manish.Rangankar@cavium.com>
To: Himanshu Jha <himanshujha199640@gmail.com>,
	"jejb@linux.vnet.ibm.com" <jejb@linux.vnet.ibm.com>,
	"martin.petersen@oracle.com" <martin.petersen@oracle.com>,
	"aacraid@adaptec.com" <aacraid@adaptec.com>
Cc: "Gurumurthy, Anil" <Anil.Gurumurthy@cavium.com>,
	"Kalluru, Sudarsana" <Sudarsana.Kalluru@cavium.com>,
	Dept-Eng QLogic Storage Upstream 
	<QLogic-Storage-Upstream@cavium.com>,
	"satishkh@cisco.com" <satishkh@cisco.com>,
	"sebaddel@cisco.com" <sebaddel@cisco.com>,
	"kartilak@cisco.com" <kartilak@cisco.com>,
	Dept-Eng QLogic Storage Upstream 
	<QLogic-Storage-Upstream@cavium.com>,
	Dept-Eng QLA2xxx Upstream <qla2xxx-upstream@cavium.com>,
	"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/9] scsi: qla4xxx: Use zeroing allocator rather than allocator/memset
Date: Tue, 2 Jan 2018 04:39:20 +0000	[thread overview]
Message-ID: <D6710A8A.4F523%manish.rangankar@cavium.com> (raw)
In-Reply-To: <1514647712-6332-2-git-send-email-himanshujha199640@gmail.com>



On 30/12/17 8:58 PM, "Himanshu Jha" <himanshujha199640@gmail.com> wrote:

>Use dma_zalloc_coherent instead of dma_alloc_coherent followed by memset
>0.
>
>Generated-by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci
>
>Suggested-by: Luis R. Rodriguez <mcgrof@kernel.org>
>Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
>---
> drivers/scsi/qla4xxx/ql4_init.c |  5 ++---
> drivers/scsi/qla4xxx/ql4_mbx.c  | 21 +++++++++------------
> drivers/scsi/qla4xxx/ql4_nx.c   |  5 ++---
> drivers/scsi/qla4xxx/ql4_os.c   | 12 +++++-------
> 4 files changed, 18 insertions(+), 25 deletions(-)
>
>diff --git a/drivers/scsi/qla4xxx/ql4_init.c
>b/drivers/scsi/qla4xxx/ql4_init.c
>index 5d6d158..52b1a0b 100644
>--- a/drivers/scsi/qla4xxx/ql4_init.c
>+++ b/drivers/scsi/qla4xxx/ql4_init.c
>@@ -153,15 +153,14 @@ int qla4xxx_get_sys_info(struct scsi_qla_host *ha)
> 	dma_addr_t sys_info_dma;
> 	int status = QLA_ERROR;
> 
>-	sys_info = dma_alloc_coherent(&ha->pdev->dev, sizeof(*sys_info),
>-				      &sys_info_dma, GFP_KERNEL);
>+	sys_info = dma_zalloc_coherent(&ha->pdev->dev, sizeof(*sys_info),
>+				       &sys_info_dma, GFP_KERNEL);
> 	if (sys_info == NULL) {
> 		DEBUG2(printk("scsi%ld: %s: Unable to allocate dma buffer.\n",
> 			      ha->host_no, __func__));
> 
> 		goto exit_get_sys_info_no_free;
> 	}
>-	memset(sys_info, 0, sizeof(*sys_info));
> 
> 	/* Get flash sys info */
> 	if (qla4xxx_get_flash(ha, sys_info_dma, FLASH_OFFSET_SYS_INFO,
>diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c
>b/drivers/scsi/qla4xxx/ql4_mbx.c
>index 1da04f3..bda2e64 100644
>--- a/drivers/scsi/qla4xxx/ql4_mbx.c
>+++ b/drivers/scsi/qla4xxx/ql4_mbx.c
>@@ -625,15 +625,14 @@ int qla4xxx_initialize_fw_cb(struct scsi_qla_host *
>ha)
> 	uint32_t mbox_sts[MBOX_REG_COUNT];
> 	int status = QLA_ERROR;
> 
>-	init_fw_cb = dma_alloc_coherent(&ha->pdev->dev,
>-					sizeof(struct addr_ctrl_blk),
>-					&init_fw_cb_dma, GFP_KERNEL);
>+	init_fw_cb = dma_zalloc_coherent(&ha->pdev->dev,
>+					 sizeof(struct addr_ctrl_blk),
>+					 &init_fw_cb_dma, GFP_KERNEL);
> 	if (init_fw_cb == NULL) {
> 		DEBUG2(printk("scsi%ld: %s: Unable to alloc init_cb\n",
> 			      ha->host_no, __func__));
> 		goto exit_init_fw_cb_no_free;
> 	}
>-	memset(init_fw_cb, 0, sizeof(struct addr_ctrl_blk));
> 
> 	/* Get Initialize Firmware Control Block. */
> 	memset(&mbox_cmd, 0, sizeof(mbox_cmd));
>@@ -710,9 +709,9 @@ int qla4xxx_get_dhcp_ip_address(struct scsi_qla_host
>* ha)
> 	uint32_t mbox_cmd[MBOX_REG_COUNT];
> 	uint32_t mbox_sts[MBOX_REG_COUNT];
> 
>-	init_fw_cb = dma_alloc_coherent(&ha->pdev->dev,
>-					sizeof(struct addr_ctrl_blk),
>-					&init_fw_cb_dma, GFP_KERNEL);
>+	init_fw_cb = dma_zalloc_coherent(&ha->pdev->dev,
>+					 sizeof(struct addr_ctrl_blk),
>+					 &init_fw_cb_dma, GFP_KERNEL);
> 	if (init_fw_cb == NULL) {
> 		printk("scsi%ld: %s: Unable to alloc init_cb\n", ha->host_no,
> 		       __func__);
>@@ -720,7 +719,6 @@ int qla4xxx_get_dhcp_ip_address(struct scsi_qla_host
>* ha)
> 	}
> 
> 	/* Get Initialize Firmware Control Block. */
>-	memset(init_fw_cb, 0, sizeof(struct addr_ctrl_blk));
> 	if (qla4xxx_get_ifcb(ha, &mbox_cmd[0], &mbox_sts[0], init_fw_cb_dma) !=
> 	    QLA_SUCCESS) {
> 		DEBUG2(printk("scsi%ld: %s: Failed to get init_fw_ctrl_blk\n",
>@@ -1342,16 +1340,15 @@ int qla4xxx_about_firmware(struct scsi_qla_host
>*ha)
> 	uint32_t mbox_sts[MBOX_REG_COUNT];
> 	int status = QLA_ERROR;
> 
>-	about_fw = dma_alloc_coherent(&ha->pdev->dev,
>-				      sizeof(struct about_fw_info),
>-				      &about_fw_dma, GFP_KERNEL);
>+	about_fw = dma_zalloc_coherent(&ha->pdev->dev,
>+				       sizeof(struct about_fw_info),
>+				       &about_fw_dma, GFP_KERNEL);
> 	if (!about_fw) {
> 		DEBUG2(ql4_printk(KERN_ERR, ha, "%s: Unable to alloc memory "
> 				  "for about_fw\n", __func__));
> 		return status;
> 	}
> 
>-	memset(about_fw, 0, sizeof(struct about_fw_info));
> 	memset(&mbox_cmd, 0, sizeof(mbox_cmd));
> 	memset(&mbox_sts, 0, sizeof(mbox_sts));
> 
>diff --git a/drivers/scsi/qla4xxx/ql4_nx.c b/drivers/scsi/qla4xxx/ql4_nx.c
>index e91abb3..968bd85 100644
>--- a/drivers/scsi/qla4xxx/ql4_nx.c
>+++ b/drivers/scsi/qla4xxx/ql4_nx.c
>@@ -4050,15 +4050,14 @@ int qla4_8xxx_get_sys_info(struct scsi_qla_host
>*ha)
> 	dma_addr_t sys_info_dma;
> 	int status = QLA_ERROR;
> 
>-	sys_info = dma_alloc_coherent(&ha->pdev->dev, sizeof(*sys_info),
>-				      &sys_info_dma, GFP_KERNEL);
>+	sys_info = dma_zalloc_coherent(&ha->pdev->dev, sizeof(*sys_info),
>+				       &sys_info_dma, GFP_KERNEL);
> 	if (sys_info == NULL) {
> 		DEBUG2(printk("scsi%ld: %s: Unable to allocate dma buffer.\n",
> 		    ha->host_no, __func__));
> 		return status;
> 	}
> 
>-	memset(sys_info, 0, sizeof(*sys_info));
> 	memset(&mbox_cmd, 0, sizeof(mbox_cmd));
> 	memset(&mbox_sts, 0, sizeof(mbox_sts));
> 
>diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
>index 2b8a8ce..82e889b 100644
>--- a/drivers/scsi/qla4xxx/ql4_os.c
>+++ b/drivers/scsi/qla4xxx/ql4_os.c
>@@ -2689,16 +2689,15 @@ qla4xxx_iface_set_param(struct Scsi_Host *shost,
>void *data, uint32_t len)
> 	uint32_t rem = len;
> 	struct nlattr *attr;
> 
>-	init_fw_cb = dma_alloc_coherent(&ha->pdev->dev,
>-					sizeof(struct addr_ctrl_blk),
>-					&init_fw_cb_dma, GFP_KERNEL);
>+	init_fw_cb = dma_zalloc_coherent(&ha->pdev->dev,
>+					 sizeof(struct addr_ctrl_blk),
>+					 &init_fw_cb_dma, GFP_KERNEL);
> 	if (!init_fw_cb) {
> 		ql4_printk(KERN_ERR, ha, "%s: Unable to alloc init_cb\n",
> 			   __func__);
> 		return -ENOMEM;
> 	}
> 
>-	memset(init_fw_cb, 0, sizeof(struct addr_ctrl_blk));
> 	memset(&mbox_cmd, 0, sizeof(mbox_cmd));
> 	memset(&mbox_sts, 0, sizeof(mbox_sts));
> 
>@@ -4196,15 +4195,14 @@ static int qla4xxx_mem_alloc(struct scsi_qla_host
>*ha)
> 			  sizeof(struct shadow_regs) +
> 			  MEM_ALIGN_VALUE +
> 			  (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1);
>-	ha->queues = dma_alloc_coherent(&ha->pdev->dev, ha->queues_len,
>-					&ha->queues_dma, GFP_KERNEL);
>+	ha->queues = dma_zalloc_coherent(&ha->pdev->dev, ha->queues_len,
>+					 &ha->queues_dma, GFP_KERNEL);
> 	if (ha->queues == NULL) {
> 		ql4_printk(KERN_WARNING, ha,
> 		    "Memory Allocation failed - queues.\n");
> 
> 		goto mem_alloc_error_exit;
> 	}
>-	memset(ha->queues, 0, ha->queues_len);
> 
> 	/*
> 	 * As per RISC alignment requirements -- the bus-address must be a
>-- 

Acked-by: Manish Rangankar <Manish.Rangankar@cavium.com>

>

  reply	other threads:[~2018-01-02  4:39 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-30 15:28 [PATCH 0/9] scsi: Use zeroing allocators " Himanshu Jha
2017-12-30 15:28 ` [PATCH 1/9] scsi: qla4xxx: Use zeroing allocator rather " Himanshu Jha
2018-01-02  4:39   ` Rangankar, Manish [this message]
2018-01-04  6:08   ` Martin K. Petersen
2017-12-30 15:28 ` [PATCH 2/9] scsi: qla2xxx: " Himanshu Jha
2018-01-02 17:01   ` Madhani, Himanshu
2018-01-04  6:09   ` Martin K. Petersen
2017-12-30 15:28 ` [PATCH 3/9] scsi: qedi: Use zeroing allocator instead of allocator/memset Himanshu Jha
2018-01-02  4:40   ` Rangankar, Manish
2018-01-04  6:17   ` Martin K. Petersen
2017-12-30 15:28 ` [PATCH 4/9] scsi: mvsas: Use zeroing allocator rather than allocator/memset Himanshu Jha
2017-12-30 15:28 ` [PATCH 5/9] scsi: fnic: " Himanshu Jha
2017-12-30 15:28 ` [PATCH 6/9] scsi: dpt_i2o: " Himanshu Jha
2017-12-30 15:28 ` [PATCH 7/9] scsi: bnx2fc: " Himanshu Jha
2018-01-02 21:14   ` Chad Dupuis
2018-01-04  6:17   ` Martin K. Petersen
2018-01-04  7:38     ` Himanshu Jha
2018-01-09  3:35       ` Martin K. Petersen
2017-12-30 15:28 ` [PATCH 8/9] scsi: bfa: " Himanshu Jha
2018-01-02  5:40   ` Gurumurthy, Anil
2018-01-04  6:13   ` Martin K. Petersen
2017-12-30 15:28 ` [PATCH 9/9] scsi: bnx2i: " Himanshu Jha
2018-01-02  4:42   ` Rangankar, Manish
2018-01-04  6:13   ` Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D6710A8A.4F523%manish.rangankar@cavium.com \
    --to=manish.rangankar@cavium.com \
    --cc=Anil.Gurumurthy@cavium.com \
    --cc=QLogic-Storage-Upstream@cavium.com \
    --cc=Sudarsana.Kalluru@cavium.com \
    --cc=aacraid@adaptec.com \
    --cc=himanshujha199640@gmail.com \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=kartilak@cisco.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=qla2xxx-upstream@cavium.com \
    --cc=satishkh@cisco.com \
    --cc=sebaddel@cisco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®