From patchwork Fri Aug 1 12:09:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 4662511 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 EE225C0338 for ; Fri, 1 Aug 2014 12:09:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BEAE120218 for ; Fri, 1 Aug 2014 12:09:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6169520204 for ; Fri, 1 Aug 2014 12:09:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754698AbaHAMJN (ORCPT ); Fri, 1 Aug 2014 08:09:13 -0400 Received: from mail-pa0-f42.google.com ([209.85.220.42]:32992 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754620AbaHAMJL (ORCPT ); Fri, 1 Aug 2014 08:09:11 -0400 Received: by mail-pa0-f42.google.com with SMTP id lf10so5663821pab.15 for ; Fri, 01 Aug 2014 05:09:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=Q7fSfZqkUmxi3gB06vfHjxCFzFxHtqLSwMZ8jBWSKas=; b=APBSbdO51h4wWEH5mVTPLacNvh3EjNJHGNrIgMFs1p+BYOXi20XekRgU+NKLuCpq7W Hj+0Hze7AIeI1cDtEm0Ork6msALRKg2bts7CFg2HPhbR/MhFrtcOPCXfSCZrW1MkK8yP oO8vMm+0Ye3fxU82gTcYGVj6pJtmA7DyYaWEr1z9rPFtgEgRJDuMmvbdQdDKjFB36gV+ 2BBGpE4BLtBogVXm/gF2/9V9Oq2AtAe7T3bIEDTNZ0Tyd1eEnzqFmTT0E56U4LId3/GP zVDHyM3LYzc4HcuukUi73sC0KgUpkwBM8p4cheCNEbNgt8AmLe21mxBrdmBNF4wp2IdH mCOw== X-Received: by 10.70.40.131 with SMTP id x3mr5366485pdk.22.1406894950364; Fri, 01 Aug 2014 05:09:10 -0700 (PDT) Received: from [192.168.95.129] ([66.129.239.10]) by mx.google.com with ESMTPSA id p9sm1981905pdl.21.2014.08.01.05.09.09 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 01 Aug 2014 05:09:09 -0700 (PDT) Message-ID: <53DB8375.7090503@gmail.com> Date: Fri, 01 Aug 2014 05:09:25 -0700 From: Rajat Jain User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130803 Thunderbird/17.0.8 MIME-Version: 1.0 To: Bjorn Helgaas , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , Rajat Jain Subject: PCI/x86 CPU Hangs: Need to enable CRS Software Visibility (Configuration Request Retry Status) 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.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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 Hello, I'm using an Intel Haswell CPU (/proc/cpu at the end of mail). I have a PCIe endpoint (a PLX 8713 NT bridge) that will take a long time to initialize itself after a reset. In accordance with the PCIe spec, the device responds with the CRS when the kernel tries to enumerate the endpoint, trying to indicate that the device is not yet ready. [Ref: PCIe spec V3.0, pg119, pg127 for "Configuration Request Retry Status") This results in a CPU hang because the CPU root port goes into an endless cycle of retries, as the CRS Software Visibility is not enabled: [Ref commit ad7edfe "[PCI] Do not enable CRS Software Visibility by default" by Linus] The problem goes away if I enable the CRS software visibility and I see that the kernel moves on after timing out on that device: pci 0000:30:00.0 id reading try 50 times with interval 20 ms to get ffff0001 Thus in a nutshell I want to enable the CRS Software visibility flag for my platform. From the commit log of the above commit, I'm trying to understand what would be the best way to do it. When the commit log says we should use white list for systems for which CRS should be enabled, and introduce something like pcibios_enable_crs(), do we mean something like this (suggestive patch only)? --- arch/x86/pci/common.c | 18 ++++++++++++++++++ drivers/pci/pci.c | 5 +++++ drivers/pci/probe.c | 2 ++ include/linux/pci.h | 1 + 4 files changed, 26 insertions(+) diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c index 81ec592..81b961d 100644 --- a/arch/x86/pci/common.c +++ b/arch/x86/pci/common.c @@ -634,6 +634,24 @@ char * __init pcibios_setup(char *str) return str; } +static const struct pci_device_id crs_whitelist[] = { + { PCI_VDEVICE(INTEL, 0x2f00), }, + { PCI_VDEVICE(INTEL, 0x2f02), }, + { }, +}; + +void pcibios_enable_crs(struct pci_dev *dev) +{ + if (!pci_is_pcie(dev) || + pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT) + return; + + /* Enable CRS Software visibility only for whitelisted systems */ + if (pci_match_id(crs_whitelist, dev)) + pcie_capability_set_word(dev, PCI_EXP_RTCTL, + PCI_EXP_RTCTL_CRSSVE); +} + unsigned int pcibios_assign_all_busses(void) { return (pci_probe & PCI_ASSIGN_ALL_BUSSES) ? 1 : 0; diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 3387c5e..982e8b1 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -2685,6 +2685,11 @@ char * __weak __init pcibios_setup(char *str) return str; } +void __weak pcibios_enable_crs(struct pci_dev *dev) +{ + /* Do nothing by default, and let platforms decide for themselves */ +} + /** * pcibios_set_master - enable PCI bus-mastering for device dev * @dev: the PCI device to enable diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 1aa058e..a4c50f7 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -801,6 +801,8 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass) pci_write_config_word(dev, PCI_BRIDGE_CONTROL, bctl & ~PCI_BRIDGE_CTL_MASTER_ABORT); + pcibios_enable_crs(dev); + if ((secondary || subordinate) && !pcibios_assign_all_busses() && !is_cardbus && !broken) { unsigned int cmax; diff --git a/include/linux/pci.h b/include/linux/pci.h index dbe746f..8ac0b31 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -723,6 +723,7 @@ void pcibios_fixup_bus(struct pci_bus *); int __must_check pcibios_enable_device(struct pci_dev *, int mask); /* Architecture-specific versions may override this (weak) */ char *pcibios_setup(char *str); +void pcibios_enable_crs(struct pci_dev *dev); /* Used only when drivers/pci/setup.c is used */ resource_size_t pcibios_align_resource(void *, const struct resource *,