From patchwork Tue Jan 10 19:15:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adit Ranadive X-Patchwork-Id: 9508413 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 0B25A60231 for ; Tue, 10 Jan 2017 19:16:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F27FB27F89 for ; Tue, 10 Jan 2017 19:16:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E73AD284EA; Tue, 10 Jan 2017 19:16:41 +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 EC8B6285A5 for ; Tue, 10 Jan 2017 19:16:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S939164AbdAJTQ2 (ORCPT ); Tue, 10 Jan 2017 14:16:28 -0500 Received: from mail-sn1nam01on0083.outbound.protection.outlook.com ([104.47.32.83]:28692 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S940379AbdAJTQR (ORCPT ); Tue, 10 Jan 2017 14:16:17 -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=LAKsiG1UfBOeCotlPPMCoV+GsqL+yZPzwDhlCA2tCws=; b=JjodYsvnkhyyQZ6DYqWgQ2+WZCi0gS1L1YNZARDrzbaYkvPAQpBK411vRMcTTQ1tXFqOcaVr5GYVwUweD7+ERa7c5W85HpgA/X4Pj8PQnAIRkUtxpz2h2mW0dXESfdTyH6mEju207hdqaufmcsD4v8XEtLbNNFVP/e2NrZ2s3Oo= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aditr@vmware.com; Received: from promb-2s-dhcp95-136.eng.vmware.com (208.91.1.34) by CO2PR0501MB838.namprd05.prod.outlook.com (10.141.244.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.845.6; Tue, 10 Jan 2017 19:16:03 +0000 From: Adit Ranadive To: , CC: Adit Ranadive , Subject: [PATCH 2/3] IB/vmw_pvrdma: Cleanup unused variables Date: Tue, 10 Jan 2017 11:15:40 -0800 Message-ID: <8631bae587fe5c6b63f8c1f486d79f564041ddae.1484075557.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: DM5PR21CA0037.namprd21.prod.outlook.com (10.172.92.151) To CO2PR0501MB838.namprd05.prod.outlook.com (10.141.244.148) X-MS-Office365-Filtering-Correlation-Id: 1bd12bb0-a811-4a59-00b5-08d4398d1f32 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:CO2PR0501MB838; X-Microsoft-Exchange-Diagnostics: 1; CO2PR0501MB838; 3:cIwGOkzwstIkJ5lC3X07D/Msbt3NRQarD+Z0OiT+fMVld4CNFL8FH131W4rPFnqGXH2myQw2SO4gM0KIlUX5KKVEe7DFHa20IJOHnh4P2T0k8c4s4PGdin6B+4kOr3/Izq7y70mJgU0bZO3hT1tWLYTaZlDMHKM/P1wR8YLPGjt3zy4Ivi52QVWXOVV94MkDc6ciA+dXxU2747xb5ge51kOXF0oJkr4/VvXUE8HV38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nXXXWhpiztg6NsOuAsSyoCX+ZpxP/KhHQkf/7bE2KJk2o2UkSWXffmGCUWvO5rz40OWKBBrGhgfItRqbSue/ZmHZPjJ7UmxER83nPA47wlh65ShEUqzSu4sY3L06+uS8v0E6msfw==; 20:Nv/yvcfMNTcsKZFJFhvXu+AhXlikT9P1D134eCWHhjcbKUU9+c7/Cuuzf94F47cG+CJVn2WQ14DgVXdNJiSnI9NQUQ6NygiYEuc4oe8ssYzSxPtiIWSOfcLFJQIA1G5mAFImDs1vT8yT+KD2MmFlcbc+Wz7HIq4x5SYPP/bqDTk/4HYg6dNkSX6eEltbgLdNomFa+igHYIKHjAWLPnvFib9ECLMue4ipNptxlE6AyC8Ls+0t/VPnNF5w5FCVpT8A2iqALbf9tVEdCY++J5U214R5O1igs8yUoWr19vpmri/Qtnv4ku7iGv1wYtFpORcwE2t8lw2jCsJbrb7VMnO94eKBz+bBNUtON2mombCpNTUsi5p3ysmSyCwb8EdgOrXHqXB4YLyu96QbXBQeQp8rc8v7h3rsVaLK3+JMYZWi/aYvbbkIefF1OGy2t/52nFp6XTlOxC1Ri/1P7r/rxO3UI7RKrgg2bHzOE2f7aTRadamx8kj+EllOTZ2JcwRfv4jA 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)(5005006)(8121501046)(3002001)(10201501046)(6041248)(20161123562025)(20161123555025)(20161123564025)(20161123560025)(6072148); SRVR:CO2PR0501MB838; BCL:0; PCL:0; RULEID:; SRVR:CO2PR0501MB838; X-Microsoft-Exchange-Diagnostics: 1; CO2PR0501MB838; 4:CwDz3LOW8a1oQunwWJ0Pewh3TvUFuGhKpWDF5BitHXIX7FsRF+7O30N9OOVB9XKBS4OCw9Fmv6AVaCJkZqC0en7h5oisGLRirUYN8kNLxhQL5+J7kq5AQ57Va1pYI15T5KyRNcEH+aYp2MYAVExV7+IfHOEbsC3mcPKcQIdG6CoGkN+CAteMk1wG5Vf5RJwmtyuXGFsxXNMLTdUTp4nr4HW1uUvS3OKmn91I0XbbvfDg490JyUkuIDEKD8TsJ5rYzUIGVD3ld7VDr0CRaJ4pnFb9e4V7L0oHvYtR2h1PVHAFTc/i0UzZGdo+dB4s7ZapUkRyJDQf4dUUb3oarOw/qnmjZ1nVwbX4Q2UUsNeAIeSRr02wUg5J7rkZD8WG3WqrD+Sd5ZS+1zuPoV4sDKeKQ3gYfOL/yN2zGPdmcOP0VP+EM5ZQXOdhrgm23R0Xj11iQLDWZhzqxax86K1EzmtLRbpUp/ALc/WyYYgGzhV8ldpEOVEFE1u8fehLt9K+xnLucZJ00S7wp5urXEgDovG8yNKnTJZxi8dKZyRVnVGCsPqJThnLYKqrDunKO2sxzCM/6YrI/GDrwGshRpitSJsRIA3oK/dZoQ88mhfNdNaivhgK2V28k8fDHvN3rbA3ZpnRKnGRb/dO+FdyfyXWebmbEQ== X-Forefront-PRVS: 01834E39B7 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(39450400003)(189002)(199003)(7736002)(101416001)(48376002)(50986999)(81166006)(76176999)(50466002)(4001430100002)(42186005)(92566002)(106356001)(6116002)(2906002)(4326007)(105586002)(47776003)(118296001)(66066001)(6666003)(8676002)(33646002)(36756003)(50226002)(3846002)(2950100002)(189998001)(38730400001)(25786008)(68736007)(5003940100001)(97736004)(5660300001)(305945005)(107886002)(86362001)(54906002)(6486002)(81156014)(5001770100001)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:CO2PR0501MB838; H:promb-2s-dhcp95-136.eng.vmware.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: vmware.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CO2PR0501MB838; 23:ugXLX3gxwXCZI45aa3N9VevdDylJzwCoeumV0UoH?= =?us-ascii?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DiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CO2PR0501MB838; 7:UkYNysu9QEQoP8wQNNr45ZvtIVgXfakyWtffX2LcmkwJlytcljd8n/XWmlP35V4EFVkD/96jLOOF9dBSO++KTih6DLS/IUXK5bau1gQ6Tscv4u6OI6+C44f1n2M75QVCAI/SgOwPtizoLJEWiytBnEMDIknLYqTBPHjDSvPZsqIcUTiJqy1hLNYrPkn5BkSn35XGiEZo2aBc94Op8NN9R5rr+nQ5Gj6canix3m14rZ5kcb25Toyp0ETQOdSHv74InJxbyPlovcCug8ew3Ez4QoVg/xBHZ5Mhh6cXcGRMi62drcicZwVrKHP0d5R2fhiG5qH5NAewWRCjsrkgG5MU7ZWgQM3CTzjAGryLsMrGRYK4CZtbrWW2Vy8+DASRS7VBcQeafY7oe58Uto4Zp1ljYeW74xwIvknZwLgaLFU0NG+x1Bd+JM7vbECKLjJYzh/XemEIzbfSATaOOf0ThXXUQQ==; 20:3vvhaec4e09Eg3n0fZ4fvsKQHwoX+4ZQ8G6lfF1dcCcPXb3LqIJA3IYdJ/NudzCa/vRb7/v8vS2/5QmmFfVi9WAdwwP6Sn/MzI9aZZtEGeKbixryaKOI02aRjOCLcvMTPIhf3nX+z+PNHJmcIT7ZAktGTRwsO11tSD1MruQ1FcU= X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2017 19:16:03.6039 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR0501MB838 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. Fixes: 29c8d9eba550 ("IB: Add vmw_pvrdma driver") Reported-by: Yuval Shaia Signed-off-by: Adit Ranadive Reviewed-by: Aditya Sarwade Reviewed-by: Yuval Shaia --- 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 540a54b..ee6a941 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 b57132f..8e21a86 100644 --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c @@ -1001,7 +1001,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) @@ -1010,7 +1010,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 c8c01e5..765bd32 100644 --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c @@ -555,13 +555,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); @@ -599,9 +599,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, @@ -614,9 +612,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))) { @@ -681,7 +678,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; @@ -772,12 +769,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; @@ -807,7 +803,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; @@ -822,9 +817,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)) { @@ -844,7 +838,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; @@ -860,12 +854,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);