From af5e97c122bb5930176ecb450af087c0fd35a3ca Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Mon, 28 Feb 2005 01:27:24 +0000 Subject: There were two calls to cardbus_do_cis when cardbus_do_cis changed, yet I only changed one of them. So when we loaded drivers, we'd fail to allocate resources correct. This pointed out that we were doing the wrong thing when we failed to attach a child. We released all the resources and almost deleted the child. Instead, we should keep the resources allocated so when/if a driver is loaded, we can go w/o having to allocate them. We use pci_cfg_save/restore to restore the BARs with these resources. This seems to fix the problems that we were seeing that I thought might have magically gone away in the last revision of cardbus.c (but really didn't). Noticed by: avatar (nicely done!) --- sys/dev/cardbus/cardbus.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'sys/dev') diff --git a/sys/dev/cardbus/cardbus.c b/sys/dev/cardbus/cardbus.c index d6ffbe996cbb5..19974cd4219ea 100644 --- a/sys/dev/cardbus/cardbus.c +++ b/sys/dev/cardbus/cardbus.c @@ -471,10 +471,10 @@ cardbus_attach_card(device_t cbdev) } cardbus_pickup_maps(cbdev, child); cardbus_alloc_resources(cbdev, child); + pci_cfg_save(child, &dinfo->pci, 0); + pci_cfg_restore(child, &dinfo->pci); pci_print_verbose(&dinfo->pci); - if (device_probe_and_attach(child) != 0) - cardbus_release_all_resources(cbdev, dinfo); - else + if (device_probe_and_attach(child) == 0) cardattached++; } } @@ -545,10 +545,8 @@ cardbus_driver_added(device_t cbdev, driver_t *driver) continue; dinfo = device_get_ivars(dev); pci_print_verbose(&dinfo->pci); - resource_list_init(&dinfo->pci.resources); - cardbus_do_cis(cbdev, dev); - if (device_probe_and_attach(dev) != 0) - cardbus_release_all_resources(cbdev, dinfo); + pci_cfg_restore(dev, &dinfo->pci); + device_probe_and_attach(dev); } free(devlist, M_TEMP); } -- cgit v1.3