From patchwork Thu Apr 13 20:30:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jayachandran C X-Patchwork-Id: 9679995 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 B5F1C60381 for ; Thu, 13 Apr 2017 20:41:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A758C286BE for ; Thu, 13 Apr 2017 20:41:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A84A286C0; Thu, 13 Apr 2017 20:41:59 +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=-1.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3E8FD286BE for ; Thu, 13 Apr 2017 20:41:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YF+7aTpPvuGLfCicaOXZTgE+1oZuDOgmtjtv+l5j7Xo=; b=aRVm4l+fgCr9Pe lx+rgSDbUdBl8Xk2TG4mU8Tx7lDDJoltr/bPYW3368WL2RLUzkPoqRZvPknHxUg8l33q/Wf9qAEK6 tUPhUmBvNFZ4rJL71QRlJ5PrEzY08EFGOHni/0Pv3LXFcsij8VsBYN7NYPorSbO6gCzPnJTr11lOM 1A+kHTWbA7WI7VWBUnfdDYmtjsr24esCoHZWEcqhJaG6Dejg1BJtxWjzMINYHIkJQ4ZIUOevwgO5J mB0Dysud/l2AU2yx4lxHBrgEgXPC531+O/poVZdW/A5yIrhJUAe7ReJuEGpsu0yzlRSvD5K0szy4u aWxGz92v6eer+GMUD2WQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cylYy-00067m-EF; Thu, 13 Apr 2017 20:41:56 +0000 Received: from mail-cys01nam02on0087.outbound.protection.outlook.com ([104.47.37.87] helo=NAM02-CY1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cylOo-0001K3-Od for linux-arm-kernel@lists.infradead.org; Thu, 13 Apr 2017 20:31:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=2yZZWzUNGrmYbmY+mDEC5MIoyV/RCdqAz+JYuQVYnQg=; b=gDQTI7vpEwCQd5jffkfwO6ilV6HqsXeJQqJFTHDss5GpigLQlnrKAC9w9+VtH42oa+0nR6ushSzaPxItfBGcjejYBQRAFS0SvOS8Oy64ekwDgBAc1JNQJ0A+zvb51BKqJoYV6uXjey4lxCUZhoyewl4HsCD1FUG/mQwR9+tnc7g= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=caviumnetworks.com; Received: from vulcan.caveonetworks.com (50.233.148.156) by MWHPR07MB3008.namprd07.prod.outlook.com (10.172.96.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1019.17; Thu, 13 Apr 2017 20:31:02 +0000 From: Jayachandran C To: Bjorn Helgaas , linux-pci@vger.kernel.org Subject: [PATCH v5 1/2] PCI: Add device flag PCI_DEV_FLAGS_BRIDGE_XLATE_ROOT Date: Thu, 13 Apr 2017 20:30:44 +0000 Message-Id: <1492115445-4069-2-git-send-email-jnair@caviumnetworks.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1492115445-4069-1-git-send-email-jnair@caviumnetworks.com> References: <1492115445-4069-1-git-send-email-jnair@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [50.233.148.156] X-ClientProxiedBy: CY4PR06CA0034.namprd06.prod.outlook.com (10.173.44.20) To MWHPR07MB3008.namprd07.prod.outlook.com (10.172.96.14) X-MS-Office365-Filtering-Correlation-Id: 2f877f21-c84b-46a9-a435-08d482ac013a X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:MWHPR07MB3008; X-Microsoft-Exchange-Diagnostics: 1; MWHPR07MB3008; 3:4JUXYVzLZMdwacG200uFff2eTp/N6GKQZJEuKnZUoWK8QvK4/zUk3e/zE5Q8rY6pkyooRVpt/7hgyGqDcNew93zMqo8nhOyv8E19n/ybdVoojpaCmL5t2jkKb3HI+ZQF3B7kbb2516tTxpi8ajVz4z+YdL8yL7aqNG5o5eo/A0gDa+Am+C7y2s4+5l+kVeWc53cQNI7itBcTcAZCCufWIgdq9ZWLaoogxmvjtOdCDj74TZ6+UAWHuVi20PcxTkWaQza0N8TrD5/N+GgXuQX6Hr+Cu5cdBomBlM5od9x6MeZR2PMPkytAcj7x3xcT8bDxDvrPvNDEFy8WQVhxvTOOUg==; 25:8yqUxko1uh2bbNIX0d5tCaUw3Twcm5VS9mE2XIErLgWWBcuC1mxz3Zk+5bU9maKh8nzbigDbqim57AYLblYmNXpa4561F/f9O3HKATk3TxsVBDMm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UcYul1GAFdcGJIu/gK1OiBNMItqW/bNQe3KcGHO9yV6D3kEg8e6ox3Wq344KsIMXkuxAQQjWx3i0dOOt0wdQ0ee9jlCpLrmk5FiAdDqvaa5eofams9i16LwDNmWm7EhEpcre5br3I3c6dSIprcaDE9bXCiB144oK0VuI9wQJWjIVdOaCwisDjlhlWVs= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(6041248)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(20161123560025)(20161123555025)(20161123564025)(6072148); SRVR:MWHPR07MB3008; BCL:0; PCL:0; RULEID:; SRVR:MWHPR07MB3008; X-Microsoft-Exchange-Diagnostics: 1; MWHPR07MB3008; 4:QQX/N5QXPDU8wh1FAo+KAiJy91zritPVGyEZvoLJD4AVCvquEPO6RmS9cWZ66kvDeOCkhFrvTUErlQiQ0pBg7bIAySI/mDXQcpvX8pMdEbpZiS+iPuS0qtagVPCZdonqcXHDV5MEEEMkwR/Dd/wDeQEnoM6NsKMe3h5dNXbSzg51KDFGyDS0nqjCboM2hbY0AlZBcHPq6oQHyzUQCt5IjxVJFRwyBGmuvgOubGJ2OlMwiYCD+3nmOjaig3p6aylSIBKQ8uI95qtnivl7Lvtnwiqrpgi9sx5ogoYf8OA2z+PC2gKux3xWuPrmoqOKMQuTyW5gisLU3VdAURsXNB8FF547RQyu1ys6TROkLkXMTQW83mI9YF6k1GHvv+dpz+1Ql5s0fOuxLsQuvjwXZjFXkHeNrLKzC3GPETZprBfpJD7shYleqhscwkXAur6cXFF2S3m9D3fgRNL7Z/ExQmRNzurgaIb1zXhnRtKxJW7YAZThsLEEVUjJAoT9vIURBMDLL7U1ud7FI3DdySt08ZyqOmkv5Q1oZ9GACg2A27lnKtgUvPYVEQ/6yMbQLxpkRNpYq4CrX9hUndV/e+ZX9Ef0Wq9jtuokcEnH3J7tz+HA7oVF8a36SuXB+CaGn9IdhbT7nRJ05BQrLA/65d5Bxj93WXADPnXkgPkJSYQP8Ipd95EfWEGO39bkOYxz2vM/752dp3htYh3tA3R3PDIbeo7etA6WMK/w3o6G+ePSBQ/Tlvvw9Dy9BiNWziHZbGqO7Pql X-Forefront-PRVS: 02760F0D1C X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39400400002)(39840400002)(39410400002)(39850400002)(39450400003)(4326008)(50226002)(36756003)(2950100002)(38730400002)(110136004)(25786009)(53416004)(42882006)(47776003)(42186005)(6512007)(50986999)(76176999)(54906002)(5003940100001)(6506006)(5660300001)(6486002)(6666003)(53936002)(7736002)(33646002)(305945005)(48376002)(81166006)(8676002)(5890100001)(575784001)(189998001)(66066001)(2906002)(3846002)(6116002); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR07MB3008; H:vulcan.caveonetworks.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR07MB3008; 23:XG00Y9Rkn2LoMs8eOvJugExCAjhJRjpSZnbKkBWt2?= =?us-ascii?Q?JFYN2Nmu9DOKqPALyOmHeEv+vhPhqjw+PRxGvE93y6ShC6NTzC4eQnVFuqN7?= =?us-ascii?Q?1Uj8WsaQXPIB6Pfung6Ro8J04OMAoGj+G4Xcwg8g0dJoxRdOxhIbEh4n6Fwq?= =?us-ascii?Q?FkvSQF6RUEVwZf7uYEpTTpVASyBO/XucMG/7xn4x+e0qDaql7QqZna74rCbD?= =?us-ascii?Q?hoZvCFAtrk3kxL4umgHPejXbZMLgexRgWNGXchfgUoXFp+vA/QIrTaEAdhhr?= =?us-ascii?Q?dEKzJTVwv24/S84GIpU5y5uSjJbgQIZ3TlCZuZtn2UMrPqYbZTPpbVfUhkiS?= =?us-ascii?Q?7ENfAn4NnFQayZxPNZkDzHqL4bUBpXa/bu4gSitwzjMwwfYvKfClctewTY9h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wfVeAuA3Y2yqZ2GGmOdPMGqOHOo7jGYGsU47kzBrSKJ2o3DlSO0BpFZuGaPWxzCQ6F+10xtBkNqxvDU5jsxzZNZMjFg0x8B1m++wfnEX9+e1pslD8BKxJCCSJ6T8kNjZyKetBbQ2Dd8CSFr5ZCxGN9XT6yKOlT/MHnOzvDLliMmRA6p1IvsfgGY6a3NPBJs0q0/BWZQJpTgIg/aQ1uD9l6t32a4QSMeh3UNLGftDe9KedY2exmLQudYWApDKGYCz2Wg8ziqRJAKWXg==; 5:4GZ+q+fuN/CVKRA53oJd+SYiib7gs6V9AlYC/tqdIU7HZKLn1bqQx7ZJMZqRVuzKA4korsLnKKFnV+09gMZBXwj7Gu0yZeXmXQYGUXf850Yymbx0mIaCQ6yXs0oyJhzyQEHM2Iy74nT7Azz8MyBCRg==; 24:Kkbmo6DuCAvpX0dK/c0JZZaR3x29SQmvGno1XMY8R8o5mqhDFRTfo7cC0cZ5LTPFdX68n/yxz2QoywhFfMPX50VQTDTKSLHpIT7RJCZb/g0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR07MB3008; 7:IeAJo319fNJKXr/Tzpn4Y8mdG3mQukq0VmVs8mWK53QDzUlOnZpVgNqvy+txs73GdFT6ItsF5mgttrS601+O6K+t+xXF7fXOWD1jqAEtSDsZ97mSJ1TJf5s4yYPFRwdRGDL2Gm/wJ9btFdwxIEeyJdn87dwnf84Yqoztq+JXR/4nDaAGT45MlWfy6GgBlGcuv1xG01NInC6rEi7H3ppJFRd0xW4SVXObKMBOkVeM0/8LUwXilhuhfySMTvZ4t9N3IMckGHuOE+7lzHfdxAwu+xGJCxPMZ1aIfw7cH+wxpwrj+vXM30LQAqfsNMqLtAtUXYFDfsCnfv9iSUD6JSEugQ== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2017 20:31:02.7464 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR07MB3008 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170413_133126_959320_656229C1 X-CRM114-Status: UNSURE ( 9.20 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jon Masters , Joerg Roedel , iommu@lists.linux-foundation.org, Jayachandran C , Robin Murphy , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add a new quirk flag PCI_DEV_FLAGS_BRIDGE_XLATE_ROOT to limit the DMA alias search to go no further than the bridge where the IOMMU unit is attached. The flag will be used to indicate a bridge device which forwards the address translation requests to the IOMMU, i.e where the interrupt and DMA requests leave the PCIe hierarchy and go into the system blocks. Usually this happens at the PCI RC, so this flag is not needed. But on systems where there are bridges that introduce aliases above the "real" root bridge, this flag is needed to ensure that the function pci_for_each_dma_alias() works correctly. The function pci_for_each_dma_alias() is updated to stop when it see a bridge with this flag set. Signed-off-by: Jayachandran C Reviewed-by: Robin Murphy Acked-by: David Daney --- drivers/pci/search.c | 4 ++++ include/linux/pci.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/drivers/pci/search.c b/drivers/pci/search.c index 33e0f03..4c6044a 100644 --- a/drivers/pci/search.c +++ b/drivers/pci/search.c @@ -60,6 +60,10 @@ int pci_for_each_dma_alias(struct pci_dev *pdev, tmp = bus->self; + /* stop at bridge where translation unit is associated */ + if (tmp->dev_flags & PCI_DEV_FLAGS_BRIDGE_XLATE_ROOT) + return ret; + /* * PCIe-to-PCI/X bridges alias transactions from downstream * devices using the subordinate bus number (PCI Express to diff --git a/include/linux/pci.h b/include/linux/pci.h index eb3da1a..3f596ac 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -178,6 +178,8 @@ enum pci_dev_flags { PCI_DEV_FLAGS_NO_PM_RESET = (__force pci_dev_flags_t) (1 << 7), /* Get VPD from function 0 VPD */ PCI_DEV_FLAGS_VPD_REF_F0 = (__force pci_dev_flags_t) (1 << 8), + /* a non-root bridge where translation occurs, stop alias search here */ + PCI_DEV_FLAGS_BRIDGE_XLATE_ROOT = (__force pci_dev_flags_t) (1 << 9), }; enum pci_irq_reroute_variant {