From 9b8cbbc6ed960bbf0777bf2f9222592b1cb07a39 Mon Sep 17 00:00:00 2001 From: marcel Date: Fri, 12 Jun 2015 12:27:10 +0000 Subject: We need to handle 64-bit BARs ourselves to avoid that the PCI infrastructure instantiates a non-existent resource. This has BARs suddenly show up with pciconf(8) under VMware as well. Now that we read the BAR ourselves, ask for the correct resource type. --- sys/dev/proto/proto_bus_pci.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'sys/dev/proto/proto_bus_pci.c') 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; -- cgit v1.1