diff options
author | 2015-02-11 21:27:08 +0000 | |
---|---|---|
committer | 2015-02-11 21:27:08 +0000 | |
commit | c5bacb7b3af5650aed29f61b2c33f2c579600bd9 (patch) | |
tree | 9bac741e73dbe1b53d280a0866a270008668655e | |
parent | Make syslogd test more reliable. Use Time::HiRes to sleep .01 (diff) | |
download | wireguard-openbsd-c5bacb7b3af5650aed29f61b2c33f2c579600bd9.tar.xz wireguard-openbsd-c5bacb7b3af5650aed29f61b2c33f2c579600bd9.zip |
Disable the L0S and L1 ASPM link states to workaround errata with the
82573 / 82574 controllers.
82573..
8 82573 Disappears in PCI Configuration Space When L0s and L1 PCIe Link
States Are Enabled
41 Delay of Received Ethernet Packet During ASPM L1
82574..
24. PCIe: Common Mode Voltage Shift During L1 Exit
25. Dropped Rx Packets
From FreeBSD
ok jsg@
-rw-r--r-- | sys/dev/pci/if_em.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/sys/dev/pci/if_em.c b/sys/dev/pci/if_em.c index 49939a03bbf..09037cd043b 100644 --- a/sys/dev/pci/if_em.c +++ b/sys/dev/pci/if_em.c @@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. ***************************************************************************/ -/* $OpenBSD: if_em.c,v 1.293 2015/02/09 03:09:57 dlg Exp $ */ +/* $OpenBSD: if_em.c,v 1.294 2015/02/11 21:27:08 brad Exp $ */ /* $FreeBSD: if_em.c,v 1.46 2004/09/29 18:28:28 mlaier Exp $ */ #include <dev/pci/if_em.h> @@ -222,6 +222,7 @@ void em_disable_intr(struct em_softc *); void em_free_transmit_structures(struct em_softc *); void em_free_receive_structures(struct em_softc *); void em_update_stats_counters(struct em_softc *); +void em_disable_aspm(struct em_softc *); void em_txeof(struct em_softc *); int em_allocate_receive_structures(struct em_softc *); int em_allocate_transmit_structures(struct em_softc *); @@ -1835,6 +1836,8 @@ em_hardware_init(struct em_softc *sc) sc->hw.fc_send_xon = TRUE; sc->hw.fc = E1000_FC_FULL; + em_disable_aspm(sc); + if ((ret_val = em_init_hw(&sc->hw)) != 0) { if (ret_val == E1000_DEFER_INIT) { INIT_DEBUGOUT("\nHardware Initialization Deferred "); @@ -3186,6 +3189,35 @@ em_fill_descriptors(u_int64_t address, u_int32_t length, return desc_array->elements; } +/* + * Disable the L0S and L1 LINK states. + */ +void +em_disable_aspm(struct em_softc *sc) +{ + int offset; + pcireg_t val; + + switch (sc->hw.mac_type) { + case em_82573: + case em_82574: + break; + default: + return; + } + + if (!pci_get_capability(sc->osdep.em_pa.pa_pc, sc->osdep.em_pa.pa_tag, + PCI_CAP_PCIEXPRESS, &offset, NULL)) + return; + + /* Disable PCIe Active State Power Management (ASPM). */ + val = pci_conf_read(sc->osdep.em_pa.pa_pc, sc->osdep.em_pa.pa_tag, + offset + PCI_PCIE_LCSR); + val &= ~(PCI_PCIE_LCSR_ASPM_L0S | PCI_PCIE_LCSR_ASPM_L1); + pci_conf_write(sc->osdep.em_pa.pa_pc, sc->osdep.em_pa.pa_tag, + offset + PCI_PCIE_LCSR, val); +} + #ifndef SMALL_KERNEL /********************************************************************** * |