Index: pci.c =================================================================== RCS file: /usr/cvs/src/sys/dev/pci/pci.c,v retrieving revision 1.357 diff -u -r1.357 pci.c --- pci.c 1 Feb 2008 20:31:09 -0000 1.357 +++ pci.c 4 Aug 2008 16:03:04 -0000 @@ -2319,6 +2319,8 @@ * respond oddly to having these bits enabled. Let the user * be able to turn them off (since pci_enable_io_modes is 1 by * default). + * + * XXX: We probably shouldn't do this until after programming the BAR. */ if (pci_enable_io_modes) { /* Turn on resources that have been left off by a lazy BIOS */ @@ -2355,16 +2357,32 @@ */ res = resource_list_alloc(rl, bus, dev, type, ®, start, end, count, prefetch ? RF_PREFETCHABLE : 0); - if (res == NULL) - return (barlen); - start = rman_get_start(res); - if ((u_long)start != start) { - /* Wait a minute! this platform can't do this address. */ - device_printf(bus, - "pci%d:%d.%d.%x bar %#x start %#jx, too many bits.", - pci_get_domain(dev), b, s, f, reg, (uintmax_t)start); - resource_list_release(rl, bus, dev, type, reg, res); - return (barlen); + if (res == NULL) { + /* + * If this fails, clear the BAR and delete the + * resource list entry to force pci_alloc_resource() + * to allocate resources from the parent. + */ + resource_list_delete(rl, type, reg); + start = 0; + } else { + start = rman_get_start(res); + if ((u_long)start != start) { + /* + * Wait a minute! This platform can't do this + * address. + */ + device_printf(bus, + "pci%d:%d.%d.%x bar %#x start %#jx, too many bits.", + pci_get_domain(dev), b, s, f, reg, + (uintmax_t)start); + resource_list_release(rl, bus, dev, type, reg, res); + + /* + * XXX: Should this delete the resource list entry? + */ + return (barlen); + } } pci_write_config(dev, reg, start, 4); if (ln2range == 64)