fanghuilin / rpms / kernel

Forked from rpms/kernel 3 years ago
Clone
a8a466
centosplus patch (bug#12277)
a8a466
a8a466
Ref: https://patchwork.kernel.org/patch/9397341/
a8a466
a8a466
--- a/drivers/pci/probe.c	2016-10-19 07:16:25.000000000 -0700
a8a466
+++ b/drivers/pci/probe.c	2016-11-28 09:30:30.621332097 -0800
a8a466
@@ -1426,6 +1426,16 @@ static void program_hpp_type1(struct pci
a8a466
 		dev_warn(&dev->dev, "PCI-X settings not supported\n");
a8a466
 }
a8a466
 
a8a466
+static bool pcie_get_upstream_rcb(struct pci_dev *dev)
a8a466
+{
a8a466
+	struct pci_dev *bridge = pci_upstream_bridge(dev);
a8a466
+	u16 lnkctl;
a8a466
+
a8a466
+	pcie_capability_read_word(bridge, PCI_EXP_LNKCTL, &lnkctl);
a8a466
+
a8a466
+	return lnkctl & PCI_EXP_LNKCTL_RCB;
a8a466
+}
a8a466
+
a8a466
 static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *hpp)
a8a466
 {
a8a466
 	int pos;
a8a466
@@ -1455,9 +1465,21 @@ static void program_hpp_type2(struct pci
a8a466
 			~hpp->pci_exp_devctl_and, hpp->pci_exp_devctl_or);
a8a466
 
a8a466
 	/* Initialize Link Control Register */
a8a466
-	if (pcie_cap_has_lnkctl(dev))
a8a466
+	if (pcie_cap_has_lnkctl(dev)) {
a8a466
+		bool us_rcb;
a8a466
+		u16 clear;
a8a466
+		u16 set;
a8a466
+
a8a466
+		us_rcb = pcie_get_upstream_rcb(dev);
a8a466
+
a8a466
+		clear = ~hpp->pci_exp_lnkctl_and;
a8a466
+		set = hpp->pci_exp_lnkctl_or;
a8a466
+		if (!us_rcb)
a8a466
+			set &= ~PCI_EXP_LNKCTL_RCB;
a8a466
+
a8a466
 		pcie_capability_clear_and_set_word(dev, PCI_EXP_LNKCTL,
a8a466
-			~hpp->pci_exp_lnkctl_and, hpp->pci_exp_lnkctl_or);
a8a466
+						  clear, set);
a8a466
+	}
a8a466
 
a8a466
 	/* Find Advanced Error Reporting Enhanced Capability */
a8a466
 	pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);