--- if_re.c.orig +++ if_re.c @@ -155,6 +155,11 @@ /* "device miibus" required. See GENERIC if you get errors here. */ #include "miibus_if.h" +/* + * Default to using PIO access for this driver. + */ +#define RE_USEIOSPACE + /* Tunables. */ static int msi_disable = 1; TUNABLE_INT("hw.re.msi_disable", &msi_disable); @@ -275,6 +280,14 @@ static int re_diag (struct rl_softc *); #endif +#ifdef RE_USEIOSPACE +#define RL_RES SYS_RES_IOPORT +#define RL_RID RL_PCI_LOIO +#else +#define RL_RES SYS_RES_MEMORY +#define RL_RID RL_PCI_LOMEM +#endif + static device_method_t re_methods[] = { /* Device interface */ DEVMETHOD(device_probe, re_probe), @@ -1104,9 +1117,9 @@ struct ifnet *ifp; struct rl_hwrev *hw_rev; int hwrev; - u_int16_t devid, re_did = 0; int error = 0, rid, i; int msic, reg; + uint16_t re_did = 0; uint8_t cfg; sc = device_get_softc(dev); @@ -1121,26 +1134,14 @@ */ pci_enable_busmaster(dev); - devid = pci_get_device(dev); - /* Prefer memory space register mapping over IO space. */ - sc->rl_res_id = PCIR_BAR(1); - sc->rl_res_type = SYS_RES_MEMORY; - /* RTL8168/8101E seems to use different BARs. */ - if (devid == RT_DEVICEID_8168 || devid == RT_DEVICEID_8101E) - sc->rl_res_id = PCIR_BAR(2); - sc->rl_res = bus_alloc_resource_any(dev, sc->rl_res_type, - &sc->rl_res_id, RF_ACTIVE); + rid = RL_RID; + sc->rl_res = bus_alloc_resource_any(dev, RL_RES, &rid, + RF_ACTIVE); if (sc->rl_res == NULL) { - sc->rl_res_id = PCIR_BAR(0); - sc->rl_res_type = SYS_RES_IOPORT; - sc->rl_res = bus_alloc_resource_any(dev, sc->rl_res_type, - &sc->rl_res_id, RF_ACTIVE); - if (sc->rl_res == NULL) { - device_printf(dev, "couldn't map ports/memory\n"); - error = ENXIO; - goto fail; - } + device_printf(dev, "couldn't map ports/memory\n"); + error = ENXIO; + goto fail; } sc->rl_btag = rman_get_bustag(sc->rl_res); @@ -1556,8 +1557,7 @@ pci_release_msi(dev); } if (sc->rl_res) - bus_release_resource(dev, sc->rl_res_type, sc->rl_res_id, - sc->rl_res); + bus_release_resource(dev, RL_RES, RL_RID, sc->rl_res); /* Unload and free the RX DMA ring memory and map */