From patchwork Thu Nov 13 19:37:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 410568 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 9F0661400AB for ; Fri, 14 Nov 2014 06:37:45 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933986AbaKMTho (ORCPT ); Thu, 13 Nov 2014 14:37:44 -0500 Received: from metis.ext.pengutronix.de ([92.198.50.35]:44370 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933938AbaKMThn (ORCPT ); Thu, 13 Nov 2014 14:37:43 -0500 Received: from dude.hi.4.pengutronix.de ([10.1.0.7] helo=dude.pengutronix.de.) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1Xp0D5-0002p1-Fv; Thu, 13 Nov 2014 20:37:39 +0100 From: Lucas Stach To: Thierry Reding , Bjorn Helgaas Cc: Stephen Warren , Alexandre Courbot , linux-tegra@vger.kernel.org, linux-pci@vger.kernel.org Subject: [PATCH 1/2] PCI: tegra: apply relaxed ordering fixup only on Tegra Date: Thu, 13 Nov 2014 20:37:36 +0100 Message-Id: <1415907457-3147-2-git-send-email-l.stach@pengutronix.de> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1415907457-3147-1-git-send-email-l.stach@pengutronix.de> References: <1415907457-3147-1-git-send-email-l.stach@pengutronix.de> X-SA-Exim-Connect-IP: 10.1.0.7 X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-tegra@vger.kernel.org Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org The fixup to enable relaxed ordering on all PCI devices was executed unconditionally if the Tegra PCI host driver was built into the kernel. This doesn't play nice with a multiplatform kernel executed on other platforms which may not need this fixup. Make sure to only apply the fixup if the root port is a Tegra. Signed-off-by: Lucas Stach Tested-by: Alexandre Courbot --- drivers/pci/host/pci-tegra.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c index 3d43874319be..d5a14f22ebb8 100644 --- a/drivers/pci/host/pci-tegra.c +++ b/drivers/pci/host/pci-tegra.c @@ -647,10 +647,34 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_NVIDIA, 0x0bf1, tegra_pcie_fixup_class); DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_NVIDIA, 0x0e1c, tegra_pcie_fixup_class); DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_NVIDIA, 0x0e1d, tegra_pcie_fixup_class); +static int tegra_pcie_root_is_tegra(struct pci_dev *dev) +{ + struct pci_bus *bus = dev->bus; + struct pci_dev *root_bridge; + + /* walk up the PCIe hierarchy to the first level below the root bus */ + while (bus->parent && bus->parent->self) + bus = bus->parent; + + /* + * If there is no bridge on the bus the passed device is the root + * bridge itself. + */ + root_bridge = bus->self ? bus->self : dev; + if (root_bridge->vendor == PCI_VENDOR_ID_NVIDIA && + (root_bridge->device == 0x0bf0 || root_bridge->device == 0x0bf1 || + root_bridge->device == 0x0e1c || root_bridge->device == 0x0e1d || + root_bridge->device == 0x0e12 || root_bridge->device == 0x0e13)) + return 1; + + return 0; +} /* Tegra PCIE requires relaxed ordering */ static void tegra_pcie_relax_enable(struct pci_dev *dev) { - pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_RELAX_EN); + if (tegra_pcie_root_is_tegra(dev)) + pcie_capability_set_word(dev, PCI_EXP_DEVCTL, + PCI_EXP_DEVCTL_RELAX_EN); } DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, tegra_pcie_relax_enable);