e1000e: disable correctable errors for quad ports while going to D3
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / net / e1000e / netdev.c
index cc0502bbb9ff5351304932ed710569d3e068da7c..ebbb9f061c876d0046be2658c8169cda351a2c00 100644 (file)
@@ -4462,7 +4462,27 @@ static int e1000_suspend(struct pci_dev *pdev, pm_message_t state)
 
        pci_disable_device(pdev);
 
-       pci_set_power_state(pdev, pci_choose_state(pdev, state));
+       /*
+        * The pci-e switch on some quad port adapters will report a
+        * correctable error when the MAC transitions from D0 to D3.  To
+        * prevent this we need to mask off the correctable errors on the
+        * downstream port of the pci-e switch.
+        */
+       if (adapter->flags & FLAG_IS_QUAD_PORT) {
+               struct pci_dev *us_dev = pdev->bus->self;
+               int pos = pci_find_capability(us_dev, PCI_CAP_ID_EXP);
+               u16 devctl;
+
+               pci_read_config_word(us_dev, pos + PCI_EXP_DEVCTL, &devctl);
+               pci_write_config_word(us_dev, pos + PCI_EXP_DEVCTL,
+                                     (devctl & ~PCI_EXP_DEVCTL_CERE));
+
+               pci_set_power_state(pdev, pci_choose_state(pdev, state));
+
+               pci_write_config_word(us_dev, pos + PCI_EXP_DEVCTL, devctl);
+       } else {
+               pci_set_power_state(pdev, pci_choose_state(pdev, state));
+       }
 
        return 0;
 }