From patchwork Tue Jan 10 19:15:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adit Ranadive X-Patchwork-Id: 9508411 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 E02946075C for ; Tue, 10 Jan 2017 19:16:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D377927F89 for ; Tue, 10 Jan 2017 19:16:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C8368284EA; Tue, 10 Jan 2017 19:16:40 +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 CC36028553 for ; Tue, 10 Jan 2017 19:16:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758586AbdAJTQ1 (ORCPT ); Tue, 10 Jan 2017 14:16:27 -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 S939164AbdAJTQP (ORCPT ); Tue, 10 Jan 2017 14:16:15 -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=YNN+mNmSIJYEl5GiKYZt+/rIOFCOLrCmIr2CXP9pFlg=; b=pHHjIvCnZW3a9+m+aTYHmFBBycAeDJoVLC4JPxXtc1SiVWRhdM+yJMJqHQ0ijMcOQr4AtZ5RuG+DI4mTe8Cp7SpCzXfxNeHLXB55LunnK/oH3S4PB/ZxFEmh8q95y3h72obAeAx4351DmsgKs9h/xarG4WFqpO5wpaJF0+k9BXo= 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:04 +0000 From: Adit Ranadive To: , CC: Adit Ranadive , Subject: [PATCH 3/3] IB/vmw_pvrdma: Dont hardcode QP header page Date: Tue, 10 Jan 2017 11:15:41 -0800 Message-ID: <2035e9eca59810687d9b53d7d6e603b765729b1f.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: da70024f-4a81-4863-6cfd-08d4398d1fdc X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:CO2PR0501MB838; X-Microsoft-Exchange-Diagnostics: 1; CO2PR0501MB838; 3:pdmCtb8cRtHJw7L3gGg+lawqrqMekalLMdWklX0j1JptKfwmMNPEuFReSekQQAL+UbcMbXCiZDjvfkPvS0z8L4iyB5Mab+1DnWiB50bUtFKacPKZkKrKXX1dPEzE6/PwySDeIYxOZE77jhiiIYJDb0pcA+oM+dDkf8koji7ylbNkjX+yS1NBMUbEgM3PKC4KRabQZucQoyG/76g0vqz23l//BHm1bOmcp09iYyizHa1zKiRuBzIJ9dIP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4vvAFkddtViXVRdVrR3NztFMCCgIZaZ3KInKm81yYBNscDZncueT1KB0NJA+SmZ3tLqJA48Ta0VPlazzeX3JkUGPfuMj8cWzjP0ayD2oOQcdmH5tliJ6ulnfI1G8MmxpEoNsq4+syp9kKvqspWIM6wK4KEzVS6JqdJydoUnkS4Ea+vGMHcLwHDS6832lFyumLi7tQDbKnOOURYEDTuViBJ68XchrNgZAbaj5Zts4OgFuI83FZ3e4g5soqz1tUGkjzouMQ 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:WJRLbZ5G1D791Mo3GG3SWpLBtu8TqJq0TCXAy8GHY4uNKUsmQf2ZwpjNgn83cIxV0zQ8lOwCbkuUXiuAUTXDvGhb9E7bi49r5qjNst31n/D/gt/bBXP9gXHGNd/9mmdYRVfve1jXmfLNzjSV8CbZDPazLINR7fDQIqVqPe6vEYWA1So4OiNbzQSgV0EXqj3xVfX+4AYyuqZ9LzAKPe0BtcSx0hBBEroduSsz3RWcOTe+GM+g1h+sAPrtcdILFbJBl5UlXPT1biLrU4h82Pa4IOAeA+0WH80deVLvCiiH0tdOzqJMwoVkbso4+1TbVAxPK8oryvpxp3SGBXMQi/opxmemojdcx+MIz31U5LqmqX+SVhEPp2NlXD02/ZI3Ivyqcf9MrLFsgNm4FrVrbyc6DK7KmRrud1RiZgvcAjXuKcKrXCJj7iUGUd9QawMnjgb1e55rvfrHNxkx64q2VnIL8l4GCuC/LGnj3iqLZcW/6Xtm7+SyprvtM0Tj66Euenqe6VulBxqSaSVuzS+jb/7fd549qnxfNcHg4+rZ+hncxfDf1G8bfFehy8CYLvSzLwP23+wyFcthqEXKXiiG+lKofkoynpzv3hQ2Hh4+lG08ro3sjNZTxy0H8/qYtqW3bQyJlTsH8m02vVZR+4+iReMelA== X-Forefront-PRVS: 01834E39B7 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(39450400003)(209900001)(189002)(199003)(7736002)(101416001)(48376002)(50986999)(81166006)(76176999)(50466002)(4001430100002)(42186005)(92566002)(106356001)(6116002)(2906002)(4326007)(105586002)(47776003)(118296001)(66066001)(6666003)(8676002)(15395725005)(33646002)(36756003)(50226002)(3846002)(2950100002)(189998001)(6306002)(38730400001)(25786008)(68736007)(5003940100001)(97736004)(5660300001)(305945005)(107886002)(86362001)(54906002)(6486002)(81156014)(5001770100001)(7099028)(192303002)(6606295002); 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:myAidXs3Of+oyhqPU8bJIoq3tGY3gv7Q2n/kEuV+?= =?us-ascii?Q?VJNSAp1X2OgMM8QRv/BjXHZQ2aHq2giLq9u0FxNkFdIh9CwXie92QrqyzQPW?= =?us-ascii?Q?bNIR00ud2qG8dCOFyNe1PNYFnjQi8EXhPUijlogYuBLEIOwAIJBE8eA0Ygsu?= =?us-ascii?Q?1810CERK1OY9m5zULfIfJ5+NeWs0Tcz+9bZbI1LKIznWn/0bsE6/SUq23Pex?= =?us-ascii?Q?PFM2cdEtlDNbgRaOzWVG1WGngfA/YVgXRHbiuSYUfHKDgVM2MPkhHsZNPYVh?= =?us-ascii?Q?gib9WYyd/y6UgcscZhJCIhfBpeZ2pDgk8RYaU6bQ6NoNMT7hzozP/H1vRZwG?= =?us-ascii?Q?CvK5P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Jj1HGG3VJtteMi37LFAR6C/e?= =?us-ascii?Q?PoNMTUmvG1iFHlHTYYgIfVpgeLghtCvmyHCxfyNk?= X-Microsoft-Exchange-Diagnostics: 1; CO2PR0501MB838; 6:OvjDmsU8D4rheyPSSU2+JkGlSNv9+gMexHU67UKIB6qeGTOLz/AXAs9xmi563mA64V+Uu1DTmS2gYOFXjKrS+05OO+DyN8XiNLYSopGhbNIwHFUhBwx+jXwK5+AjpWJNHkMF+cACcKtv0MM4tyY2/W9kJwwRllqEB3DWYztEhJTYJolC0/2Qk7vfS9+ynWLhFCG30rpvKLSNDTknjwoZ1H1CPg//pAAF6mjsOaNpvPzYLwo5jZc6WPzndmOS0MPoaKEMQsEKiQYBIyjV66FPDpNjsEuYaoG/4iJP8mr+s1ainNWseamJSqjAnUfnKs3gb2cR2kp7t28tR7mzF6d8fmP2oDYDytGrzdmxphn4YV17xffTjWhUYuZqkjpxA7SbcfF9q8dPyyUuqS08DhuZtaTK56Nbrf70VLYk+Mojews=; 5:8WYzNA2tUQmUDTcXP93con6s6dPMj8YZW1rY30hY/wI2bCbG/wQY9IVE6glXDP11AF7ileihfGaZeyIXhrZ8h5WPOzkABZdzmKXphRa/UgPK1kGCIbLaW/XLLQNdLpmQj6yGEHkU5Mz6N1VnQk/M70PGEvPK7JUJeqwHTOwRNR4=; 24:vX+WYYWdpGJkfyLsKgbUW8K3hQMWVnW/n6+usIX5g4QCzEHdOKjLnXKJAtSlhxd8hYVvFvJumj2mh0LzQ7MwZIL41nxxVkiTzull9NcK0NY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CO2PR0501MB838; 7:Pk+czZFO4JpEjZne9dyb026+d3ch7VuqyVKWrTzznIu9ODidZM6NFS8qw6hDGEXumHX01lSDlmmnh11cdtuxzgor9iNhCec7jvJZ7656kWD3JudmZLHwo18GcBefaNjhK87wG/AJG3kGRgUlB2bbKRPNX8NjBp2auEva7q/Qi+a1qaacGc198VtGQjJN4RGr4zqdRVBT3Ok1tNVIm56oUa7mIwWlH/ryaxN3MiPY1St3ePknxSRWMzoQvbXIa58pOeo//85uA8ke9UI38A2buNwW9I9KRlBxOXyVlUF/HkMwWn1kaMu1lP9WOm2Bn24zkwlCSJLEjUQnHBqQlDCC3CkUteJ/Edwm94F7A4MkBu12zoaEY+qBCdGCfzUfqzVEqKht5BVae4QZWkxZgvAjRYQZv1E3XZsXBnx7zPubZOwk/O8jNN7pEJ1fH7n6Bfbx3IvaUwMKYmOu2ii5clc3+A==; 20:x1KW+orgEK9zx1OS3jAkF4byWqp5bdjsCjDDwTycByepbELCpNb5iRnw+sw8JgHjscyYe1kENTVz0l4gT3HGEBl6jc+9ujr1tuc1xV+rDniTaLnd7biA0j97XZKY/GW10c4k4HK8zrYfwITIK5FkABec/Yd3o2r9ZxpBlvOn05M= X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2017 19:16:04.7198 (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 Moved the header page count to a macro [1]. In a future patch we will separate out the allocation for the header page. Thanks Yuval. Also, clear out the alloc_ucontext user response [2]. Thanks Dan. [1] - http://marc.info/?l=linux-rdma&m=148101146228847&w=2 [2] - http://marc.info/?l=linux-rdma&m=148351229926333&w=2 Fixes: 29c8d9eba550 ("IB: Add vmw_pvrdma driver") Reported-by: Yuval Shaia Reported-by: Dan Carpenter Signed-off-by: Adit Ranadive Reviewed-by: Aditya Sarwade Reviewed-by: Yuval Shaia Reviewed-by: Yuval Shaia --- drivers/infiniband/hw/vmw_pvrdma/pvrdma.h | 1 + drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c | 9 +++++---- drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.c | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma.h b/drivers/infiniband/hw/vmw_pvrdma/pvrdma.h index ee6a941..5dada5a 100644 --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma.h +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma.h @@ -70,6 +70,7 @@ #define PCI_DEVICE_ID_VMWARE_PVRDMA 0x0820 #define PVRDMA_NUM_RING_PAGES 4 +#define PVRDMA_QP_NUM_HEADER_PAGES 1 struct pvrdma_dev; diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c index 765bd32..3e23425 100644 --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c @@ -170,8 +170,9 @@ static int pvrdma_set_sq_size(struct pvrdma_dev *dev, struct ib_qp_cap *req_cap, sizeof(struct pvrdma_sge) * qp->sq.max_sg); /* Note: one extra page for the header. */ - qp->npages_send = 1 + (qp->sq.wqe_cnt * qp->sq.wqe_size + - PAGE_SIZE - 1) / PAGE_SIZE; + qp->npages_send = PVRDMA_QP_NUM_HEADER_PAGES + + (qp->sq.wqe_cnt * qp->sq.wqe_size + PAGE_SIZE - 1) / + PAGE_SIZE; return 0; } @@ -289,7 +290,7 @@ struct ib_qp *pvrdma_create_qp(struct ib_pd *pd, qp->npages = qp->npages_send + qp->npages_recv; /* Skip header page. */ - qp->sq.offset = PAGE_SIZE; + qp->sq.offset = PVRDMA_QP_NUM_HEADER_PAGES * PAGE_SIZE; /* Recv queue pages are after send pages. */ qp->rq.offset = qp->npages_send * PAGE_SIZE; @@ -342,7 +343,7 @@ struct ib_qp *pvrdma_create_qp(struct ib_pd *pd, cmd->qp_type = ib_qp_type_to_pvrdma(init_attr->qp_type); cmd->access_flags = IB_ACCESS_LOCAL_WRITE; cmd->total_chunks = qp->npages; - cmd->send_chunks = qp->npages_send - 1; + cmd->send_chunks = qp->npages_send - PVRDMA_QP_NUM_HEADER_PAGES; cmd->pdir_dma = qp->pdir.dir_dma; dev_dbg(&dev->pdev->dev, "create queuepair with %d, %d, %d, %d\n", diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.c index 5489137..c2aa526 100644 --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.c +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.c @@ -306,7 +306,7 @@ struct ib_ucontext *pvrdma_alloc_ucontext(struct ib_device *ibdev, union pvrdma_cmd_resp rsp; struct pvrdma_cmd_create_uc *cmd = &req.create_uc; struct pvrdma_cmd_create_uc_resp *resp = &rsp.create_uc_resp; - struct pvrdma_alloc_ucontext_resp uresp; + struct pvrdma_alloc_ucontext_resp uresp = {0}; int ret; void *ptr;