summaryrefslogtreecommitdiffstats
path: root/sys/dev
diff options
context:
space:
mode:
authorkmacy <kmacy@FreeBSD.org>2007-03-23 20:18:07 +0000
committerkmacy <kmacy@FreeBSD.org>2007-03-23 20:18:07 +0000
commit4bfdd681e77c880870040f0cbd4d6b43933894df (patch)
tree5a2f4dbedc6ff2e56097fc79570e80236643dbc5 /sys/dev
parentacede79cbae3ad5ac9c813b98547f46f97d26877 (diff)
downloadFreeBSD-src-4bfdd681e77c880870040f0cbd4d6b43933894df.zip
FreeBSD-src-4bfdd681e77c880870040f0cbd4d6b43933894df.tar.gz
Check PCI-e link width to avoid foot shooting with 4x links
MFC after: 3 days
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/cxgb/cxgb_main.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/sys/dev/cxgb/cxgb_main.c b/sys/dev/cxgb/cxgb_main.c
index bb4d0cf..17ea53c 100644
--- a/sys/dev/cxgb/cxgb_main.c
+++ b/sys/dev/cxgb/cxgb_main.c
@@ -303,13 +303,29 @@ cxgb_controller_attach(device_t dev)
device_t child;
const struct adapter_info *ai;
struct adapter *sc;
- int i, msi_needed, msi_count = 0, error = 0;
+ int i, reg, msi_needed, msi_count = 0, error = 0;
uint32_t vers;
int port_qsets = 1;
sc = device_get_softc(dev);
sc->dev = dev;
+ /* find the PCIe link width and set max read request to 4KB*/
+ if (pci_find_extcap(dev, PCIY_EXPRESS, &reg) == 0) {
+ uint16_t lnk, pectl;
+ lnk = pci_read_config(dev, reg + 0x12, 2);
+ sc->link_width = (lnk >> 4) & 0x3f;
+
+ pectl = pci_read_config(dev, reg + 0x8, 2);
+ pectl = (pectl & ~0x7000) | (5 << 12);
+ pci_write_config(dev, reg + 0x8, pectl, 2);
+ }
+ if (sc->link_width != 0 && sc->link_width <= 4) {
+ device_printf(sc->dev,
+ "PCIe x%ld Link, expect reduced performance\n",
+ sc->link_width);
+ }
+
pci_enable_busmaster(dev);
/*
OpenPOWER on IntegriCloud