From patchwork Tue Jan 9 09:06:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Jha X-Patchwork-Id: 10151213 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D6FD4602B3 for ; Tue, 9 Jan 2018 09:07:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFB7B286BA for ; Tue, 9 Jan 2018 09:07:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C4754288C6; Tue, 9 Jan 2018 09:07:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.7 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 664C7286BA for ; Tue, 9 Jan 2018 09:07:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751800AbeAIJHV (ORCPT ); Tue, 9 Jan 2018 04:07:21 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:32848 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751709AbeAIJHN (ORCPT ); Tue, 9 Jan 2018 04:07:13 -0500 Received: by mail-pf0-f194.google.com with SMTP id y89so8117505pfk.0 for ; Tue, 09 Jan 2018 01:07:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RXaCo7Fs4TIYdZuCKY07URt4NEZnpJnut4g9r2XDXTw=; b=UgUNbVLQBsDpqIzpeLJGZhu3lE0C2wRdtgobdVka7MusQajF0MQQlaU0dDZUV+PoHD F+LxefrFckgdCbvUX7a5c4kZtzxrL73EpPyrgGqzbaAt7LUfyRq4xzGRuKjDsgqRygeU +JKbj9RsLKxLC2UHZJS+Setlda6NT13daQY9JhqRzPdOMvhIXT7kL4PVNyMbUgCzISsX AWz+4FDhzAbX1K3CI+tzb6OSj5ILp8d/HYXA9SiDgt05efo+W7MKv0a4P6iyy2SJs1Lm ZATnFZ5KvhyCt+6kbJVIvG6xiKDfbAm3XBVd1rSmOONacx5+F9HLnqxGXpl0Wsnu2ues hJSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RXaCo7Fs4TIYdZuCKY07URt4NEZnpJnut4g9r2XDXTw=; b=EL4u2xdy3gJqRM5+vhIbO/7XeK/wprvHwkM5/cU6Xtl5Nf65Oi+toMOiQMzXFj3Zgf naYVTGeglAlomWovkI2Z660TADZseIsvMzV9QF47xkQeOK0QpYHEA7xdSnJaFBGV9hef L86bcY1leT/oCjfmq42jzadfVdYSdwINzjd1otG0+kUnFussYnTRWD5bK23YsM5+7zKT f+p4tc+MkwDrT6vM/d4dmblpCQUE3tkHziBYXnd56yZF3Nb/vxEZ6AEA22g/d1GVFnEz YXAlLXWhfwzVJ6MZ4cT+rEggIj5I/9+/ubHi+GmMJMozkTjibggE3U78wH7gowNtYOx3 IV9Q== X-Gm-Message-State: AKGB3mJHdtAIsIfOsulKe9DvQmTgkoYhULJgR3gSg72CUV+ahD2UDnss acoVAHd7FaEtLfENtUFlURI= X-Google-Smtp-Source: ACJfBoscwRexPvM6y/pWHBqWqRzWqvrAVgjpvI/Hzr/2351APMWl5i6Ct6tGd74igwzDOe/YyeFGrg== X-Received: by 10.99.173.79 with SMTP id y15mr11695782pgo.444.1515488833368; Tue, 09 Jan 2018 01:07:13 -0800 (PST) Received: from localhost.localdomain ([103.46.193.14]) by smtp.gmail.com with ESMTPSA id p10sm31806667pfl.32.2018.01.09.01.07.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Jan 2018 01:07:12 -0800 (PST) From: Himanshu Jha To: jejb@linux.vnet.ibm.com, martin.petersen@oracle.com Cc: QLogic-Storage-Upstream@qlogic.com, linux-scsi@vger.kernel.org, QLogic-Storage-Upstream@cavium.com, chad.dupuis@cavium.com, Manish.Rangankar@cavium.com, Himanshu Jha Subject: [RESEND PATCH 2/2] scsi: qedi: Use zeroing allocator instead of allocator/memset Date: Tue, 9 Jan 2018 14:36:52 +0530 Message-Id: <1515488812-22664-2-git-send-email-himanshujha199640@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515488812-22664-1-git-send-email-himanshujha199640@gmail.com> References: <1515488812-22664-1-git-send-email-himanshujha199640@gmail.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Manish Rangankar --- 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;