From patchwork Sun May 8 09:33:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jayachandran C." X-Patchwork-Id: 9038721 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0306C9F1C1 for ; Sun, 8 May 2016 09:35:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 18E192012D for ; Sun, 8 May 2016 09:35:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 425B220120 for ; Sun, 8 May 2016 09:35:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750714AbcEHJfg (ORCPT ); Sun, 8 May 2016 05:35:36 -0400 Received: from mail-gw2-out.broadcom.com ([216.31.210.63]:22597 "EHLO mail-gw2-out.broadcom.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750703AbcEHJff (ORCPT ); Sun, 8 May 2016 05:35:35 -0400 X-IronPort-AV: E=Sophos;i="5.24,594,1455004800"; d="scan'208";a="94948665" Received: from mail-irv-18.broadcom.com ([10.15.198.37]) by mail-gw2-out.broadcom.com with ESMTP; 08 May 2016 02:49:57 -0700 Received: from mail-irva-12.broadcom.com (mail-irva-12.broadcom.com [10.11.16.101]) by mail-irv-18.broadcom.com (Postfix) with ESMTP id C508282023; Sun, 8 May 2016 02:35:32 -0700 (PDT) Received: from lc-blr-136.ban.broadcom.com (unknown [10.131.60.136]) by mail-irva-12.broadcom.com (Postfix) with ESMTP id 5CBB3127621; Sun, 8 May 2016 02:35:31 -0700 (PDT) From: Jayachandran C To: Alex Williamson , iommu@lists.linux-foundation.org Cc: Jayachandran C , Bjorn Helgaas , linux-pci@vger.kernel.org Subject: [PATCH v2 1/2] PCI: Add PCI device flag PCI_DEV_FLAGS_DMA_ALIAS_ROOT Date: Sun, 8 May 2016 15:03:20 +0530 Message-Id: <1462700001-30086-1-git-send-email-jchandra@broadcom.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a new flag PCI_DEV_FLAGS_DMA_ALIAS_ROOT to limit the DMA alias search to go no further than the bridge where the IOMMU is attached. This has been added to support Broadcom's Vulcan which has the SMMUv3 and GIC ITS associated with an intermediate bridge in the PCI topology. Traversing to buses above would hit internal glue bridges which will change the RID. Update the function pci_for_each_dma_alias() to stop when it see a bridge with this flag set. Signed-off-by: Jayachandran C --- Here is v2 of the patch, the previous discussion is at http://lists.linuxfoundation.org/pipermail/iommu/2016-February/015668.html v1->v2 changes: - dropped the BAR quirk (not needed) - moved from using the 'skip' flag for some bridges to using similar approach to stop the traversal at the bridge with PCI_DEV_FLAGS_DMA_ALIAS_ROOT Comments and suggestions are welcome JC. 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 a20ce7d..3ea9c27 100644 --- a/drivers/pci/search.c +++ b/drivers/pci/search.c @@ -56,6 +56,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_DMA_ALIAS_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 932ec74..b6f832b 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -176,6 +176,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_DMA_ALIAS_ROOT = (__force pci_dev_flags_t) (1 << 9), }; enum pci_irq_reroute_variant {