Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751482AbeABEkt (ORCPT + 1 other); Mon, 1 Jan 2018 23:40:49 -0500 Received: from mail-bn3nam01on0079.outbound.protection.outlook.com ([104.47.33.79]:43616 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750819AbeABEkq (ORCPT ); Mon, 1 Jan 2018 23:40:46 -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 3/9] scsi: qedi: Use zeroing allocator instead of allocator/memset Thread-Topic: [PATCH 3/9] scsi: qedi: Use zeroing allocator instead of allocator/memset Thread-Index: AQHTgYMQG9PJ9upLYU2dkD5tDsIHUaNgYNsA Date: Tue, 2 Jan 2018 04:40:42 +0000 Message-ID: References: <1514647712-6332-1-git-send-email-himanshujha199640@gmail.com> <1514647712-6332-4-git-send-email-himanshujha199640@gmail.com> In-Reply-To: <1514647712-6332-4-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;DM5PR07MB3050;6:lWWqGK0Y8/p7pjKSkTfVVyWOGxB3l3OzJ6vlovoevPwj3e45fYGkyqIKmCCUJ0QAG0dkcyExse9PNQgecravgZ75x5DnAI58vdainAR6XqlpmhpofnyChLtmbKlDB45s821rcOHy4GXpKVHM0GXtnzh/B/Vx35Vhsl6kcKK9rd8S2YYnqIt4Xf4G9+WS8to8SxavXmTPYl+9VEfRbMXTRdFHC/LWMzBv/XlTw+o9oXyYn/7KCO6bOAwNom+YuaEImkLq4TTpqTAuDrI1WqLcW5gPWkyW5I5dYK0zgBTsK08vdqo9r02RWPQoqOwXHPVDxzyfQKDqEZ9Qrjj03sFKBBD3TNzC8aD3tx7leZO56s/d8BC68SG/NZRyVzhIbVAS;5:b78WvxDzf1NNWjEuKxjtwCSoZtC558UEaSdYqC24Jt0l+UNqjTIKm6YtI1J7ezcDq6gzESzrsDa6z72d+dXAjN5cR69jHiXWbvlM+5xvaRre7AbyzU+Ib4ykU1WRX+/F0LeWhjoLGQsccK+reFLYwKz7BvYVVTGCwYDAzskm1yo=;24:HbCj518phvMjQIpXqw8a1ydKRNFQdWLYZVuDm7nPJkg7BvjgrJZCYKwDvM7o2MIax8N01XPpdtJwoUy87noLZhCkkONBmo5IKu1noTbcknc=;7:GbDnO4pEkHRRDxWqyltAB9DEX6rQqwNUUxVcSzomaDpA63z6c8UMTS37TA1IietKS2S0iRrjSUnhjzDFWtugDleYNpvyMWeh42qbls9Xe9smYvhP+SsjWW58NXoKjeqPvqcJHHBgUATjOrtzeEpV7gX0ve7rh0C6pfi6cOKkxEwUspnFuPzcxbS31Zzq8YgtLG6qOjzUV0xsrg1xNHQWEgNoFQz/2q89KjBqZX2sSkbmBFa0IxcjJKvOZgfap+33 x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-ms-office365-filtering-correlation-id: 0290aecf-fb62-4de1-ce09-08d5519afb44 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(2017052603307)(7153060);SRVR:DM5PR07MB3050; x-ms-traffictypediagnostic: DM5PR07MB3050: 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)(10201501046)(93006095)(93001095)(3231023)(944501075)(3002001)(6041268)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123558120)(6072148)(201708071742011);SRVR:DM5PR07MB3050;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:DM5PR07MB3050; x-forefront-prvs: 0540846A1D x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(376002)(39380400002)(39850400004)(396003)(366004)(346002)(199004)(189003)(24454002)(5660300001)(25786009)(106356001)(575784001)(14454004)(86362001)(3846002)(6116002)(105586002)(2950100002)(81156014)(53546011)(6246003)(102836004)(76176011)(8936002)(39060400002)(6506007)(68736007)(53936002)(81166006)(2201001)(97736004)(8676002)(305945005)(99286004)(59450400001)(7736002)(3660700001)(316002)(3280700002)(2906002)(54906003)(77096006)(4326008)(6486002)(110136005)(478600001)(6512007)(36756003)(72206003)(66066001)(2501003)(2900100001)(229853002)(6436002);DIR:OUT;SFP:1101;SCL:1;SRVR:DM5PR07MB3050;H:BN3PR07MB2483.namprd07.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; x-microsoft-antispam-message-info: PzvNAUvd5bt5rQ6JhvTJv/mJlkjdxfYtVgnWdNWqi8SZsD+5GpjFlbgAbkb8FAAPytPIGYFTGDf4pjDk0ycX+w== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: <2E77EDF39D9E264390EFEA2A3C871429@namprd07.prod.outlook.com> Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0290aecf-fb62-4de1-ce09-08d5519afb44 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Jan 2018 04:40:42.4415 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR07MB3050 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/qedi/qedi_main.c | 42 >+++++++++++++++--------------------------- > 1 file changed, 15 insertions(+), 27 deletions(-) > >diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c >index cccc34a..5ef0b36 100644 >--- a/drivers/scsi/qedi/qedi_main.c >+++ b/drivers/scsi/qedi/qedi_main.c >@@ -1268,16 +1268,14 @@ static int qedi_alloc_bdq(struct qedi_ctx *qedi) > } > > /* Allocate list of PBL pages */ >- qedi->bdq_pbl_list = dma_alloc_coherent(&qedi->pdev->dev, >- PAGE_SIZE, >- &qedi->bdq_pbl_list_dma, >- GFP_KERNEL); >+ qedi->bdq_pbl_list = dma_zalloc_coherent(&qedi->pdev->dev, PAGE_SIZE, >+ &qedi->bdq_pbl_list_dma, >+ GFP_KERNEL); > if (!qedi->bdq_pbl_list) { > QEDI_ERR(&qedi->dbg_ctx, > "Could not allocate list of PBL pages.\n"); > return -ENOMEM; > } >- memset(qedi->bdq_pbl_list, 0, PAGE_SIZE); > > /* > * Now populate PBL list with pages that contain pointers to the >@@ -1367,11 +1365,10 @@ static int qedi_alloc_global_queues(struct >qedi_ctx *qedi) > (qedi->global_queues[i]->cq_pbl_size + > (QEDI_PAGE_SIZE - 1)); > >- qedi->global_queues[i]->cq = >- dma_alloc_coherent(&qedi->pdev->dev, >- qedi->global_queues[i]->cq_mem_size, >- &qedi->global_queues[i]->cq_dma, >- GFP_KERNEL); >+ qedi->global_queues[i]->cq = >+ dma_zalloc_coherent(&qedi->pdev->dev, >+ qedi->global_queues[i]->cq_mem_size, >+ &qedi->global_queues[i]->cq_dma, >+ GFP_KERNEL); > > if (!qedi->global_queues[i]->cq) { > QEDI_WARN(&qedi->dbg_ctx, >@@ -1379,14 +1376,10 @@ static int qedi_alloc_global_queues(struct >qedi_ctx *qedi) > status = -ENOMEM; > goto mem_alloc_failure; > } >- memset(qedi->global_queues[i]->cq, 0, >- qedi->global_queues[i]->cq_mem_size); >- >- qedi->global_queues[i]->cq_pbl = >- dma_alloc_coherent(&qedi->pdev->dev, >- qedi->global_queues[i]->cq_pbl_size, >- &qedi->global_queues[i]->cq_pbl_dma, >- GFP_KERNEL); >+ qedi->global_queues[i]->cq_pbl = >+ dma_zalloc_coherent(&qedi->pdev->dev, >+ qedi->global_queues[i]->cq_pbl_size, >+ &qedi->global_queues[i]->cq_pbl_dma, >+ GFP_KERNEL); > > if (!qedi->global_queues[i]->cq_pbl) { > QEDI_WARN(&qedi->dbg_ctx, >@@ -1394,8 +1387,6 @@ static int qedi_alloc_global_queues(struct qedi_ctx >*qedi) > status = -ENOMEM; > goto mem_alloc_failure; > } >- memset(qedi->global_queues[i]->cq_pbl, 0, >- qedi->global_queues[i]->cq_pbl_size); > > /* Create PBL */ > num_pages = qedi->global_queues[i]->cq_mem_size / >@@ -1456,25 +1447,22 @@ int qedi_alloc_sq(struct qedi_ctx *qedi, struct >qedi_endpoint *ep) > ep->sq_pbl_size = (ep->sq_mem_size / QEDI_PAGE_SIZE) * sizeof(void *); > ep->sq_pbl_size = ep->sq_pbl_size + QEDI_PAGE_SIZE; > >- ep->sq = dma_alloc_coherent(&qedi->pdev->dev, ep->sq_mem_size, >- &ep->sq_dma, GFP_KERNEL); >+ ep->sq = dma_zalloc_coherent(&qedi->pdev->dev, ep->sq_mem_size, >+ &ep->sq_dma, GFP_KERNEL); > if (!ep->sq) { > QEDI_WARN(&qedi->dbg_ctx, > "Could not allocate send queue.\n"); > rval = -ENOMEM; > goto out; > } >- memset(ep->sq, 0, ep->sq_mem_size); >- >- ep->sq_pbl = dma_alloc_coherent(&qedi->pdev->dev, ep->sq_pbl_size, >- &ep->sq_pbl_dma, GFP_KERNEL); >+ ep->sq_pbl = dma_zalloc_coherent(&qedi->pdev->dev, ep->sq_pbl_size, >+ &ep->sq_pbl_dma, GFP_KERNEL); > if (!ep->sq_pbl) { > QEDI_WARN(&qedi->dbg_ctx, > "Could not allocate send queue PBL.\n"); > rval = -ENOMEM; > goto out_free_sq; > } >- memset(ep->sq_pbl, 0, ep->sq_pbl_size); > > /* Create PBL */ > num_pages = ep->sq_mem_size / QEDI_PAGE_SIZE; >-- >2.7.4 Acked-by: Manish Rangankar >