@@ -76,11 +76,42 @@ pcibios_align_resource(void *data, const struct resource *res,
return start;
}
+static struct pci_bus_resource *
+controller_resources(const struct pci_controller *ctrl, int domain, int busno)
+{
+ struct pci_bus_resource *mem_res, *io_res;
+
+ mem_res = kzalloc(sizeof(struct pci_bus_resource), GFP_KERNEL);
+ if (!mem_res)
+ goto err_out;
+
+ mem_res->res = ctrl->mem_resource;
+ mem_res->flags = 0;
+ INIT_LIST_HEAD(&mem_res->list);
+
+ io_res = kzalloc(sizeof(struct pci_bus_resource), GFP_KERNEL);
+ if (!io_res) {
+ kfree(mem_res);
+ goto err_out;
+ }
+
+ io_res->res = ctrl->io_resource;
+ io_res->flags = 0;
+ list_add(&io_res->list, &mem_res->list);
+
+ return mem_res;
+err_out:
+ printk(KERN_ERR "PCI bus %04x:%02x: Can't allocate bus resource.\n",
+ domain, busno);
+ return NULL;
+}
+
static void __devinit pcibios_scanbus(struct pci_controller *hose)
{
static int next_busno;
static int need_domain_info;
- struct pci_bus *bus;
+ struct pci_bus *bus = NULL;
+ struct pci_bus_resource *bus_res;
if (!hose->iommu)
PCI_DMA_BUS_IS_PHYS = 1;
@@ -88,7 +119,22 @@ static void __devinit pcibios_scanbus(struct pci_controller *hose)
if (hose->get_busno && pci_probe_only)
next_busno = (*hose->get_busno)();
- bus = pci_scan_bus(next_busno, hose->pci_ops, hose);
+ bus_res = controller_resources(hose, hose->index, next_busno);
+ if (bus_res) {
+ bus = pci_create_bus(NULL, next_busno, hose->pci_ops,
+ hose, bus_res);
+ if (bus) {
+ bus->subordinate = pci_scan_child_bus(bus);
+ pci_bus_add_devices(bus);
+ } else {
+ /* io_resource */
+ kfree(list_first_entry(&bus_res->list,
+ struct pci_bus_resource, list));
+ /* mem_resource */
+ kfree(bus_res);
+ }
+ }
+
hose->bus = bus;
need_domain_info = need_domain_info || hose->index;
@@ -265,15 +311,14 @@ void __devinit pcibios_fixup_bus(struct pci_bus *bus)
{
/* Propagate hose info into the subordinate devices. */
- struct pci_controller *hose = bus->sysdata;
struct list_head *ln;
struct pci_dev *dev = bus->self;
- if (!dev) {
- bus->resource[0] = hose->io_resource;
- bus->resource[1] = hose->mem_resource;
- } else if (pci_probe_only &&
- (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
+ /*
+ * Root bus resources should already be set up correctly in
+ * pci_create_bus(), so don't do fixups for it.
+ */
+ if (pci_probe_only && (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
pci_read_bridge_bases(bus);
pcibios_fixup_device_resources(dev, bus);
}