From patchwork Thu Dec 14 00:19:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan Tan X-Patchwork-Id: 10111251 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 D8D7860352 for ; Thu, 14 Dec 2017 00:20:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8458298AC for ; Thu, 14 Dec 2017 00:20:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B56D629980; Thu, 14 Dec 2017 00:20:01 +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 261A029916 for ; Thu, 14 Dec 2017 00:20:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751477AbdLNAUA (ORCPT ); Wed, 13 Dec 2017 19:20:00 -0500 Received: from mail-sn1nam02on0065.outbound.protection.outlook.com ([104.47.36.65]:55264 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751121AbdLNAT7 (ORCPT ); Wed, 13 Dec 2017 19:19:59 -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=QUoidc4G+JrxxEE8UT6BZYbhhFwNW8nYxkCfeSiKmLs=; b=XmrHpZMg/7Ril8HTqppb3zHa1dck3cGYH58vFb/cRssr8FU3D2v+4B4oqru55+MuO1QgL0hXlafT6RuQzlx6EKUnRvaPHLPUcFtI6zvLa8syoBBcQj3jW+6MlNjC6XpD3QY7JwnSSFgVqmAgnD38Veu4vkZJzygA3/BJ/6ZBhIk= Received: from bryantan-devbox.prom.eng.vmware.com.prom.eng.vmware.com (208.91.1.34) by CO2PR05MB2773.namprd05.prod.outlook.com (10.166.200.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.302.2; Thu, 14 Dec 2017 00:19:55 +0000 Date: Wed, 13 Dec 2017 16:19:43 -0800 From: Bryan Tan To: linux-rdma@vger.kernel.org Subject: [PATCH v1 for-rc 1/8] RDMA/vmw_pvrdma: Clarify QP and CQ is_kernel logic Message-ID: <20171214001937.GA11378@bryantan-devbox.prom.eng.vmware.com.prom.eng.vmware.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20171214001753.GA9780@bryantan-devbox.prom.eng.vmware.com.prom.eng.vmware.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Originating-IP: [208.91.1.34] X-ClientProxiedBy: BN6PR16CA0023.namprd16.prod.outlook.com (10.172.212.161) To CO2PR05MB2773.namprd05.prod.outlook.com (10.166.200.25) X-MS-Office365-Filtering-Correlation-Id: dd93ef37-4492-460a-1b92-08d5428867d9 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(5600026)(4604075)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603307); SRVR:CO2PR05MB2773; X-Microsoft-Exchange-Diagnostics: 1; CO2PR05MB2773; 3:Cj5vtUtmxybeq1LgLa+F/1trelEnaSmtHVTlNFUpEPUUiBn0gmK+q4gG7SX5qBXLFNAfW2GzrEw6XnbhsbnDxOxQ9PhzXov1rj70CXd6USnI5QpeM1bpLPnsekTarYLGMVYRJJuEopUq64+e/KCGcjcWEVxgMiyY0Rjt9DwRQZYNkvSfoibRJrs8O7DEQFVE5NJZSBAfpDjHIJMDKkazYix/99JSvcAlVzRxUHYhAdw1WG8mOmjJXaIkCrP180iD; 25:52qaRoXpj6Yuzdy4O9Sv3UvyTke3J7onUwe6z0lrYObdox/SGda5UQyLWFDMFpDOUtiElqR2fCVROq+By4wGMPXMg2yd6oJDFLIRLQNUOb5Ytx78WqN6ZkseoplabOVLzs2JU6i+s6/4olxp+Infey+xzQlX/y6ZlmUe1mKlAWBSpjEzEN/8/NkltulSga9i7s/cRFbaZYDAh7LV56C8+QvmBKwzKeBz78Md524D7k2GTE5ShXrpFAbtj66IHMZCcAc4BwF4++xxMJgr8fBOFb3QG4BQw0ez4U6WFA2aJCsim2GE9Gf0Evl7AxewAl2M3pKv9N4WO8+a2mt3TZBqLA8jrYR6Qxhxae3XKEScSEM=; 31:JgA/2+nVSlFRzUQ8R6fILxvV5PVUBVNN+ID8XMhJHz3CnrPkNX8a1Hhx/bxh6pWOcHG+Mtvo+1ySaI3dEHhp3QxlMQn89Ta7pNfIzUnneDeN/vcr0/EXpaW91SBl7/XdyVFToL0eDLTfHQLR4pOm0Zkzj7Ckix215oymwWz3gxTgO2jStGeUGOabW1BGAZRRHgB4ULP5WaShj031uqln9TnDxr/Xprqe940O5K6hFtM= X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO2PR05MB2773: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=bryantan@vmware.com; X-Microsoft-Exchange-Diagnostics: 1; CO2PR05MB2773; 20:XXpFXAb17O2aMxgETl+XfaRI+NtXcXQadbgufTOEPbraMg+5ABSo7BGxnDi3yHHOtRwcElGGvwlL1nG5sLEPXN2D/9nu67qNm1nxemcKWDKrvZsCoT4Gzxm54U6ONmOsiJm3q7hNT3teGSniP+8Qj7ifcMfi54RB9KSFBRmnMar/BS0a3lZj9Sf7EUiwN/g178IOdMsuoIotR5kSd5sDM1+hnszEltToc4hBLHrgGT3w2GXxqVEhTPgQ9Vqf3pmjTtS8uskRRYtsA/dSrv+6fXT1CfwTNwOyK41j6Ey9+KEPoEkcAafvGJ9dPBlakHZhqJPM6gRp3nibsODEeGYYP+97O+6MM3zdsF7faSBA2Zsu5wIlNYSESZcP60bUXunIdgT9JI0pEzaco+2BU3ECqxAC928wJlmGnTQ+Jl0OEgTPe3JgPnS6s2HIpmuXITa+7iqaXex0G9IeuSruHJD22rJVvtO3snSG2Qw/MoLyeC/BxNyDNmA2Eu/uyY0zNg40; 4:v9o+R6ZZVZgN1l1sPW6IgeU2a6/FiVBJf4/LMQYymfLmRKFCj4CB6PiNSFjQZHtNh/SjnYe3TiVZYqaUNkHyR33a09dhekxSIgVQ0X588NODWF4tH34ZBdpl9Oj+GqMVbcsfmsxPC/9yeCrMnZwQg5Nah1JD5kp/h2DT8eNqJRH0G7xP9NMsr8Av540I1bB3RY68+LYWEDyWJoK+plQgrmwT5FGJE32+wX0g5ucQPEEJRhs/wNiiFFzAIuRKjFj7KFJ7Ui4v+8mZHmbqoqWsLYaIhUx9Sn4k8jyxTobik8nWvFGmmWGum53u6aEcxvsK X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(61668805478150); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(2401047)(5005006)(8121501046)(3002001)(10201501046)(3231023)(93006095)(93001095)(6041248)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123564025)(20161123562025)(20161123555025)(6072148)(201708071742011); SRVR:CO2PR05MB2773; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:CO2PR05MB2773; X-Forefront-PRVS: 05214FD68E X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(396003)(376002)(346002)(366004)(199004)(189003)(16586007)(25786009)(58126008)(50466002)(53936002)(83506002)(55016002)(1076002)(105586002)(316002)(6116002)(2351001)(2906002)(3846002)(575784001)(23726003)(86362001)(68736007)(478600001)(2361001)(106356001)(16526018)(8936002)(81156014)(81166006)(8676002)(7696005)(305945005)(33656002)(52116002)(7736002)(6666003)(386003)(66066001)(47776003)(5660300001)(97736004)(59450400001)(2950100002)(6916009)(18370500001); DIR:OUT; SFP:1101; SCL:1; SRVR:CO2PR05MB2773; H:bryantan-devbox.prom.eng.vmware.com.prom.eng.vmware.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; CO2PR05MB2773; 23:qa0lHPZ8IYsYePtWKuKKyKyUjLcjD1z636vM66b/m?= =?us-ascii?Q?KZgZPupazZjjHusGlCcGXIWGawVKri4ImOV5zjUS3E3jsNu9EcWHJwDpO/he?= =?us-ascii?Q?zdRhg75IlBD/9iQ6vf8QedmOyZOXRTD2D0miMUI0iY5/lGrm6DYJjPpHYBvZ?= =?us-ascii?Q?xy4//+snax5MHLl5w6GqYInYjxLAO3PNu+tqBBLp6ONXEqpZKJ5cYkpoFL75?= =?us-ascii?Q?o7KfTVYJ6/zX0onXp+zknpCUh7xAyegLoGnHyQyuION6pPkNUaupH1mzGv5X?= =?us-ascii?Q?BF7ZDYjettnrjRCESDqqvWleMpYWHjLk3NjnLjHqwo5a/zMrjjyRIkzMoSi7?= =?us-ascii?Q?wOyfybFrL7cJaod47fmzD4pMhHdqgN80bAJJ46vbq4re496fQiNZZOhwWedc?= =?us-ascii?Q?QwhsExLH67eGqb5dDdn04j0H2csPZAXh4MTVHtGLqwe3REjdgLaxq0WhCZMT?= =?us-ascii?Q?5KGpN0PuEax5iLXwGeL3gTluni/MnLt9uNN5BGAdDlcWDs8982t6tpasRaRu?= =?us-ascii?Q?RbzlWdVwpfRd7i27xrcq8MMzA6+7GDlMNQLfBKoueMN8SIgf+E8adwDfobJh?= =?us-ascii?Q?7U+HldDZyGHovAZAS3TgYRXJ4zDqOpmXLBFcJTN9GjoB2/7T8NVxo4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FWL7WznatH6Vwo+SVBp306/VkJH/J4SbfY7ep2E9821xBhq6CSuGyt3s24he6WMIaNTzhEVUZPZZ+JfgeOWIaYuiZsK+UuJsFVfMCl/BoRxhFcrQfy6//IRkvhtzG5nNE=; 24:AYi2VMCM+tkIeErPXsd4jzjmHtTi9NJxPRr5kQbNKB/BX8Vjb1qDIzJp1KFF89FSQ2HXCtnw0TgAJGacd/q7I3yID0LApG+qxJh+19owVAg=; 7:wwsCb8EMyEhacAQxf8e6qE4caz6CxDwmZoCaVdOKBSkjXM5jwaplYbbK3cbIhKp+zBwTr0YNvK6tslmT4rQkGvFGt3n7B++So1tvf7dnDWhMOv7aSfZKAnE+dQznh2vIz/6KDx65igJFM8BsGIjp0bQ2+Bz6rl7Olm7XDieV+joyDJIIlJdWvmWtbBRlgXgrSs2cEFAR9UGv3l1K7x7mw4Sgk2xrSAdQ8JZybXvBJw7f2AvU9yuOsKQjtfeBJbLs SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CO2PR05MB2773; 20:qKKN7O+owEEAh0UEy24l7/zoMBA2gW+ReLBrbT2LXRGDoddL2ONh5+1/a+OrykCHpW+Ix/h68hCMPzWhoW87/HT5f665daLstw04PB40TrqpoSrBJG38BRKFDwHm5yV+1oxciBDN9uYVsfiwYR26JrG0qZ6qgpSk4cRQfATRhEs= X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2017 00:19:55.8372 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dd93ef37-4492-460a-1b92-08d5428867d9 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR05MB2773 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 Be more consistent in setting and checking is_kernel flag for QPs and CQs. Reviewed-by: Adit Ranadive Reviewed-by: Aditya Sarwade Reviewed-by: Jorgen Hansen Signed-off-by: Bryan Tan Reviewed-by: Yuval Shaia --- drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c | 9 ++++----- drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c | 7 +++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c index 3562c0c..ea8db5e6 100644 --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c @@ -132,8 +132,9 @@ struct ib_cq *pvrdma_create_cq(struct ib_device *ibdev, } cq->ibcq.cqe = entries; + cq->is_kernel = !context; - if (context) { + if (!cq->is_kernel) { if (ib_copy_from_udata(&ucmd, udata, sizeof(ucmd))) { ret = -EFAULT; goto err_cq; @@ -148,8 +149,6 @@ struct ib_cq *pvrdma_create_cq(struct ib_device *ibdev, npages = ib_umem_page_count(cq->umem); } else { - cq->is_kernel = true; - /* One extra page for shared ring state */ npages = 1 + (entries * sizeof(struct pvrdma_cqe) + PAGE_SIZE - 1) / PAGE_SIZE; @@ -202,7 +201,7 @@ struct ib_cq *pvrdma_create_cq(struct ib_device *ibdev, dev->cq_tbl[cq->cq_handle % dev->dsr->caps.max_cq] = cq; spin_unlock_irqrestore(&dev->cq_tbl_lock, flags); - if (context) { + if (!cq->is_kernel) { cq->uar = &(to_vucontext(context)->uar); /* Copy udata back. */ @@ -219,7 +218,7 @@ struct ib_cq *pvrdma_create_cq(struct ib_device *ibdev, err_page_dir: pvrdma_page_dir_cleanup(dev, &cq->pdir); err_umem: - if (context) + if (!cq->is_kernel) ib_umem_release(cq->umem); err_cq: atomic_dec(&dev->num_cqs); diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c index 10420a1..b932b7e 100644 --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c @@ -249,8 +249,9 @@ struct ib_qp *pvrdma_create_qp(struct ib_pd *pd, init_waitqueue_head(&qp->wait); qp->state = IB_QPS_RESET; + qp->is_kernel = !(pd->uobject && udata); - if (pd->uobject && udata) { + if (!qp->is_kernel) { dev_dbg(&dev->pdev->dev, "create queuepair from user space\n"); @@ -291,8 +292,6 @@ struct ib_qp *pvrdma_create_qp(struct ib_pd *pd, qp->npages_recv = 0; qp->npages = qp->npages_send + qp->npages_recv; } else { - qp->is_kernel = true; - ret = pvrdma_set_sq_size(to_vdev(pd->device), &init_attr->cap, qp); if (ret) @@ -394,7 +393,7 @@ struct ib_qp *pvrdma_create_qp(struct ib_pd *pd, err_pdir: pvrdma_page_dir_cleanup(dev, &qp->pdir); err_umem: - if (pd->uobject && udata) { + if (!qp->is_kernel) { if (qp->rumem) ib_umem_release(qp->rumem); if (qp->sumem)