From patchwork Thu Jun 11 20:08:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Duc Dang X-Patchwork-Id: 6591601 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 4DC4A9F399 for ; Thu, 11 Jun 2015 20:08:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 54BAB2064E for ; Thu, 11 Jun 2015 20:08:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2E6FA20646 for ; Thu, 11 Jun 2015 20:08:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932516AbbFKUIt (ORCPT ); Thu, 11 Jun 2015 16:08:49 -0400 Received: from exprod5og126.obsmtp.com ([64.18.0.251]:49002 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753537AbbFKUIs (ORCPT ); Thu, 11 Jun 2015 16:08:48 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]) (using TLSv1) by exprod5ob126.postini.com ([64.18.4.12]) with SMTP ID DSNKVXnqz8/GQtM5peQmUKvsPshiKkeFDTZX@postini.com; Thu, 11 Jun 2015 13:08:48 PDT Received: by padev16 with SMTP id ev16so8974982pad.0 for ; Thu, 11 Jun 2015 13:08:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Ey3iAgsYQoVwVlOx44CrULac/Lu+Smssyg8S9NpEjSc=; b=FEDWBjfPG62w/IKd/sa52AlhSu08mi3qvJVBAaU0fBT0sfFJ3Iios02GNrUQgnchxA bp9JoI1UcjI7Hqbn5Ut8DuOGgACfiGc5qf1t7hWpcFUridME+uKXyGQ0A4LhZJvXhjTl appJDOdJ4QHcIlqABMMjewqxUUp9ffQv/mKZh8BPSU2v3RfkM6Md4CnCQWQ2xAvL3apM CRzowM3iWRtLmXabAtjq51qm6w8hnLmli5AQUwJQGzUu3qu6dGhQQOZvOMMunU7c5CIn UzrcnC5VLncr7a5E6yWMbMStPeO05mVfvo2oWZ7FT81Cmig6NDnXsbXwD+NWJKGEYTXW muiQ== X-Gm-Message-State: ALoCoQnSGB4wQtoO99N0SNghrVzOhbKLVz9OIGnQVVgEwoOAG6CSinm/2wAF6Afhez147w8LGKfoPMjHppf5Rye/zl//3luqNhWOtQn0hGravYonRmHC9rojysxW9errn6g3haIzy4C//MnfLU5Z30gRuIALLAuhGA== X-Received: by 10.66.122.37 with SMTP id lp5mr17348863pab.17.1434053327036; Thu, 11 Jun 2015 13:08:47 -0700 (PDT) X-Received: by 10.66.122.37 with SMTP id lp5mr17348852pab.17.1434053326933; Thu, 11 Jun 2015 13:08:46 -0700 (PDT) Received: from dhdang-Precision-WorkStation-T3400.amcc.com (67-207-112-226.static.wiline.com. [67.207.112.226]) by mx.google.com with ESMTPSA id zt9sm1522439pac.9.2015.06.11.13.08.45 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Jun 2015 13:08:46 -0700 (PDT) From: Duc Dang To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Ian Campbell , Marcin Juszkiewicz , Tanmay Inamdar , patches@apm.com, Duc Dang Subject: [PATCH 1/1] PCI: X-Gene: Disable Configuration Request Retry Status for X-Gene v1 PCIe Date: Thu, 11 Jun 2015 13:08:14 -0700 Message-Id: <1434053294-10962-1-git-send-email-dhdang@apm.com> X-Mailer: git-send-email 1.9.1 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 X-Gene v1 PCIe controller has a bug in Configuration Request Retry Status (CRS) logic: When CPU tries to read Vendor ID and Device ID of not-existed remote device, the controller returns 0xFFFF0001 instead of 0xFFFFFFFF; this will add significant delay in boot time as pci_bus_read_dev_vendor_id will wait for 60 seconds before giving up. So for X-Gene v1 PCIe controllers, disable CRS capability advertisement by clearing CRS Software Visibility bit before returning the Root Capability value to the callers. This is done by implementing X-Gene PCIe specific xgene_pcie_config_read32 for CFG read accesses to replace the generic default pci_generic_config_read32 function. Signed-off-by: Duc Dang Tested-by: Marcin Juszkiewicz Tested-by: Ian Campbell --- drivers/pci/host/pci-xgene.c | 48 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/drivers/pci/host/pci-xgene.c b/drivers/pci/host/pci-xgene.c index ee082c0..741a253 100644 --- a/drivers/pci/host/pci-xgene.c +++ b/drivers/pci/host/pci-xgene.c @@ -59,6 +59,12 @@ #define SZ_1T (SZ_1G*1024ULL) #define PIPE_PHY_RATE_RD(src) ((0xc000 & (u32)(src)) >> 0xe) +#define ROOT_CAP_AND_CTRL 0x5C + +/* PCIe IP version */ +#define XGENE_PCIE_IP_VER_UNKN 0 +#define XGENE_PCIE_IP_VER_1 1 + struct xgene_pcie_port { struct device_node *node; struct device *dev; @@ -67,6 +73,7 @@ struct xgene_pcie_port { void __iomem *cfg_base; unsigned long cfg_addr; bool link_up; + u32 version; }; static inline u32 pcie_bar_low_val(u32 addr, u32 flags) @@ -140,9 +147,44 @@ static void __iomem *xgene_pcie_map_bus(struct pci_bus *bus, unsigned int devfn, return xgene_pcie_get_cfg_base(bus) + offset; } +int xgene_pcie_config_read32(struct pci_bus *bus, unsigned int devfn, + int where, int size, u32 *val) +{ + void __iomem *addr; + struct xgene_pcie_port *port = bus->sysdata; + + addr = bus->ops->map_bus(bus, devfn, where & ~0x3); + if (!addr) { + *val = ~0; + return PCIBIOS_DEVICE_NOT_FOUND; + } + + *val = readl(addr); + /* + * X-Gene v1 PCIe controller has a bug in Configuration Request + * Retry Status (CRS) logic: + * When CPU tries to read Vendor ID and Device ID of not-existed + * remote device, the controller returns 0xFFFF0001 instead of + * 0xFFFFFFFF; this will add significant delay in boot time as + * pci_bus_read_dev_vendor_id will wait for 60 seconds before + * giving up. + * So for X-Gene v1 PCIe controllers, disable CRS capability + * advertisement by clearing CRS Software Visibility bit before + * returning the Root Capability value to the callers. + */ + if (pci_is_root_bus(bus) && (port->version == XGENE_PCIE_IP_VER_1) && + ((where & ~0x3) == ROOT_CAP_AND_CTRL)) + *val &= ~(PCI_EXP_RTCAP_CRSVIS << 16); + + if (size <= 2) + *val = (*val >> (8 * (where & 3))) & ((1 << (size * 8)) - 1); + + return PCIBIOS_SUCCESSFUL; +} + static struct pci_ops xgene_pcie_ops = { .map_bus = xgene_pcie_map_bus, - .read = pci_generic_config_read32, + .read = xgene_pcie_config_read32, .write = pci_generic_config_write32, }; @@ -483,6 +525,10 @@ static int xgene_pcie_probe_bridge(struct platform_device *pdev) port->node = of_node_get(pdev->dev.of_node); port->dev = &pdev->dev; + port->version = XGENE_PCIE_IP_VER_UNKN; + if (of_device_is_compatible(port->node, "apm,xgene-pcie")) + port->version = XGENE_PCIE_IP_VER_1; + ret = xgene_pcie_map_reg(port, pdev); if (ret) return ret;