Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751399AbeABEjZ (ORCPT + 1 other); Mon, 1 Jan 2018 23:39:25 -0500 Received: from mail-bl2nam02on0040.outbound.protection.outlook.com ([104.47.38.40]:27586 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750819AbeABEjX (ORCPT ); Mon, 1 Jan 2018 23:39:23 -0500 From: "Rangankar, Manish" To: Himanshu Jha , "jejb@linux.vnet.ibm.com" , "martin.petersen@oracle.com" , "aacraid@adaptec.com" CC: "Gurumurthy, Anil" , "Kalluru, Sudarsana" , Dept-Eng QLogic Storage Upstream , "satishkh@cisco.com" , "sebaddel@cisco.com" , "kartilak@cisco.com" , Dept-Eng QLogic Storage Upstream , Dept-Eng QLA2xxx Upstream , "linux-scsi@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 1/9] scsi: qla4xxx: Use zeroing allocator rather than allocator/memset Thread-Topic: [PATCH 1/9] scsi: qla4xxx: Use zeroing allocator rather than allocator/memset Thread-Index: AQHTgYMDqGuCYFYofU+Ejn3V02I1FaNgYHcA Date: Tue, 2 Jan 2018 04:39:20 +0000 Message-ID: References: <1514647712-6332-1-git-send-email-himanshujha199640@gmail.com> <1514647712-6332-2-git-send-email-himanshujha199640@gmail.com> In-Reply-To: <1514647712-6332-2-git-send-email-himanshujha199640@gmail.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Manish.Rangankar@cavium.com; x-originating-ip: [114.143.185.87] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;BN6PR07MB3041;6:p2Qb7B9xlbfJFidmbPelfb6urH7+PpTz+Vp3QgO9X+l9iTrj8QvEDSBJ3OXrY0TwArHTRBEG1+X9uL7lJpHOzuUZKwqTDM58uVxVpytolAbd+H11jYPG9kqOH57KJK+FzahfiIeUY0zLm8kFpb9gv5Iaeim4IcheAsc5HX/IgTnsiYxhCCs9faIj7isIuSJJXVgbItqlYqXVlQjzfAtzKPLPhACpPj83iJzhonTQch747dY0/JgfP3FbvqOX6wTGwBO6InWvuBod6fk1OGQ8yGMcuIF3vT595dT2MrBkGZdta7ImlPE/7NgQ0roVF+es/l14rUIelQunyiiXDS0P3AX5xeNWRUMezXCDjx21O8BY+Mf2y8PbWV3Sa5qTA65k;5:7HrpSlSztW6/1XGay+QHewn1Khak1vUUosDrcyIRHUQdH7nrhN2hepUeNB/tP1Tq8TEEZZxQe+TVTOWXjm2ck+UG4hT/rmNz3S6b6LQVSHXkQf0vg2pvOzNObMQmQqyG1vVOQigUmHUOXIZbj3WA09g2CtT5qchzLslr1YUkee4=;24:8ysvys4djLTf4TCAs5LArHZTfIknTEoJ3QirxS36yPq1JrY6iPFe4FL2LDHUIy0DH6AmOe0nsPUopxLnbJz1TL8ii+IDR5vx/k8ulaTkTkw=;7:d9RJEEAjftYAJuLpdMFT0yiATjOnkxjaGUChrZYprw9hUMzJ4VWP0l34xmpiAFFlN/Gt/+y3UBLB+FJDRcoFjMPyQf8jZ7gQ9mubU6wK1DU9rfaUwyZGx9dTk46S019zd+TZmlUayHB7Ux0hIwm2AoOb6qSfXJSrzjMPdoHb4i40RJT5UvTx4g663LEChVXr+95/l+ozaB0Fo2cZcrK0aa3IZt7LEqwD/oGEFuboBI4SkDLUlr3Kw+elNFpn3Evn x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-ms-office365-filtering-correlation-id: 4bf13329-1ce4-4736-dcbd-08d5519aca32 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(2017052603307)(7153060);SRVR:BN6PR07MB3041; x-ms-traffictypediagnostic: BN6PR07MB3041: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040470)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(3231023)(944501075)(6041268)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123562045)(6072148)(201708071742011);SRVR:BN6PR07MB3041;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:BN6PR07MB3041; x-forefront-prvs: 0540846A1D x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(396003)(376002)(39850400004)(39380400002)(366004)(346002)(24454002)(199004)(189003)(102836004)(305945005)(575784001)(2201001)(2501003)(86362001)(106356001)(77096006)(6486002)(97736004)(2900100001)(105586002)(66066001)(5660300001)(2950100002)(7736002)(36756003)(53936002)(76176011)(478600001)(3280700002)(6436002)(6512007)(3846002)(72206003)(8936002)(53546011)(6506007)(54906003)(6246003)(14454004)(25786009)(81156014)(110136005)(99286004)(4326008)(8676002)(316002)(39060400002)(3660700001)(229853002)(59450400001)(68736007)(81166006)(6116002)(2906002)(32563001);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR07MB3041;H:BN3PR07MB2483.namprd07.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; x-microsoft-antispam-message-info: xXpH1/FJrY6O6RrtC89Rd9u+deCN9gQiyhXvppeYOI4XNbeWgqmaqmY7GBN0y02mAL+TfCRQjE8MEUNEY2akww== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: <2FB69548789AF442AF02C8A3D2024691@namprd07.prod.outlook.com> Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4bf13329-1ce4-4736-dcbd-08d5519aca32 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Jan 2018 04:39:20.1468 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR07MB3041 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On 30/12/17 8:58 PM, "Himanshu Jha" 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 >Signed-off-by: Himanshu Jha >--- > 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 >