summaryrefslogtreecommitdiffstats
path: root/sys/dev/proto/proto_bus_pci.c
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2015-06-20 19:34:50 +0000
committerdim <dim@FreeBSD.org>2015-06-20 19:34:50 +0000
commite109f99dcb6c95c84bbec22229de29a25491f7c2 (patch)
treed142d742b698973a366ae768a3f4033924e314c8 /sys/dev/proto/proto_bus_pci.c
parent238df27d058d0d8912acf0a186d3f43289a0a2b6 (diff)
parentcb167b45a82327b0d6d88e85e3d6e2e326291ee4 (diff)
downloadFreeBSD-src-e109f99dcb6c95c84bbec22229de29a25491f7c2.zip
FreeBSD-src-e109f99dcb6c95c84bbec22229de29a25491f7c2.tar.gz
Merge ^/head r284188 through r284643.
Diffstat (limited to 'sys/dev/proto/proto_bus_pci.c')
-rw-r--r--sys/dev/proto/proto_bus_pci.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/sys/dev/proto/proto_bus_pci.c b/sys/dev/proto/proto_bus_pci.c
index 46ec41e..53ebb5e 100644
--- a/sys/dev/proto/proto_bus_pci.c
+++ b/sys/dev/proto/proto_bus_pci.c
@@ -82,6 +82,7 @@ proto_pci_attach(device_t dev)
{
struct proto_softc *sc;
struct resource *res;
+ uint32_t val;
int bar, rid, type;
sc = device_get_softc(dev);
@@ -91,15 +92,17 @@ proto_pci_attach(device_t dev)
for (bar = 0; bar < PCIR_MAX_BAR_0; bar++) {
rid = PCIR_BAR(bar);
- type = SYS_RES_MEMORY;
+ val = pci_read_config(dev, rid, 4);
+ type = (PCI_BAR_IO(val)) ? SYS_RES_IOPORT : SYS_RES_MEMORY;
res = bus_alloc_resource_any(dev, type, &rid, RF_ACTIVE);
- if (res == NULL) {
- type = SYS_RES_IOPORT;
- res = bus_alloc_resource_any(dev, type, &rid,
- RF_ACTIVE);
- }
- if (res != NULL)
- proto_add_resource(sc, type, rid, res);
+ if (res == NULL)
+ continue;
+ proto_add_resource(sc, type, rid, res);
+ if (type == SYS_RES_IOPORT)
+ continue;
+ /* Skip over adjacent BAR for 64-bit memory BARs. */
+ if ((val & PCIM_BAR_MEM_TYPE) == PCIM_BAR_MEM_64)
+ bar++;
}
rid = 0;
OpenPOWER on IntegriCloud