From: Rajat Jain <rajatxjain@gmail.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: "linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Rajat Jain <rajatjain@juniper.net>,
Guenter Roeck <groeck@juniper.net>,
Linus Torvalds <torvalds@linux-foundation.org>,
Richard Yang <weiyang@linux.vnet.ibm.com>,
Matthew Wilcox <matthew.r.wilcox@intel.com>,
Yinghai Lu <yinghai@kernel.org>
Subject: [PATCH v2] pci/probe: Enable CRS for root port if it is supported
Date: Tue, 02 Sep 2014 16:26:00 -0700 [thread overview]
Message-ID: <54065208.3080309@gmail.com> (raw)
In-Reply-To: <CAErSpo5_WMUmnTHpPZt+j04VZoiW1pthQoGV90A5BDQpQgjwOQ@mail.gmail.com>
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 <rajatxjain@gmail.com>
Signed-off-by: Rajat Jain <rajatjain@juniper.net>
Signed-off-by: Guenter Roeck <groeck@juniper.net>
---
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 */
--
1.7.9.5
next prev parent reply other threads:[~2014-09-02 23:51 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-28 21:55 [PATCH] pci/probe: Enable CRS for Intel Haswell root ports Rajat Jain
2014-08-29 4:04 ` Wei Yang
2014-08-29 17:11 ` Rajat Jain
2014-08-31 13:31 ` Wei Yang
2014-09-02 4:14 ` Bjorn Helgaas
2014-09-02 18:39 ` Rajat Jain
2014-09-02 19:30 ` Linus Torvalds
2014-09-06 21:21 ` Bjorn Helgaas
2014-09-06 23:28 ` Linus Torvalds
2014-09-02 23:26 ` Rajat Jain [this message]
2014-09-09 5:38 ` [PATCH v2] pci/probe: Enable CRS for root port if it is supported Bjorn Helgaas
2014-09-09 18:35 ` Rajat Jain
2014-09-16 5:10 ` Rajat Jain
2014-09-16 15:40 ` Bjorn Helgaas
2014-09-22 18:54 ` Bjorn Helgaas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54065208.3080309@gmail.com \
--to=rajatxjain@gmail.com \
--cc=bhelgaas@google.com \
--cc=groeck@juniper.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=matthew.r.wilcox@intel.com \
--cc=rajatjain@juniper.net \
--cc=torvalds@linux-foundation.org \
--cc=weiyang@linux.vnet.ibm.com \
--cc=yinghai@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).