From patchwork Thu Feb 23 01:22:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adit Ranadive X-Patchwork-Id: 9587629 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 B17F16057F for ; Thu, 23 Feb 2017 01:24:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FA1F28716 for ; Thu, 23 Feb 2017 01:24:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9469728725; Thu, 23 Feb 2017 01:24:37 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 D078E28716 for ; Thu, 23 Feb 2017 01:24:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934279AbdBWBY3 (ORCPT ); Wed, 22 Feb 2017 20:24:29 -0500 Received: from mail-cys01nam02on0063.outbound.protection.outlook.com ([104.47.37.63]:29976 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933159AbdBWBYZ (ORCPT ); Wed, 22 Feb 2017 20:24:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=onevmw.onmicrosoft.com; s=selector1-vmware-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=cXqUUc4VQUeQl0GI+CIgzFM3tozh5GGujC5oQ2N+fIM=; b=QEIezBOekCjJ6a9CKs/fb0UrOxtSYBVLl+LNKsMYd56gVyaFCiCXAwHBH7rqIkEOXMiZ/FYsimxEgar/79+ogJ1NrHFHPzQQd9Xy6Yjdap1E4KNWRWl6nH8Z9DZE0vS70rwVXI/Gn8m3TjVXJexJYdR5Y3VvH9t9T2cKygx8I1A= Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none; redhat.com; dmarc=none action=none header.from=vmware.com; Received: from promb-2s-dhcp95-136.eng.vmware.com (208.91.1.34) by CO2PR05MB2421.namprd05.prod.outlook.com (10.166.95.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.933.7; Thu, 23 Feb 2017 01:23:18 +0000 From: Adit Ranadive To: , CC: Adit Ranadive , Subject: [PATCH 1/3] RDMA/vmw_pvrdma: Cleanup unused variables Date: Wed, 22 Feb 2017 17:22:56 -0800 Message-ID: <83baafed74beeee75a6a1342d4b37fac50b85b31.1487812849.git.aditr@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [208.91.1.34] X-ClientProxiedBy: CY1PR1201CA0032.namprd12.prod.outlook.com (10.169.17.170) To CO2PR05MB2421.namprd05.prod.outlook.com (10.166.95.21) X-MS-Office365-Filtering-Correlation-Id: 28967b46-cd03-4ff0-37c2-08d45b8a8c62 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:CO2PR05MB2421; X-Microsoft-Exchange-Diagnostics: 1; CO2PR05MB2421; 3:dZAg0XFvlCZA3HhpefuhERknxa0hanWufQ9RJGCFeQn1EBennVFWNL0rPaxC8Rxct0fzI2nCnV1SFroYyq67HCQkuMxX25GI59aY9cJqAooyn6XATtNG+WAJftWyT93Gau6LAKvl45dkrs2D4iun0equ/PiR23alYrp25JyEeQwJ4W0MV9efaZEepgksyn+I4cyzDzm2P37sFHSVYoLw4HxPe0j6Xzo8PbQ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51EerJZOfl/EgTDmSJuQDPUvHOaBofvbnFNXObqORUljLsTDgJrlbbe+hdvUxX5hx0585+Bx0zkRRyknYTzE1TbuLi7u5KccLShfJtQfMSq/yAvJW4wx+YNgXTmeQeGycEsYwXNJ7Lz6/S+6ZDyFPlpQpZX2CcRPUwf248qDC4VkS0jPuSjakAQSe+LixpqbiyZl0iHwGxOpDi6u395Vqsq7VgIsA+DsLOo1cpYGGkdTCp1BWLDdrsrQ+Nni2fZHvVWhO4vSgu X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(61668805478150)(146099531331640); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6041248)(20161123558025)(20161123560025)(20161123564025)(20161123555025)(20161123562025)(6072148); SRVR:CO2PR05MB2421; BCL:0; PCL:0; RULEID:; SRVR:CO2PR05MB2421; X-Microsoft-Exchange-Diagnostics: 1; CO2PR05MB2421; 4:kO5Qhxqwq6fEuv8hh42SoKhWTVYF0udjVriYRGveDm24p2Q9T4QtgfKnDYf+H5N8Rm+ZY9/KSbxWfTnhsXOTzCkZs/QcjUB+ZTEK+7UpLUIgAyJn0JDls80GItdBGjPIeL4heln676Q4mOy34yBz9EJ2RxrrtFaNl+7S3R35TicIUmnsg3zNoN1H8SapR6HawKi23JbLmGCCvxtqkYLFPfHJmgMaljagRBtNrJ/oRPnpoui4+bhUWa6Pmt/x+2Dj61sOokH66WAgxwDeaJGz1glVJjQ1x8vU5snXsK7RcomKHOckooBRfuHD95Emeb7yuGRPQ47+kkw/Mk+D6ClkLave4KadrhC633b6xc/FO7Ei9QjUYL9t6tEchCo/xMtxevluNENuHHJZUuT86N/tk4zaPg42/GjLJgtGEnOPwqx5UlSGM9Kd2nZfEzX/Lp7eo8rYahyCzFInPquXYZssfQABw86N8SSkDFeyBicKZ4R7Xx8YOYfhYY2tzuzX2B9v8W2eyht4iWIll+mmIGHx+9D+rW+IJDwVjekUXnGFdU6YwP01358hYIEf/s4ua7JEtUEGZWb1BWnbIzrTRSs3NAuNl9KXZmxQ+1FrlfajtwS880LCJfWF7NPkANVUpL1hRBQDq0iVi0AwaTaapRR6j4FYVbjJa5o5jBrF5TzaS+cViTjnBfN0cEgsIdqk4G+/ X-Forefront-PRVS: 02272225C5 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(39450400003)(36756003)(5660300001)(4326007)(47776003)(305945005)(66066001)(118296001)(50986999)(76176999)(7736002)(50226002)(2906002)(6486002)(8676002)(81166006)(25786008)(54906002)(3846002)(6116002)(48376002)(50466002)(42186005)(86362001)(92566002)(38730400002)(33646002)(107886003)(189998001)(5003940100001)(2950100002)(6666003)(53936002)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:CO2PR05MB2421; H:promb-2s-dhcp95-136.eng.vmware.com; FPR:; SPF:None; MLV:nspm; PTR:InfoNoRecords; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CO2PR05MB2421; 23:J0jungbOQsqjV6BuhrEIaT4Jax6OuLdHi0aBeckw/m2lD7xBhsTOQoMr0TzWF1FDFBZ+QAm4mCa4AJBoyLCo8LY3K4Ka7s9XQk2Qze6dHpFhp/AWq7jDqYSNZjGd2IALfh+p28Ee11/ofaOYlgroMmezIzzHhm3ASPU/o/Tv1c2LP3/jP7sedeveJGLa46Q3Bmizm/A9tGIaGQ+UyiWNqlVN3JZy+PwqAltEjZdB8Rf9F6t98ymGW+G/seFkIKCtqY+y3dzyz7ZDNe2Le495hAm8MSBRVK+d3T7hA/2RQy4v5AhqINSJTdWjbdOR7oHiN/rNMhGUUC+zrGbzvCyw04vOBkaGuJYrn8Y7qlBE5bv3JqVJ/+1F8aBUsetN6WHj5euDXMVRXo+wJyu9+hNGuX+BW9gJaYYVOrusnI4wT6dwboKzx96UBFgrndDVH0lJ7zKi/z64BwAvySWxAuHyS+flSjlH2M6iqyUDUzusFxdn1eoAOaJ2GBVg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M=; 24:8m82NURM4SbH3DYElCP8rwwSyOJ+2KxCy5/SvN7uz1a6h7m4Ex2RRHATTTs9zDKsbS06GTSSrqpzCM3SwF87cQhSzvDQbW0qPTMx+rq+TqE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CO2PR05MB2421; 7:Z62MLC3uLBRiOPy8YxhcDbtr7ixUVn5E7PJBBDwfADD/jdf6Ol2wq/4W/vdKroNClO9hu4FhzPUn7nWpW5GbzsDr2e0BuddA2JK6eYHivwGhHEjUWtcSjJtZ/+fsZHWnw2e8zJ+kWVQ3DIgjwWNhgK4qKivW3xjDEO+8iK3ZlKEuiMkMVTeukQGzdBQFcW0o+t65H3ySuHSnS5l0JiekHvbrpmhXBQd8vCI88aCbPjuqin0jqn3z8di+kij+m6dvK8+xzMzfOm7QKRIFGJiHR+07OjbpdfyOLUgarGWO5nHyRHEWp7uimqnCDDfeTaat00iqRMomRfhhHFZfW8nNEw==; 20:MrL3sVqdbLsGOr8Y+zi9qEm7QmKmB5FZ5keHl6Jyl6FWW/Rv6K2bUOKSSMOZIBvuso/Irqo0/emWW5i7r3HAOlOUTfcv2y5aAZqGEyETUS7iIhtCT28YDstEv3MxmsR95imSvp2VpDos02urA8KnPcA4iNktsfM70rxY0x7Zkt8= X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2017 01:23:18.1050 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR05MB2421 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Removed the unused nreq and redundant index variables. Moved hardcoded async and cq ring pages number to macro. Reported-by: Yuval Shaia Signed-off-by: Adit Ranadive Reviewed-by: Aditya Sarwade Tested-by: Andrew Boyer --- drivers/infiniband/hw/vmw_pvrdma/pvrdma.h | 2 ++ drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c | 4 ++-- drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c | 33 ++++++++++---------------- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma.h b/drivers/infiniband/hw/vmw_pvrdma/pvrdma.h index 3cd96c1..dbf61c3 100644 --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma.h +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma.h @@ -69,6 +69,8 @@ */ #define PCI_DEVICE_ID_VMWARE_PVRDMA 0x0820 +#define PVRDMA_NUM_RING_PAGES 4 + struct pvrdma_dev; struct pvrdma_page_dir { diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c index 60cdb77..4380d3d 100644 --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c @@ -857,7 +857,7 @@ static int pvrdma_pci_probe(struct pci_dev *pdev, dev->dsr->resp_slot_dma = (u64)slot_dma; /* Async event ring */ - dev->dsr->async_ring_pages.num_pages = 4; + dev->dsr->async_ring_pages.num_pages = PVRDMA_NUM_RING_PAGES; ret = pvrdma_page_dir_init(dev, &dev->async_pdir, dev->dsr->async_ring_pages.num_pages, true); if (ret) @@ -866,7 +866,7 @@ static int pvrdma_pci_probe(struct pci_dev *pdev, dev->dsr->async_ring_pages.pdir_dma = dev->async_pdir.dir_dma; /* CQ notification ring */ - dev->dsr->cq_ring_pages.num_pages = 4; + dev->dsr->cq_ring_pages.num_pages = PVRDMA_NUM_RING_PAGES; ret = pvrdma_page_dir_init(dev, &dev->cq_pdir, dev->dsr->cq_ring_pages.num_pages, true); if (ret) diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c index dbbfd35..3ffbb2d 100644 --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c @@ -554,13 +554,13 @@ int pvrdma_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, return ret; } -static inline void *get_sq_wqe(struct pvrdma_qp *qp, int n) +static inline void *get_sq_wqe(struct pvrdma_qp *qp, unsigned int n) { return pvrdma_page_dir_get_ptr(&qp->pdir, qp->sq.offset + n * qp->sq.wqe_size); } -static inline void *get_rq_wqe(struct pvrdma_qp *qp, int n) +static inline void *get_rq_wqe(struct pvrdma_qp *qp, unsigned int n) { return pvrdma_page_dir_get_ptr(&qp->pdir, qp->rq.offset + n * qp->rq.wqe_size); @@ -598,9 +598,7 @@ int pvrdma_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, unsigned long flags; struct pvrdma_sq_wqe_hdr *wqe_hdr; struct pvrdma_sge *sge; - int i, index; - int nreq; - int ret; + int i, ret; /* * In states lower than RTS, we can fail immediately. In other states, @@ -613,9 +611,8 @@ int pvrdma_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, spin_lock_irqsave(&qp->sq.lock, flags); - index = pvrdma_idx(&qp->sq.ring->prod_tail, qp->sq.wqe_cnt); - for (nreq = 0; wr; nreq++, wr = wr->next) { - unsigned int tail; + while (wr) { + unsigned int tail = 0; if (unlikely(!pvrdma_idx_ring_has_space( qp->sq.ring, qp->sq.wqe_cnt, &tail))) { @@ -680,7 +677,7 @@ int pvrdma_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, } } - wqe_hdr = (struct pvrdma_sq_wqe_hdr *)get_sq_wqe(qp, index); + wqe_hdr = (struct pvrdma_sq_wqe_hdr *)get_sq_wqe(qp, tail); memset(wqe_hdr, 0, sizeof(*wqe_hdr)); wqe_hdr->wr_id = wr->wr_id; wqe_hdr->num_sge = wr->num_sge; @@ -771,12 +768,11 @@ int pvrdma_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, /* Make sure wqe is written before index update */ smp_wmb(); - index++; - if (unlikely(index >= qp->sq.wqe_cnt)) - index = 0; /* Update shared sq ring */ pvrdma_idx_ring_inc(&qp->sq.ring->prod_tail, qp->sq.wqe_cnt); + + wr = wr->next; } ret = 0; @@ -806,7 +802,6 @@ int pvrdma_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr, struct pvrdma_qp *qp = to_vqp(ibqp); struct pvrdma_rq_wqe_hdr *wqe_hdr; struct pvrdma_sge *sge; - int index, nreq; int ret = 0; int i; @@ -821,9 +816,8 @@ int pvrdma_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr, spin_lock_irqsave(&qp->rq.lock, flags); - index = pvrdma_idx(&qp->rq.ring->prod_tail, qp->rq.wqe_cnt); - for (nreq = 0; wr; nreq++, wr = wr->next) { - unsigned int tail; + while (wr) { + unsigned int tail = 0; if (unlikely(wr->num_sge > qp->rq.max_sg || wr->num_sge < 0)) { @@ -843,7 +837,7 @@ int pvrdma_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr, goto out; } - wqe_hdr = (struct pvrdma_rq_wqe_hdr *)get_rq_wqe(qp, index); + wqe_hdr = (struct pvrdma_rq_wqe_hdr *)get_rq_wqe(qp, tail); wqe_hdr->wr_id = wr->wr_id; wqe_hdr->num_sge = wr->num_sge; wqe_hdr->total_len = 0; @@ -859,12 +853,11 @@ int pvrdma_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr, /* Make sure wqe is written before index update */ smp_wmb(); - index++; - if (unlikely(index >= qp->rq.wqe_cnt)) - index = 0; /* Update shared rq ring */ pvrdma_idx_ring_inc(&qp->rq.ring->prod_tail, qp->rq.wqe_cnt); + + wr = wr->next; } spin_unlock_irqrestore(&qp->rq.lock, flags);