From patchwork Sat Jun 13 00:35:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Duc Dang X-Patchwork-Id: 6601711 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0AB63C0433 for ; Sat, 13 Jun 2015 00:40:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1445A20689 for ; Sat, 13 Jun 2015 00:39:59 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1F60A20392 for ; Sat, 13 Jun 2015 00:39:58 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z3ZRB-0005vr-Bp; Sat, 13 Jun 2015 00:36:41 +0000 Received: from exprod5og108.obsmtp.com ([64.18.0.186] helo=mail-pd0-f176.google.com) by bombadil.infradead.org with smtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z3ZR6-0005sD-I8 for linux-arm-kernel@lists.infradead.org; Sat, 13 Jun 2015 00:36:37 +0000 Received: from mail-pd0-f176.google.com ([209.85.192.176]) (using TLSv1) by exprod5ob108.postini.com ([64.18.4.12]) with SMTP ID DSNKVXt6/jAxRK9ciUx7uV7i7i1visgRg+AL@postini.com; Fri, 12 Jun 2015 17:36:36 PDT Received: by pdjm12 with SMTP id m12so33038648pdj.3 for ; Fri, 12 Jun 2015 17:36:14 -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:in-reply-to :references; bh=RiW0YOg8B2ZLU0Ragjgo3H26l75llMyHg+xWpH4eHbA=; b=heUP/IWKQtpQ8Xh8Zvn3SHsH/xbV/E0QBVxKNh3KhmgzDpv0OmJN9MvyefKCdtaH/j fXuuAX5NO/CAyo8l3i+iSNdhKmlZ6u9OgXn1t9s6WfRPfeXsq33QJhnXmdlaAPArsUIw M1P5hI/jmoBeaLPB3JePu2GqKBvBpZVPZN5LJXo6mou3JNAHmF4N+sXbv93y88yI2BqO ur9bDgkK2F3gcSMTtJupG4+4fTHh+Li9gHZa2dPVrMhqkNDFkB1iihIIXkXBTfQEyFll 0qnHU3TIzjSwj+ujV1jw2RAWBQjipbgFLPgGAakmD9LKVh86eGP4ZeCqsr+AMj/qlZml OjFg== X-Gm-Message-State: ALoCoQm/yS0nfqDYAym+ZmyxW8EYzDPq84HbwQ2oAfaPtOlFfVWhU8f6EA90CbKNprqS9suoT2IS2vkbfyqL2FapraWRTaGtBNafhfz9kULMFnPnTRNyKRMbU2knqVXeOHSbSfpAwuDiKd+Ri00IuqVGPXANevjLTrQ2GvUuX8yYOLnqa435d9I= X-Received: by 10.70.89.102 with SMTP id bn6mr27588133pdb.48.1434155774056; Fri, 12 Jun 2015 17:36:14 -0700 (PDT) X-Received: by 10.70.89.102 with SMTP id bn6mr27588096pdb.48.1434155773856; Fri, 12 Jun 2015 17:36:13 -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 iv7sm4774957pbc.20.2015.06.12.17.36.12 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 Jun 2015 17:36:13 -0700 (PDT) From: Duc Dang To: Bjorn Helgaas Subject: [PATCH v2 1/1] PCI: X-Gene: Disable Configuration Request Retry Status for X-Gene v1 PCIe Date: Fri, 12 Jun 2015 17:35:57 -0700 Message-Id: <017c1ec8e3f43f86a947eaddb30c9389e0b1053b.1434154377.git.dhdang@apm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150612_173636_650889_C1E8D857 X-CRM114-Status: GOOD ( 15.26 ) X-Spam-Score: -2.3 (--) Cc: Ian Campbell , linux-pci@vger.kernel.org, Duc Dang , patches@apm.com, linux-kernel@vger.kernel.org, Marcin Juszkiewicz , linux-arm-kernel@lists.infradead.org, Tanmay Inamdar X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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. v2 changes: Use pci_generic_config_read32 to implement xgene_pcie_config_read32 Signed-off-by: Duc Dang Tested-by: Ian Campbell Tested-by: Marcin Juszkiewicz --- drivers/pci/host/pci-xgene.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/drivers/pci/host/pci-xgene.c b/drivers/pci/host/pci-xgene.c index e6c8864..7e3cf28 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,39 @@ 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) +{ + struct xgene_pcie_port *port = bus->sysdata; + + if (pci_generic_config_read32(bus, devfn, where & ~0x3, 4, val) != + PCIBIOS_SUCCESSFUL) + return PCIBIOS_DEVICE_NOT_FOUND; + /* + * 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, }; @@ -500,6 +537,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;