From patchwork Tue Sep 2 23:26:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 4829371 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CF3309F2ED for ; Tue, 2 Sep 2014 23:51:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E3D3A201EF for ; Tue, 2 Sep 2014 23:51:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EF87B201ED for ; Tue, 2 Sep 2014 23:51:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753031AbaIBXvx (ORCPT ); Tue, 2 Sep 2014 19:51:53 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:55935 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752980AbaIBXvw (ORCPT ); Tue, 2 Sep 2014 19:51:52 -0400 Received: by mail-pa0-f44.google.com with SMTP id rd3so16051477pab.31 for ; Tue, 02 Sep 2014 16:51:52 -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:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=w+O4DiD5/YBzjW6MssH9JyNRJiifSm9kx29YqgEk81g=; b=EAKEKJHpAjqwOaifhNfM5Oam8o1KwMxB89R8QkABk6B6CiyBoTe7S/ar/haUWu9k3l RA4AmvUeuBGjVBEksf1Jlm40S131cEtfB9vMAEE8OCza9C/4T+2fK7iYRsdl8jpPiLQn K2hsfBzWtfhuQMLiHmuCVEwhXQ7gaN9lN09EOk+j02bJSOWdyHW8e8Nq/ZTVmLVMGZN8 VflMnQDwkE8fMkWO7LLuKXMYmN8Uc79nDruedBvtr6Euw4S8sIUlrO/C4VOCGvJ6NFQ+ oM1o1VqvH5Q2aO0u02fQvoUZtX4vODjD69WkDOjOPLDwhAjoJZIMcq3GzNursNFyEyfE 8SSw== X-Received: by 10.70.53.65 with SMTP id z1mr52571148pdo.74.1409701911975; Tue, 02 Sep 2014 16:51:51 -0700 (PDT) Received: from [192.168.95.129] ([66.129.239.14]) by mx.google.com with ESMTPSA id gw1sm5069429pbd.63.2014.09.02.16.51.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 02 Sep 2014 16:51:51 -0700 (PDT) Message-ID: <54065208.3080309@gmail.com> Date: Tue, 02 Sep 2014 16:26:00 -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 CC: "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Rajat Jain , Guenter Roeck , Linus Torvalds , Richard Yang , Matthew Wilcox , Yinghai Lu Subject: [PATCH v2] pci/probe: Enable CRS for root port if it is supported References: <53FFA54D.9000907@gmail.com> In-Reply-To: Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-8.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 As per the PCIe spec, an endpoint may return the configuration cycles with CRS if it is not yet fully ready to be accessed. If the CRS visibility is not enabled at the root port, the spec leaves the retry behaviour open to implementation in such a case. The Intel root ports have chosen to retry endlessly in this situation. Thus, the root controller may "hang" (repeatedly retrying the configuration requests until it gets a status other than CRS) if a device returns CRS for a long time. This can cause a broken endpoint to bring down the whole PCI hierarchy. This was recently known to cause problems on Intel systems and was discussed here: http://marc.info/?t=140926298500002&r=1&w=2 Ref1: https://www.pcisig.com/specifications/pciexpress/ECN_CRS_Software_Visibility_No27.pdf Ref2: PCIe spec V3.0, pg119, pg127 for "Configuration Request Retry Status" Thus enable the CRS visibility for the root ports that support it. This patch reverts the following commit, but enables CRS visibility only when the root port supports it: ad7edfe04908 ("[PCI] Do not enable CRS Software Visibility by default") (Linus' response: http://marc.info/?l=linux-pci&m=140968622520192&w=2) Signed-off-by: Rajat Jain Signed-off-by: Rajat Jain Signed-off-by: Guenter Roeck --- v2: Remove the white list, that was enabling the CRS for certain known Intel systems. Rather now enable it for all systems that support this capability. v1: Enable CRS for only some given Intel systems (maintain a whitelist) drivers/pci/probe.c | 13 +++++++++++++ include/uapi/linux/pci_regs.h | 1 + 2 files changed, 14 insertions(+) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index e3cf8a2..3c4c35c 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -740,6 +740,17 @@ struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, } EXPORT_SYMBOL(pci_add_new_bus); +static void pci_enable_crs(struct pci_dev *pdev) +{ + u16 root_cap = 0; + + /* Enable CRS Software visibility if supported */ + pcie_capability_read_word(pdev, PCI_EXP_RTCAP, &root_cap); + if (root_cap & PCI_EXP_RTCAP_CRSVIS) + pcie_capability_set_word(pdev, PCI_EXP_RTCTL, + PCI_EXP_RTCTL_CRSSVE); +} + /* * If it's a bridge, configure it and scan the bus behind it. * For CardBus bridges, we don't scan behind as the devices will @@ -787,6 +798,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); + pci_enable_crs(dev); + if ((secondary || subordinate) && !pcibios_assign_all_busses() && !is_cardbus && !broken) { unsigned int cmax; diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h index 30db069..a75106d 100644 --- a/include/uapi/linux/pci_regs.h +++ b/include/uapi/linux/pci_regs.h @@ -552,6 +552,7 @@ #define PCI_EXP_RTCTL_PMEIE 0x0008 /* PME Interrupt Enable */ #define PCI_EXP_RTCTL_CRSSVE 0x0010 /* CRS Software Visibility Enable */ #define PCI_EXP_RTCAP 30 /* Root Capabilities */ +#define PCI_EXP_RTCAP_CRSVIS 0x0001 /* CRS software visibility capability */ #define PCI_EXP_RTSTA 32 /* Root Status */ #define PCI_EXP_RTSTA_PME 0x00010000 /* PME status */ #define PCI_EXP_RTSTA_PENDING 0x00020000 /* PME pending */