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: 5300381 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D9FE4C11AC for ; Thu, 13 Nov 2014 19:37:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 072ED20219 for ; Thu, 13 Nov 2014 19:37:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 896062021A for ; Thu, 13 Nov 2014 19:37:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933571AbaKMThp (ORCPT ); Thu, 13 Nov 2014 14:37:45 -0500 Received: from metis.ext.pengutronix.de ([92.198.50.35]:44373 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934003AbaKMTho (ORCPT ); Thu, 13 Nov 2014 14:37:44 -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-pci@vger.kernel.org Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-7.9 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 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);