From patchwork Wed Dec 20 19:24:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan Tan X-Patchwork-Id: 10126435 X-Patchwork-Delegate: jgg@ziepe.ca 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 9509E60390 for ; Wed, 20 Dec 2017 19:25:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84A3F29627 for ; Wed, 20 Dec 2017 19:25:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7993B29732; Wed, 20 Dec 2017 19:25:12 +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 0E8C429627 for ; Wed, 20 Dec 2017 19:25:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756549AbdLTTZK (ORCPT ); Wed, 20 Dec 2017 14:25:10 -0500 Received: from mail-sn1nam01on0071.outbound.protection.outlook.com ([104.47.32.71]:3004 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756455AbdLTTYv (ORCPT ); Wed, 20 Dec 2017 14:24:51 -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=adXGJXgJdxBGLsk5oBM8LuGJS+XDX5EG9oB8yOQEAfQ=; b=PXY76YQkxq3rIza9WGYYye6XbMIuBopUPW06TDKyd5Fl4avQrh8XMrDJtOyuWipAgwzxb3FoPCTSHRIBcY+ERUGKUGG9RRGeXuX1qY1hb9sxzglBldJUYAufAFBFbjwLOZn69nXcand6xsxtNzSBUUbYMsNUYOaCYkKyGsreGr4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=bryantan@vmware.com; Received: from bryantan-devbox.prom.eng.vmware.com.prom.eng.vmware.com (208.91.1.34) by CO2PR05MB2776.namprd05.prod.outlook.com (10.166.200.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.302.2; Wed, 20 Dec 2017 19:24:48 +0000 Date: Wed, 20 Dec 2017 11:24:33 -0800 From: Bryan Tan To: linux-rdma@vger.kernel.org Subject: [PATCH for-next 1/4] RDMA/vmw_pvrdma: Clarify QP and CQ is_kernel logic Message-ID: <20171220192419.GA29589@bryantan-devbox.prom.eng.vmware.com.prom.eng.vmware.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20171220192305.GA28403@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: DB6P18901CA0021.EURP189.PROD.OUTLOOK.COM (10.169.208.159) To CO2PR05MB2776.namprd05.prod.outlook.com (10.166.200.134) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9c3586d6-d104-4468-170e-08d547df5697 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(5600026)(4604075)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603307)(7153060); SRVR:CO2PR05MB2776; X-Microsoft-Exchange-Diagnostics: 1; CO2PR05MB2776; 3:dfDQwQxSAcBexMHCDysGRWGAbJRezXZa1y3mRDkRzeG/me5CJLKJEPR4++GLAjal9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VH5odKaVKnPVEkxdg1yzR21URqAyxnfQ+1dg2fIP8w7po//ImscH+9NaaLThk4e8Q5Z5vsZGqGRuVIgpA2qUWxrs+Y8GHPJUrcCBXoZjo/ch1RaSNj8onU+BtMKUF9ln8MotIbBgcVQzoCk0kh0KKMnOUTNThx9dIPpUpPvb4d1zPilzVxlI8ioleeDMQXxKjN3hlbYBxZALb/2L18jZZQyz0S0QszSDhRQybyXLNyxABTEQ5SQ286bkwTkvJd8b+69mLDDzt4Hf0dzo/SznRQVzD4qNE4CH; 4:L/xCIpXZhpzVxI6SPtYPURL0P+PPAncxKXFbtiRO4nnsVcx/5hNwNp8xsiB9zY8eMXCRCeHnao2PVCOgYZ3oOJbZqM0aAU8jGwBeyyEJfsITh+OZ2l05OFvAs0CuZHIQ0qJhume4IPEX+PMZBDVvStLSJtn9qaLJvAWBbM2rrKtabUM8PBdvy6L8hV9NETUMtUh7kyUG1OK/e9cw0VkX1+/FjDu0SayuLfvaeUNqLDGqyMr784rIANgOCdRDuvxsUpxzlZk+BDU9+4CrgXjW2fckbpqd/BPJ4irlySHmz6+qUtJs2puARzAnT1SFHmPk X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(61668805478150); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231023)(3002001)(10201501046)(6041268)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:CO2PR05MB2776; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:CO2PR05MB2776; X-Forefront-PRVS: 0527DFA348 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(376002)(39380400002)(366004)(396003)(39860400002)(189003)(199004)(386003)(68736007)(53936002)(52116002)(81166006)(105586002)(7736002)(7696005)(8936002)(106356001)(23726003)(2906002)(1076002)(58126008)(2361001)(59450400001)(97736004)(83506002)(33656002)(16526018)(16586007)(478600001)(316002)(25786009)(6116002)(86362001)(8676002)(6916009)(305945005)(2351001)(50466002)(55016002)(66066001)(5660300001)(6666003)(81156014)(47776003)(2950100002)(3846002)(18370500001); DIR:OUT; SFP:1101; SCL:1; SRVR:CO2PR05MB2776; H:bryantan-devbox.prom.eng.vmware.com.prom.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; CO2PR05MB2776; 23:H0QYfnwGQyvMyUJLD3UW/rVVug2x+fRMWNosLt19k?= =?us-ascii?Q?0WpQmXlIs56gY+eU4B1ouEvVUFQq8yRxKxi2yB+hpAA4IlC2+ZwnG08rrUsn?= =?us-ascii?Q?4P8TzQXUUPILAzAgHTGOqUbRFMb/KtxnYVj2avpEwHc09odqjdHiCBszF2W0?= =?us-ascii?Q?2rqTURV4UFiiChXGp/GXhop6jk3bGA2cgZVyO7+VNMEEzecMxqaHgKHShKPA?= =?us-ascii?Q?4JREHvLjD9YAA43KIOye8JfEBzmxKGE9RaPMXoxpn2oM1BihdevZLMGowlw5?= =?us-ascii?Q?ngwee3PYNhhBGXq612lzT2RQo6o+7sitijAZngqRt7LjpHtSJICjGJMdzHc/?= =?us-ascii?Q?ZZX/ryMOPURsiMd5dVGfn9JziIzCjqjOwvsdpiB7PtDMkYFbysv1uVbntiYS?= =?us-ascii?Q?thMOjFTWA/ledflX4/4OV7rezndw4UpQy+ZSiLTXhl+kH9ToVaWWlaj4D28U?= =?us-ascii?Q?wwJEyPQLdTE0KYxipzAoQhjWrm9ATsxFbPnV7IBrXTUFIohaxBdAT23LkXIX?= =?us-ascii?Q?A9gmsG3jFRr6mLiQDxvoFklvQ8ugaNkKkjkqIIxQ2u5wCgjfwzHL46iW8nmM?= =?us-ascii?Q?x0yvAAvIo4GZPg65kMcRUwFCJaBL6VvGp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3P/fwbaQ6xil3ulEjSB7aav9Or15P+yp+5L8p2ig3FWtb5q8/mQNl0oDsQcBQ78NmIuMvLXOKTBliKlFUZKBrhHNHMSis19zkMOoQA9Jx6TlwFyzTX5cEp6gfcVBuQCYCtAh7XDMseWCvVgkus=; 24:P3UkzeWka6w6dHTbstWqeNHO7osy44Axu1OO+/FMAAs3uG3tkWDAzPRS0iKUzUqHCKec2JLzjliohQXY2SKa9VORFdAxIGs5ed2GJZ6h5CQ=; 7:L0f1ePh4pzjKiZgggPRyAuBOAcVA7DdK2C3V029qBcE11LbDCJnP6dGVnGAss7dxANEzMrEEpXRdrajj3D1J18pfJ7Lnkkkpx3SvIo7BZtzNOkMsnGy1DP7FgT+DTPKsuVQlf6LHWrmnYhqYgyJN04Bmo+DkhUqNlJr0GNu2m0305TITKtwrXLj+W3GtrCFqkoW1i2VkkhYTHUq2RtWNSZTPT1hZx/CeXPCWoC99a7sTjryrtpI/YQp5kyQDnSG4 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CO2PR05MB2776; 20:PS5zaGIohS9r8euGAIfeR+NHOxPRuzt3Ep4Yxfvvg+K/32rmc9m8okuWIdyTaN/Q5nWYgTZScZNobEhfAxheUwAlJAld3xu+9sLVNiaK9LGm7Z5YvneJSSMLumKXMlTiFjoSm+QerJb8oKJsLjl1cVBPT/akdg03L7uUpx734/s= X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2017 19:24:48.8970 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9c3586d6-d104-4468-170e-08d547df5697 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR05MB2776 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 --- 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 e529622..cc46161 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 4059308..9dd556a 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_completion(&qp->free); 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)