From patchwork Wed Aug 3 23:27:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adit Ranadive X-Patchwork-Id: 9262353 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 EFCBE6048B for ; Wed, 3 Aug 2016 23:39:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E02FE27FB6 for ; Wed, 3 Aug 2016 23:39:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D47372807E; Wed, 3 Aug 2016 23:39:32 +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 2703627FB6 for ; Wed, 3 Aug 2016 23:39:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758474AbcHCXja (ORCPT ); Wed, 3 Aug 2016 19:39:30 -0400 Received: from smtp-outbound-1.vmware.com ([208.91.2.12]:44321 "EHLO smtp-outbound-1.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758363AbcHCXj2 (ORCPT ); Wed, 3 Aug 2016 19:39:28 -0400 Received: from sc9-mailhost2.vmware.com (sc9-mailhost2.vmware.com [10.113.161.72]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id 3895598687; Wed, 3 Aug 2016 16:28:26 -0700 (PDT) Received: from EX13-CAS-006.vmware.com (ex13-cas-006.vmware.com [10.113.191.56]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id 31DC6B06CA; Wed, 3 Aug 2016 16:28:27 -0700 (PDT) Received: from EX13-CAS-002.vmware.com (10.113.191.52) by EX13-MBX-000.vmware.com (10.113.191.20) with Microsoft SMTP Server (TLS) id 15.0.1156.6; Wed, 3 Aug 2016 16:28:26 -0700 Received: from NAM03-DM3-obe.outbound.protection.outlook.com (10.113.170.11) by EX13-CAS-002.vmware.com (10.113.191.52) with Microsoft SMTP Server (TLS) id 15.0.1156.6 via Frontend Transport; Wed, 3 Aug 2016 16:28:27 -0700 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=u1ElGihweSDjtjbuQOAcMPKoVGawDLc0EUL+3VUx32M=; b=KpkJ5L1ZidEyZsE78H71x/20q6PMOyIG7nTVlE8mpd/7s1sOmuAcl3OdPaJfflJareVJv2k6qZEqgQl+gxxZhKai58ReDjZpDV4dK6XZ3SJPLlyxcWWIbWNmmyH3o+OfcJPUlg7WkSYuxBPoSfxbY/enp0TT67Y9rJbzcd6X58w= 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 SN2PR0501MB847.namprd05.prod.outlook.com (10.160.14.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.549.15; Wed, 3 Aug 2016 23:28:21 +0000 From: Adit Ranadive To: , , CC: Adit Ranadive , , , , Subject: [PATCH v3 09/15] IB/pvrdma: Add UAR support Date: Wed, 3 Aug 2016 16:27:38 -0700 Message-ID: <1470266864-16888-10-git-send-email-aditr@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1470266864-16888-1-git-send-email-aditr@vmware.com> References: <1470266864-16888-1-git-send-email-aditr@vmware.com> MIME-Version: 1.0 X-Originating-IP: [208.91.1.34] X-ClientProxiedBy: CY1PR12CA0084.namprd12.prod.outlook.com (10.163.230.52) To SN2PR0501MB847.namprd05.prod.outlook.com (10.160.14.145) X-MS-Office365-Filtering-Correlation-Id: b7fa966e-c372-4a3b-2320-08d3bbf5dc0f X-Microsoft-Exchange-Diagnostics: 1; SN2PR0501MB847; 2:wLDpbrUbJ/hgTShvdkgClt5LM/a/79DbzBFmIEIrWC7qytsPcJxXzcuUW5LZBvhdI+I+ONZZ9NW/hNwMJI7zL8sXTGL26Av4Erb8BATAy2tkmEFNYAe++XGj0q6uq4Dh0nyvvMXDms5DKhVBZMDCCAkhkqu4POEeVCPSaTdHeQwuFwm0Ry+kINW25kv9eRKW; 3:gB+w+6Ok3vj0AjOt4Kck3cqXrfQH48cX7qpZSdO19fGO7t2LcL4piQw4UxnIvnxse5SoUKOKRyWIUAHdeD7hLno2QwT59Zy5p9E/8tVlku6OfjkkBoni8r3r7U6B3kYk X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN2PR0501MB847; X-Microsoft-Exchange-Diagnostics: 1; SN2PR0501MB847; 25:E28jgYH32BrOCB13pDr28Rsp9RGd8/9AjFAOJ3IxnZ+lg9cdPR5++37Kgx8oSigvsWALXzCgNvMeKOxvvyWiCI/FesKHo+3YesN0Ewf9A7rZvEVWZhphqIcbxGdk+wqrz154F3g5rpeA+Tix0kYMFmgKp7I8zido7TuCdb7DnC2iIXHKKwTr9Ac6zfOS4lwn0IXCkjvobAjNjF82asB8KKuIhLyqIcKbX8v+5xUVDeS1ENfELmKofDLgBnGBVL21Q+/QXHhhVpmwG1FO7hXEmVS0LTkH9Q57bSbkSJNu4gIJm5EZuuTu9A7CcZVMusyxlH0/o57YD4MM/3WAGvL6ZsO8Yo6az2M/znv9oie3IC+YFcd66wf1v9dGnrJB0RcQd1CBhn/yXY8/V+tl2u09R24aOHjqJ2HMhH1KR1I9yZ+Sgc1rM48cnABVxxA2UFH1ffaA4BVw9kgpj37/mCy0JFMhES6deiSZkz/81c2bCh1jYjaY0KfnXh8DB6D1qtigI28GDuG30gp5L4N+soPh1/I81GZ0tiTYFrSiLfbm+QUqjV4c2vgiGw+qRShB5zfWTOuYhpHodBkQcIDozRwTb/JPHdSJ7qEhwMHovDyjso103nCGJSNn8danqyNrQM6cKM9UL61hKgectDAm3lqpoburRzsM0o+RjMKP2ZT/RLWbZHtWqaU5lQgJYEpiERDkn+i6tfLN83qTSO534IHWSCzJMjRu1x/vynPVfKiwxWauE87DBklq/pbPLKvDa9pib4JwJNK+uf2Qr52KNMFSlTIvbFJzP1eRUM3dhaNwNNI= X-Microsoft-Exchange-Diagnostics: 1; SN2PR0501MB847; 31:AJ3cZFyycERRw2BQ92GzEpqiz0nMGooOuKZ1K9FWb3IOnFN/rBA/zAMJpTqivMKXfiNhKk4f3MnGVKLmb3IAFSISAEU1xPdCKZpHTjN9W3Uh5CAreSuupvO18IRr1aEckzXzWRnsvduhFpBLEeIPTnbR23w6TqvNV1QlQIPwjkriFHyK3tYJby3CNui3mzR0cEDVm2TG8jgqU3pGJYg57HtDDXEGpRa84WxVLHXTs0g=; 20:d/mgo9F15AZ8wArzMEcsG2VRLJDBjbra0uyf6Ddw9KLHw4VDuUuf9xxJmrYyrx8zlRfNI3AHRKBeunJxOBnKI/fttzYQ8p3vqz8lQTUPlVYVhmZ7+HCiEx2Q+aCuFRWRX6wj8Uf9yr+sKBN4Db92j1BatXeqDg834rwgKeVdxpnCIWHySMX2IlMy6wrK9DCToCYFEsf+sNXx+JuHPvvGZo6U8ZcE2pI11RvhhSjvDlKmsLqYjqdGXrc+rE5yXjrT X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(250305191791016)(61668805478150)(22074186197030); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001); SRVR:SN2PR0501MB847; BCL:0; PCL:0; RULEID:; SRVR:SN2PR0501MB847; X-Microsoft-Exchange-Diagnostics: 1; SN2PR0501MB847; 4:BV6Qesg7iYHgc4/xwsR9BkaVQfXsNqTmcynSva2TjPVpq7dJEejteMYXvoUQ7BEB269OPkKWjAwmGMLlJD+Osq5s6Ld+USB7M1eGRB+QedSNIDNF6p0GC0vF/E0IsWCnCoVDCzK0dvWUBFd3scRSLhbCPGKXMangMGoiw/efOfIIuEkxNfkE5O7IsfBJ5JkuOudQXmQI9XhgdSPPoziJTkGXWT43FupX6Dp87W0e2BjfmXhKMDnAmr1wGhp2VkvqaFjhPiTIEC2441tII3OHYf7UhufqF3f2/umwHm1lBrwrRzOVAHyxvMiIsRNshEeRbXIkJVArqOn0JaiqgRSEU7Z35B8pKBhbI6bkZDkDTW5KmuWngSJB6Tj3Jjj6p57r3vXhxph0w8QD0XPTVANwFXnY5m+7lE+jORuJpnD5/bNov5//uj/R0Nn36PlZKbL1lxGmTzlr8ChzaMH9D3OoW92V9dyjlpl7skRbBWxkea8= X-Forefront-PRVS: 00235A1EEF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(199003)(189002)(4001450100002)(66066001)(106356001)(189998001)(33646002)(92566002)(107886002)(5001770100001)(77096005)(15975445007)(229853001)(48376002)(50466002)(101416001)(97736004)(2950100001)(42186005)(586003)(47776003)(68736007)(76176999)(50986999)(4001430100002)(2906002)(105586002)(7846002)(7736002)(305945005)(81156014)(50226002)(86362001)(81166006)(8676002)(6116002)(36756003)(3846002)(5003940100001)(19580405001)(19580395003)(2201001)(4326007)(7099028)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN2PR0501MB847; H:promb-2s-dhcp95-136.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; SN2PR0501MB847; 23:CJvF1K2BeTosCTHFQ1K1M+dPVDfbTAvfGxU8FHgS?= =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7uiu9fK3WQIST34fPIo6GSZ9JqOemn+2GAzXoeknf3Pn8TF5GMt3xcV0ILd263d5lH1526HDJwDGYd1+Vsc1aCq3stUSu/1CNj6Z4/17vRU5rww9xBlTyCOdzhmvuZHU/vXt/nBQTUt7LT0Gc6kABT2Efe+DJChCXeTdqDmMmXYCsHckCPo0sbT2o6r9oXgyj8/qfoxmUNLq9tc3Ux/wUwAbzFXHbDt SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN2PR0501MB847; 20:NzCyIb+pPl89p6oh0k3tPIyHrn7nEbYol51PP7MxcZHn/bBWzZjr44D2FvqX5gL4R/3uEF4p++OUnJ81BmhPQ8YRxpYyj0/8Ja8kA5COQaJnhzGqiOdTUXVUAjvmwJpDGUPHrNd7aVnFx61vNQm1OY+ayTl+GctYwahtNyk8TkI= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Aug 2016 23:28:21.1951 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR0501MB847 X-OriginatorOrg: vmware.com 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 This patch adds the UAR support for the paravirtual RDMA device. The UAR pages are MMIO pages from the virtual PCI space. We define offsets within this page to provide the fast data-path operations. Changes v2->v3: - Used is_power_of_2 function. - Simplify pvrdma_uar_alloc function. Reviewed-by: Jorgen Hansen Reviewed-by: George Zhang Reviewed-by: Aditya Sarwade Reviewed-by: Bryan Tan Signed-off-by: Adit Ranadive Reviewed-by: Yuval Shaia --- drivers/infiniband/hw/pvrdma/pvrdma_doorbell.c | 128 +++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 drivers/infiniband/hw/pvrdma/pvrdma_doorbell.c diff --git a/drivers/infiniband/hw/pvrdma/pvrdma_doorbell.c b/drivers/infiniband/hw/pvrdma/pvrdma_doorbell.c new file mode 100644 index 0000000..c8c6c57 --- /dev/null +++ b/drivers/infiniband/hw/pvrdma/pvrdma_doorbell.c @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2012-2016 VMware, Inc. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of EITHER the GNU General Public License + * version 2 as published by the Free Software Foundation or the BSD + * 2-Clause License. This program is distributed in the hope that it + * will be useful, but WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License version 2 for more details at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html. + * + * You should have received a copy of the GNU General Public License + * along with this program available in the file COPYING in the main + * directory of this source tree. + * + * The BSD 2-Clause License + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include + +#include "pvrdma.h" + +int pvrdma_uar_table_init(struct pvrdma_dev *dev) +{ + u32 num = dev->dsr->caps.max_uar; + u32 mask = num - 1; + struct pvrdma_id_table *tbl = &dev->uar_table.tbl; + + /* Power of 2 */ + if (!is_power_of_2(num)) + return -EINVAL; + + tbl->last = 0; + tbl->top = 0; + tbl->max = num; + tbl->mask = mask; + spin_lock_init(&tbl->lock); + tbl->table = kcalloc(BITS_TO_LONGS(num), sizeof(long), GFP_KERNEL); + if (!tbl->table) + return -ENOMEM; + + /* 0th UAR is taken by the device. */ + set_bit(0, tbl->table); + + return 0; +} + +void pvrdma_uar_table_cleanup(struct pvrdma_dev *dev) +{ + struct pvrdma_id_table *tbl = &dev->uar_table.tbl; + + kfree(tbl->table); +} + +int pvrdma_uar_alloc(struct pvrdma_dev *dev, struct pvrdma_uar_map *uar) +{ + struct pvrdma_id_table *tbl; + unsigned long flags; + u32 obj; + + tbl = &dev->uar_table.tbl; + + spin_lock_irqsave(&tbl->lock, flags); + obj = find_next_zero_bit(tbl->table, tbl->max, tbl->last); + if (obj >= tbl->max) { + tbl->top = (tbl->top + tbl->max) & tbl->mask; + obj = find_first_zero_bit(tbl->table, tbl->max); + } + + if (obj >= tbl->max) { + spin_unlock_irqrestore(&tbl->lock, flags); + return -ENOMEM; + } + + set_bit(obj, tbl->table); + obj |= tbl->top; + + spin_unlock_irqrestore(&tbl->lock, flags); + + uar->index = obj; + uar->pfn = (pci_resource_start(dev->pdev, PVRDMA_PCI_RESOURCE_UAR) >> + PAGE_SHIFT) + uar->index; + + return 0; +} + +void pvrdma_uar_free(struct pvrdma_dev *dev, struct pvrdma_uar_map *uar) +{ + struct pvrdma_id_table *tbl = &dev->uar_table.tbl; + unsigned long flags; + u32 obj; + + obj = uar->index & (tbl->max - 1); + spin_lock_irqsave(&tbl->lock, flags); + clear_bit(obj, tbl->table); + tbl->last = min(tbl->last, obj); + tbl->top = (tbl->top + tbl->max) & tbl->mask; + spin_unlock_irqrestore(&tbl->lock, flags); +}