From patchwork Thu Jun 18 17:55:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 6639681 Return-Path: X-Original-To: patchwork-linux-arm@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 7084D9F326 for ; Thu, 18 Jun 2015 17:58:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6BFD920856 for ; Thu, 18 Jun 2015 17:58:57 +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 626A1207D1 for ; Thu, 18 Jun 2015 17:58:56 +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 1Z5e3P-0003sH-UD; Thu, 18 Jun 2015 17:56:43 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z5e37-0003lr-81 for linux-arm-kernel@bombadil.infradead.org; Thu, 18 Jun 2015 17:56:25 +0000 Received: from mail-ie0-x22c.google.com ([2607:f8b0:4001:c03::22c]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z5e34-0002iy-8i for linux-arm-kernel@lists.infradead.org; Thu, 18 Jun 2015 17:56:23 +0000 Received: by iebmu5 with SMTP id mu5so59815371ieb.1 for ; Thu, 18 Jun 2015 10:55:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=64pMklb1njK+hfupfnF6wucb1i6LX43FYT2ywAvNaqQ=; b=O3Mn6sIOetde959y5mDmFOHYBq9q0Rlkp9sogM99zwSTXyo5gfVZr1f55imb1hktwk 6QO+lPE5+StCYOOe0n902u4f9EzxZ5pIBWUBa+kbMOx6GXJof9fC4a1PMHmSLCWasax8 z03WJOMRxR8k4ySbZdFLAibPr5RfrkyWEfReQGd4XNmbgbup9GTuHmkJ+RguzHkYq2oV vbiDvG/oFayBkNqjkBboXuFAZ0SgdQjqmD+HEQULK1zGMNsXAbJqbuU1qYqbuvb76BNO WAsE/2jB/xwLnMY4ZhhXep4Amn/N8NlbkQG+jxFV6pQzpXEsFFwbgpkDircESlAEQBRF xycA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=64pMklb1njK+hfupfnF6wucb1i6LX43FYT2ywAvNaqQ=; b=JvvZ5pdlzr4Yj8Jnw1DwM7yOI4X0itd2VzOjW4isBfO7aSDC9IqyZbQgKrkJd5REmn F1YXL0CqDbe8KJfAAcO3kOc/0/x2/fdWfSZN3hhV+5FDi4tfFnlvFBdfjP9ebWbVxJSx aVlhBlbOePtxjtlOeDokpcJ81lDgiPf6xw231OU38lDaQvypYMzhxBwp3opLVGeRS/jK XN2mUlZZPiudqjWCB3zAUN2P3bB5n3dcUJxTnw4YWQAWUnhtImVdAgETT3kM/Z3OVN/Y PovZg1VZsAxBq58PfAAy0gZc0y7zNtIhtKv++NRAOGmnzeJ/bfwU0jwwENpV+higF4IK u2AA== X-Gm-Message-State: ALoCoQmHa/CIrhYkSETPiXXhBcWF/63Uy/qQKt4/+9H05aO1gh9H4vbz723lz90iZ/ofc6jroayu X-Received: by 10.43.84.73 with SMTP id aj9mr7264439icc.69.1434650157018; Thu, 18 Jun 2015 10:55:57 -0700 (PDT) Received: from google.com ([69.71.1.1]) by mx.google.com with ESMTPSA id k74sm5385569iok.30.2015.06.18.10.55.55 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 18 Jun 2015 10:55:56 -0700 (PDT) Date: Thu, 18 Jun 2015 12:55:53 -0500 From: Bjorn Helgaas To: Duc Dang Subject: Re: [PATCH v2 1/1] PCI: X-Gene: Disable Configuration Request Retry Status for X-Gene v1 PCIe Message-ID: <20150618175553.GF7710@google.com> References: <017c1ec8e3f43f86a947eaddb30c9389e0b1053b.1434154377.git.dhdang@apm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <017c1ec8e3f43f86a947eaddb30c9389e0b1053b.1434154377.git.dhdang@apm.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150618_185622_564932_9F6A896C X-CRM114-Status: GOOD ( 29.29 ) X-Spam-Score: -3.0 (---) Cc: Ian Campbell , linux-pci@vger.kernel.org, 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: , 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.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID, 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 On Fri, Jun 12, 2015 at 05:35:57PM -0700, Duc Dang wrote: > 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 I'd like to merge this (as amended below) for v4.2. But I'm looking for an ack from Tanmay, and I'm still waiting for the second patch to remove the link_up test. Bjorn commit 49ac8c566d7a37f9f295e1fd4fbdd96517f22d55 Author: Duc Dang Date: Fri Jun 12 17:35:57 2015 -0700 PCI: xgene: Disable Configuration Request Retry Status for v1 silicon When a CPU reads the Vendor and Device ID of a non-existent device, the controller should fabricate return data of 0xFFFFFFFF. Configuration Request Retry Status (CRS) is not applicable in this case because the device doesn't exist at all. The X-Gene v1 PCIe controller has a bug in the CRS logic such that when CRS is enabled, it fabricates return data of 0xFFFF0001 for this case, which means "the device exists but is not ready." That causes the PCI core to retry the read until it times out after 60 seconds. Disable CRS capability advertisement by clearing the CRS Software Visibility bit in the Root Capabilities Register. [bhelgaas: changelog and comment] Tested-by: Ian Campbell Tested-by: Marcin Juszkiewicz Signed-off-by: Duc Dang Signed-off-by: Bjorn Helgaas diff --git a/drivers/pci/host/pci-xgene.c b/drivers/pci/host/pci-xgene.c index 3e5a636..70af714 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,37 @@ static void __iomem *xgene_pcie_map_bus(struct pci_bus *bus, unsigned int devfn, return xgene_pcie_get_cfg_base(bus) + offset; } +static 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; + + /* + * The v1 controller has a bug in its Configuration Request + * Retry Status (CRS) logic: when CRS is enabled and we read the + * Vendor and Device ID of a non-existent device, the controller + * fabricates return data of 0xFFFF0001 ("device exists but is not + * ready") instead of 0xFFFFFFFF ("device does not exist"). This + * causes the PCI core to retry the read until it times out. + * Avoid this by not claiming to support CRS. + */ + 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 +535,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;