From patchwork Mon Oct 3 02:10:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adit Ranadive X-Patchwork-Id: 9359921 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 136D460459 for ; Mon, 3 Oct 2016 02:11:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0627228904 for ; Mon, 3 Oct 2016 02:11:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EEF7F28986; Mon, 3 Oct 2016 02:11:14 +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 5BBAA28904 for ; Mon, 3 Oct 2016 02:11:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752104AbcJCCLN (ORCPT ); Sun, 2 Oct 2016 22:11:13 -0400 Received: from ex13-edg-ou-001.vmware.com ([208.91.0.189]:24861 "EHLO EX13-EDG-OU-001.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752065AbcJCCLM (ORCPT ); Sun, 2 Oct 2016 22:11:12 -0400 Received: from sc9-mailhost3.vmware.com (10.113.161.73) by EX13-EDG-OU-001.vmware.com (10.113.208.155) with Microsoft SMTP Server id 15.0.1156.6; Sun, 2 Oct 2016 19:10:34 -0700 Received: from EX13-CAS-005.vmware.com (ex13-cas-005.vmware.com [10.113.191.55]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id 9674C404FA; Sun, 2 Oct 2016 19:11:11 -0700 (PDT) Received: from EX13-CAS-002.vmware.com (10.113.191.52) by EX13-MBX-023.vmware.com (10.113.191.43) with Microsoft SMTP Server (TLS) id 15.0.1156.6; Sun, 2 Oct 2016 19:11:11 -0700 Received: from NAM01-SN1-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; Sun, 2 Oct 2016 19:11:11 -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=7TnpzFr6+cYL35FViD4+kmPs51y1+mYz+mgDKiTDL+o=; b=HJ4/FfTnl789faA7SZstrr23QxmXYC0hoQ7VPJ35yTPCPklnS+wmXQkFW/46SNz9MkYvIDka/Amk+NdCEGngQUtAihGEMI/WqQYR8txVXMcgqVz2xyXCemdjvCYjqMKybGDHAb2XcB3lwq+jK702TJBvGRiKmQXzS4Cm9nEbCjo= 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 DM2PR0501MB841.namprd05.prod.outlook.com (10.242.115.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.649.6; Mon, 3 Oct 2016 02:11:05 +0000 From: Adit Ranadive To: , , CC: Adit Ranadive , , , , Subject: [PATCH v6 10/16] IB/pvrdma: Add UAR support Date: Sun, 2 Oct 2016 19:10:30 -0700 Message-ID: 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: CY1PR1101CA0039.namprd11.prod.outlook.com (10.169.17.49) To DM2PR0501MB841.namprd05.prod.outlook.com (10.242.115.147) X-MS-Office365-Filtering-Correlation-Id: dd835fa7-9f8c-458f-01f1-08d3eb3288cd X-Microsoft-Exchange-Diagnostics: 1; DM2PR0501MB841; 2:kZG1Cn0cScWCIHsu+vTDfSWfc2ehb4v1o/62U1X6dnQsyNI9Z+ta+9HGoxwBediZPiCO4yKRSyV0FjLMCeOqmkH7AH8MagyxWZuRkzCo7B3/XdpuHPsusZaISyA6txsVBGU4uvnUozdjMiRn6Ct8AGVXgd0W5wlY+q7o5XAArX6M60YIFp1QehILsv4PeYecmRPD4zIopxQbyqk/wJyOoQ==; 3:clOZKWbqv7ASwyzA5jj756Jztvy6w+bKVu6UfwkoaVsbkVdfJFQnAJNqkbMyOEJb0vmbReSovjBuiST9KOVmCXdHP40Uj2P8bhDuiUY5hkJPwY9IUWvmxwsjCqTo2KqUT7yey6aTHdLE4KKv/U2Dyw==; 25:EPbTJbC+9YlPQ6ExsjsbZBuJenLXh5NKVi/It3FrhvUVRUR4EGhP2s2pjm5xR/okqvCwNgE0SoTQp/NxZC2t2S00rrmxRsUWM5IGaSoIz5H9/Bz1zUiU0wi5+m60YRMDXxl0uOEd7Ahd95vo73FuZ8qoU8jLyKV+ZI1MilB38mxriE348WwH1u84ID02zENxV3GbvgOav1hb0JUtZ9dYSdOg7PRsFGEKcIBcIC3ZgECsf/PdoIM66LQcV/XYARQ74zo8s12VSHYk8gkldJmOnDQH6mI6cLpUXjXU9jHrmVhE4eOmexuKOW91pRzpjPHJXRRen7O9n+YAS8/rhYizjetmugx0Ok+tV9lT1sZ3B5BR/IIa2PIfg8DgCfFko+FCAukiNxQiTZRzwr2bFARLq10QLt5NFxriEUZPGRF83mXhcBJvETQ+OAHjYlcrReyA X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0501MB841; X-LD-Processed: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; DM2PR0501MB841; 31:jr6t4kSI0dvhrN9Zs6ioEMoWpXlRtt8NOsdaF5UVCI1UPJs/1RaJRXnCLObZ2CZOZt7bfMmX/UFWCZ05gZv0gtXwGKXv+fwwoz2oy0ReGnSTfPGXG/8f8dSWS4rwVc0It7LqVOthDZxV+DihEToW30lG0u+2xLVsv5fIH6T83LZfExGq2pJ7KLfgUr3v+fHKscwjLyWW/KXG+v5uw0EAzsam1/grTwUHp4llmEEXCwS7Eab6uDdHMK8GFAQzLGOE; 20:sL+JvvKFEU52J11pwOLaK81rbaOHsH2dnvBI//nSHBpKK0aBcG8yhOqwIv4FwF9q8a+FEYFNllG9NiLCZgZLX4rUziycrk3cBD2xLJJxenrwpBg6gUvgoRV2rfvFzTr1279Eoq6OA33td2ExAVhvHMKzMxemhBIZFasosRXsihKmbARl1cyE/vo2DQruXJR5eceXL78uiOvKgLBw4AFcx6pNkF6GxUSFx3peX54Yzy9ZUzX+bgWhyj+Ozy9C+93nfKwWZWhUnIXtSIhM/vp8L5RmSnvy2AjEzQQ/dS7B+vDoUhvRgpL5+oyWLp5HORPPU4OiULGvkoWTjj/eKREDv/aI0mFIzVgbDk0ws6BTwERuEH/L/E/x0/F1vm9JJqUsazLee6Iuqomb9/5ubI8ElSXS92gOHY6eW6SJvkCSs8EXQ9vj6agME7/Luv5RgVuEwBvdfJbRBcz+pYR9K/QO7mfZygwC7t1WPFV2c00WbD+uHSPCxcl7bIUPNbetZuEl X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(250305191791016)(61668805478150)(22074186197030)(146099531331640); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001); SRVR:DM2PR0501MB841; BCL:0; PCL:0; RULEID:; SRVR:DM2PR0501MB841; X-Microsoft-Exchange-Diagnostics: 1; DM2PR0501MB841; 4:KoOrCO5Iiq6hwmRWinUcxKgjT8UclrUqSCYonn+vhvbQCMWMh64BzmZ/ouS+WGYYvC7OJ7fMeiX+Zb2IzvA+pYAtHuNSEcPpV3UAXLEitu3RZYxWB55MT8YUBoPdYtjuTmqLGdfvo8EGQR+WamFbuAdDPWalToPUyd8/flV53BvaAP1YoGAD1muNeOPdnCLJpJFtvP2qNmbOZgbMtMYkVRmUIyy++UUO9LYFIBUBoQoGgG3c6cly2Wbft0LGdSKdWGxDGMBYAvgcJf+wsnBE/yyCSg48oSqca3RDJUm+vRT5M8jZGcXqhab7bIEXFF+C9nB59POUxRIzOys6A+jW9sUKHUSH9EKA7iUQHXzut/+/C4vCXgsNJo/vNoSlxoEhR1Q/LeR1EBx/9bk3u89e0HfEIutbZgFrmlNpMe9SzDulLPNqfOIpYQQdz9ZZ4d+JKPLJAXui30IbzZfPltIeCH2hYWEFSP2ziRi6fi9WjJXWtg7BU/WAraVnRbkNHxXv6HYHF8VTBYPeb7HUMLD3gUqjwvB9gmTzf8R4C+oPm1k= X-Forefront-PRVS: 008421A8FF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(189002)(199003)(97736004)(189998001)(42186005)(19580405001)(47776003)(8676002)(5001770100001)(33646002)(2906002)(19580395003)(15975445007)(77096005)(6862003)(50986999)(76176999)(106356001)(2950100002)(101416001)(5003940100001)(4326007)(5660300001)(107886002)(105586002)(92566002)(7846002)(7736002)(586003)(118296001)(229853001)(68736007)(4001430100002)(305945005)(2201001)(48376002)(6636002)(50466002)(66066001)(86362001)(50226002)(6116002)(3846002)(81156014)(6666003)(36756003)(81166006)(7099028)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR0501MB841; H:promb-2s-dhcp95-136.eng.vmware.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (EX13-EDG-OU-001.vmware.com: aditr@vmware.com does not designate permitted sender hosts) Received-SPF: None (protection.outlook.com: vmware.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR0501MB841; 23:1SgaYjXX8VI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n532YD9eS+4JlVFgVgoM9WfX7Fwkv+cqDotxsE8pPpt86XPdVY=; 7:BsE7AjpuG1h6EfShUZgbqIKkMAD1xtc+kekcs1HwMFNadnDNF7NCvrXLPt1wjvITsfQnVMtXbvaH3G95JCqScSQCDiiklVOvppNiohC5FCuNyRZquZEU7wWlbqlLtUbzFw9fZrsbnpJ8kRFVsbnNt5SRHx7vr0LgQZGmmS8/ytI77Aemdz55o6oox2HI9OVmjLOVE44t6QMRnp2TCdfIFd/lbHelppw6fA1/+HYQCj+n1pvFbwlWYzM95gKDNGwrI4aQtgxK098NufhivTyZyzK+qumbosid7pdl0VXKhcgEBKAGfHRiwJg21kzauV04tS/uo30 W5PvcGX0DnMmAcg== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR0501MB841; 20:KKkF6mDTkdaN2zt8chQLfpIv9iY14FbWL+iqIhjBd4dOJS7BoWnJhfNQSrxDovaB7/DyzdjTQVtC+UHctSvGThTZ0JKky1xksufaxJqB1f60hrIMMQ4+F9w9pbbYx9v0W2wWgS/SXCZ8t0h0uxOUjmVoLge8/r+McL0/GVdHUeQ= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2016 02:11:05.6163 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR0501MB841 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. Reviewed-by: Yuval Shaia Reviewed-by: Jorgen Hansen Reviewed-by: George Zhang Reviewed-by: Aditya Sarwade Reviewed-by: Bryan Tan Signed-off-by: Adit Ranadive --- Changes v3->v4: - Removed an unnecessary comment. Changes v2->v3: - Used is_power_of_2 function. - Simplify pvrdma_uar_alloc function. --- drivers/infiniband/hw/pvrdma/pvrdma_doorbell.c | 127 +++++++++++++++++++++++++ 1 file changed, 127 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..bf51357 --- /dev/null +++ b/drivers/infiniband/hw/pvrdma/pvrdma_doorbell.c @@ -0,0 +1,127 @@ +/* + * 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; + + 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); +}