From patchwork Fri Jan 5 00:45:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Kuehling X-Patchwork-Id: 10145903 X-Patchwork-Delegate: bhelgaas@google.com 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 26D8F60244 for ; Fri, 5 Jan 2018 00:45:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5585D28390 for ; Fri, 5 Jan 2018 00:45:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 49503286BF; Fri, 5 Jan 2018 00:45:38 +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=-5.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_WEB 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 A3F1328390 for ; Fri, 5 Jan 2018 00:45:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751148AbeAEApg (ORCPT ); Thu, 4 Jan 2018 19:45:36 -0500 Received: from mail-sn1nam01on0041.outbound.protection.outlook.com ([104.47.32.41]:50784 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751108AbeAEApf (ORCPT ); Thu, 4 Jan 2018 19:45:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=knmx7oDAqBw4mi7w3GbS5oole3/+xXjzwho/N0kSMkE=; b=3I/1Ca54ypToXSq+5km+Gd24SoKmOK7BonDa+TSy7PbImLRGMtW+zouGrFJdTEzVv1qOlGmmLaYJtUBFK8dJSq9NNJj6rBf60DOuSmS5I9qBUwaRo5dZWirp4jBa04KfTnSeSENcodrN/SEd/8dMBmd+8jT5zKjqyH1cbobugsc= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Felix.Kuehling@amd.com; Received: from Harpoon.amd.com (165.204.55.251) by MWHPR1201MB0238.namprd12.prod.outlook.com (10.174.99.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.386.5; Fri, 5 Jan 2018 00:45:33 +0000 From: Felix Kuehling To: linux-pci@vger.kernel.org, helgaas@kernel.org Cc: oded.gabbay@gmail.com, Jay.Cornwall@amd.com, Felix Kuehling , Ram Amrani , Doug Ledford Subject: [PATCH 2/2] RDMA/qedr: Use pci_enable_atomic_ops_to_root Date: Thu, 4 Jan 2018 19:45:00 -0500 Message-Id: <1515113100-4718-2-git-send-email-Felix.Kuehling@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515113100-4718-1-git-send-email-Felix.Kuehling@amd.com> References: <1515113100-4718-1-git-send-email-Felix.Kuehling@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.55.251] X-ClientProxiedBy: MWHPR22CA0003.namprd22.prod.outlook.com (10.172.163.141) To MWHPR1201MB0238.namprd12.prod.outlook.com (10.174.99.135) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: be05de6a-7475-4db8-fecc-08d553d5a113 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(48565401081)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060); SRVR:MWHPR1201MB0238; X-Microsoft-Exchange-Diagnostics: 1; MWHPR1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Gl+fpGs7cTgT0FMA1XBMsXrtwTbpfAKhhU/lGay++EreIeyY7IP1P+vHeEjCv/ZzJreGjCTyZPrGeS5NWTUHnSwl8izd0/hg5hdeCyz6U9oWR9nROAir62ciTdKSQuP21W4H0bC8P44sSK+5cFiUMku9nC0/jMc0Zw6I0DslfNyZDsCQR/ex5Nyzk429ti90ZqhC34ekgWQ9cnJMLfQdQ5xSDWxxr3cKDWWl1keeac+Gy3sshWUDBJNQCTZjpXwvUULXak3cY7Gy5flGwKpwD5ywzjgVacTVD0groLRapraAD2aetUAGo0JmdhyQrZaj+V8ALD8/CHCxEHKVJuB8KCxEvNGyGzsww7ajPiDHDon4pqa58YQ; 4:+UZQ/dwCVrluPhPzczsI+YrlgmfMKfKm7pnoRbkhzgRJGF4WF4oZFUQN9yFMlGQl0No+BL7vR+X4XQsuv8mfMqcw23VZSgvr3Oj/VQMdHSGxaL1zZUuqfzg7M8LYSjKGirC12FntqqAVYECXOCa2dXkXn4XYnFPbXitoBW98uuJm5pJbb8fiPp5Qt5PLejyR+lL2p3rnnnG3Xr0/5/0NlZpG9Y+TwJO4F7vLumeoh593IM6vvEHxhy8qmq7GAMGDLm5VVYF1m+qqq8NyFpz5qtKLcmhmA4AigTCaRvBIIJHBLTOeQJJkjEQ5PqLP+Tqb X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(5005006)(8121501046)(10201501046)(3002001)(3231023)(944501075)(93006095)(93001095)(6055026)(6041268)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(20161123562045)(6072148)(201708071742011); SRVR:MWHPR1201MB0238; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:MWHPR1201MB0238; X-Forefront-PRVS: 05437568AA X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(396003)(366004)(39380400002)(346002)(376002)(189003)(199004)(39060400002)(105586002)(106356001)(72206003)(478600001)(2906002)(6116002)(4326008)(3846002)(53936002)(16586007)(316002)(51416003)(52116002)(386003)(81166006)(97736004)(8676002)(86362001)(81156014)(59450400001)(16526018)(54906003)(7696005)(76176011)(50226002)(36756003)(8936002)(5660300001)(68736007)(6666003)(2950100002)(53416004)(6486002)(48376002)(50466002)(305945005)(7736002)(66066001)(47776003)(25786009); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR1201MB0238; H:Harpoon.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR1201MB0238; 23:a1wlhAkGSiaBrZgQGj2BObFbPJhlCw9PWnlnEeL?= =?us-ascii?Q?DQpTYtufDyPBCF8+bQZcqakglgY5IjbOCCr1aFQJITr5P5oaVk2sb9qdSvMy?= =?us-ascii?Q?4jTGmOsQSnAO/F3x6wYfjjt3td4iBflT7Ixnp+9nvutTiNtwO/HZURNgZ0iL?= =?us-ascii?Q?+wzH1DnAvQFIioBHrK1QgoGl2wsYgOOw6Qwu9XMPFmFPhdqK2+rfjAIbePQ9?= =?us-ascii?Q?wEsd+lHA10L/ICGsR9TQhdaKbYC/+gtQl0Fjeo27oTAtNFwbqmNx9fhSRBhD?= =?us-ascii?Q?ime/Onu+ntYY5N2hEQNvL+BoLH9MwhSFycwtN8fpXCBYFEC3k+/URC0CTDoY?= =?us-ascii?Q?8GI1lQHQw/nq3bSnQP7E3sYIkbVZG/X1ktPiHojrXImfIi1iStlPIW82rPJB?= =?us-ascii?Q?iQmlONTmd57m2yP8wEV6nHpmrsARw2s4cwwTl/cBV9TumUW6swf3VTsI7dQt?= =?us-ascii?Q?lUx92j+gtBJvM1NVezReu0oDr3cKJQfuWl1ClIvi3aIPWCmCfEZit7ZtBm7Z?= =?us-ascii?Q?F6qoFOwtJzGCzxN20W1PWQkvRJJnCHXDyBwxxfaOP7JwoyFJSASTiBb0r4Av?= =?us-ascii?Q?AE94ss4MaztREUP5ZVUm6xenypT95lA9wAlOx0bVgJQWW0dBUJtOnypnQlyb?= =?us-ascii?Q?QBDHUt/k4PCe/vGwgfXW7PuexRwiGv6snwYJCqQkKRuF9zGuW3oDBmP/R3Hg?= =?us-ascii?Q?8v5a1gchXWfkQ8zWyVZiJyUAOrMwWkqq3H51zZROlQuDO4WeixI0Wdegzq/z?= =?us-ascii?Q?lZBgKQUy706LgBUaxdGVVqvYp9OP+vMSZLdx3pS6KbUHaBLWCVex9AY9pbJ3?= =?us-ascii?Q?XAVzpFNKLYYLsGjnME+VeZBPX4J1uMixlO6BdbcrRkDMJaKG8DKNqPOmQ+35?= =?us-ascii?Q?MZQDBq5QgWWFeUSVaOL+ptosDAwW0Nmob6HUuhKs80TARKNBd872lAWrOrhI?= =?us-ascii?Q?D7fTkPO4l64wIUNpUCoJwMFH6QUy7vMdFxvu08zP5cyrR551EW3naHAiAfQn?= =?us-ascii?Q?gI478fZwe8jx6m82xGqrxzEk9JkmStiS3M1RbSFnX51OiWrYsQ5BBKsUz3Mq?= =?us-ascii?Q?ywEeGtbahr5L4qx35aBbl03OU/v+MbUbprKe89vt75jQR4zB9CfR2RqbGTNR?= =?us-ascii?Q?guqx4OYbFddKEKcLWCl9uNkmMGZFOSyq2?= X-Microsoft-Exchange-Diagnostics: 1; MWHPR1201MB0238; 6:ANILXXvP+2inbfY45CBQkB2LlKzx3eEULKp2pR6zC7MsZPQtfrv0z/+ld6dKYBRcbiYp7aXz6g2PVXML45usDS/i5+3gd9xh9OsIRw7IDVJg2sCh5S8bFRgonJzlfRuAklvgYZEp58ggCh1SgC3IF8PF+EX5C+hCK7ckNk8PbetnvL38Fc8HemjNSwucdl0+FUz5KUChEVQ434vUx+IgOrAXPSrdEuBVY6IIO/VMYa02iug2jhqi59uA7ILrXHtJMzjDOTCe0YD415biYvS5fj8ZjaQ3xdN2DMoSFvRgG9ZsB9ST3OWGSjTLDaOUMSlYsMqDubrAgWrHpnxkVBKVuIl/YfcLv3HtGdUqyLAJbFE=; 5:cV37Xl/skhAOKEt2eiThujtxlvF95Apb60LIOhD8KevVqHhijfo6MCxPqxetJ18oACKJVB2c26JQayNauVok1tXQFUZAPb69aWbdWNu8m063MLqrOiE71if9yp6zz4zsY4afUz01+ethJOsuZ65BdheTlRVD8BdwYzA8ElWei4k=; 24:yil+WkP6hHhpuogvMGkXQVeTTCPiLkVfLbWnn+pkupYtxJLod2mkMz9HTWxhUxooSrLLKkLlhDCV9tyC7Qx5ATDAOJZuTBcHNMHft7ZM6Xw=; 7:kbmigNLHe1OwKaVMrkCoX5PZ1esfFCCbwpgQrc+JomFVzJ+wgJapfpla7AAhx3ZrYESUfWIbjKQ3zRPvsmLTWSMj0MaO2yKPgwfXmcWIT7W+YCb9feoelGUKOf/SC3HSVFxVoS6nQJMVaWIsqI+DhqzhSegmKZbZvrybaqHK4BFm90GYmM+WNC1v2Kpn/wJjaH0Unwdded/iUyugavDYtOJ/askvJJjrjFwfgcDeP+1wuFcj6GO2Ikm12NZs6CIA SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR1201MB0238; 20:ISQVUklQtzMmkMO0sFJsXSQv2ZZZXHFo0v6hNfEBjDpqKuNFKQzQBXrd5VXKli78e4kTJjuHYQUmp6QvJNWwi2m5DZm7Yw+kSzcmIOQGcgiGYTCsc3hVsTT3BnkMPuEz4tvcRWeV0YsSZhOkq5vlRHpY12Nps4AbfjZgNij450fFOYlRiJXUpUN61238jAa8Qjw505qzOpoMgT3erEAjg6a+g4JrXmVnJ4aQAPhzHjRoQQM6WUmBGWr5tdlW9wkZ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2018 00:45:33.2749 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: be05de6a-7475-4db8-fecc-08d553d5a113 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1201MB0238 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use common helper function pci_enable_atomic_ops_to_root to enable atomic capability. CC: Bjorn Helgaas CC: Ram Amrani CC: Doug Ledford Signed-off-by: Felix Kuehling Acked-by: Michal Kalderon --- drivers/infiniband/hw/qedr/main.c | 59 ++++++--------------------------------- 1 file changed, 8 insertions(+), 51 deletions(-) diff --git a/drivers/infiniband/hw/qedr/main.c b/drivers/infiniband/hw/qedr/main.c index 50812b3..b378647 100644 --- a/drivers/infiniband/hw/qedr/main.c +++ b/drivers/infiniband/hw/qedr/main.c @@ -430,59 +430,16 @@ static void qedr_remove_sysfiles(struct qedr_dev *dev) static void qedr_pci_set_atomic(struct qedr_dev *dev, struct pci_dev *pdev) { - struct pci_dev *bridge; - u32 ctl2, cap2; - u16 flags; - int rc; - - bridge = pdev->bus->self; - if (!bridge) - goto disable; - - /* Check atomic routing support all the way to root complex */ - while (bridge->bus->parent) { - rc = pcie_capability_read_word(bridge, PCI_EXP_FLAGS, &flags); - if (rc || ((flags & PCI_EXP_FLAGS_VERS) < 2)) - goto disable; - - rc = pcie_capability_read_dword(bridge, PCI_EXP_DEVCAP2, &cap2); - if (rc) - goto disable; + int rc = pci_enable_atomic_ops_to_root(pdev, + PCI_EXP_DEVCAP2_ATOMIC_COMP64); - rc = pcie_capability_read_dword(bridge, PCI_EXP_DEVCTL2, &ctl2); - if (rc) - goto disable; - - if (!(cap2 & PCI_EXP_DEVCAP2_ATOMIC_ROUTE) || - (ctl2 & PCI_EXP_DEVCTL2_ATOMIC_EGRESS_BLOCK)) - goto disable; - bridge = bridge->bus->parent->self; + if (rc) { + dev->atomic_cap = IB_ATOMIC_NONE; + DP_DEBUG(dev, QEDR_MSG_INIT, "Atomic capability disabled\n"); + } else { + dev->atomic_cap = IB_ATOMIC_GLOB; + DP_DEBUG(dev, QEDR_MSG_INIT, "Atomic capability enabled\n"); } - - rc = pcie_capability_read_word(bridge, PCI_EXP_FLAGS, &flags); - if (rc || ((flags & PCI_EXP_FLAGS_VERS) < 2)) - goto disable; - - rc = pcie_capability_read_dword(bridge, PCI_EXP_DEVCAP2, &cap2); - if (rc || !(cap2 & PCI_EXP_DEVCAP2_ATOMIC_COMP64)) - goto disable; - - /* Set atomic operations */ - pcie_capability_set_word(pdev, PCI_EXP_DEVCTL2, - PCI_EXP_DEVCTL2_ATOMIC_REQ); - dev->atomic_cap = IB_ATOMIC_GLOB; - - DP_DEBUG(dev, QEDR_MSG_INIT, "Atomic capability enabled\n"); - - return; - -disable: - pcie_capability_clear_word(pdev, PCI_EXP_DEVCTL2, - PCI_EXP_DEVCTL2_ATOMIC_REQ); - dev->atomic_cap = IB_ATOMIC_NONE; - - DP_DEBUG(dev, QEDR_MSG_INIT, "Atomic capability disabled\n"); - } static const struct qed_rdma_ops *qed_ops;