@@ -686,6 +686,7 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
pci_bus_register_of_sysfs(bus);
pci_claim_bus_resources(bus);
+ pci_register_legacy_regions(bus);
pci_bus_add_devices(bus);
return bus;
}
@@ -328,41 +328,46 @@ void pci_get_pbm_props(struct pci_pbm_info *pbm)
}
}
-static void pci_register_legacy_regions(struct resource *io_res,
- struct resource *mem_res)
+static void pci_register_region(struct pci_bus *bus, const char *name,
+ resource_size_t rstart, resource_size_t size)
{
- struct resource *p;
+ struct resource *res, *conflict, *bus_res;
+ struct pci_bus_region region;
- /* VGA Video RAM. */
- p = kzalloc(sizeof(*p), GFP_KERNEL);
- if (!p)
+ res = kzalloc(sizeof(*res), GFP_KERNEL);
+ if (!res)
return;
- p->name = "Video RAM area";
- p->start = mem_res->start + 0xa0000UL;
- p->end = p->start + 0x1ffffUL;
- p->flags = IORESOURCE_BUSY;
- request_resource(mem_res, p);
+ res->flags = IORESOURCE_MEM;
- p = kzalloc(sizeof(*p), GFP_KERNEL);
- if (!p)
+ region.start = rstart;
+ region.end = rstart + size - 1UL;
+ pcibios_bus_to_resource(bus, res, ®ion);
+ bus_res = pci_find_bus_resource(bus, res);
+ if (!bus_res) {
+ kfree(res);
return;
+ }
+
+ res->name = name;
+ res->flags |= IORESOURCE_BUSY;
+ conflict = request_resource_conflict(bus_res, res);
+ if (conflict) {
+ dev_printk(KERN_DEBUG, &bus->dev,
+ " can't claim %s %pR: address conflict with %s %pR\n",
+ res->name, res, conflict->name, conflict);
+ kfree(res);
+ }
+}
- p->name = "System ROM";
- p->start = mem_res->start + 0xf0000UL;
- p->end = p->start + 0xffffUL;
- p->flags = IORESOURCE_BUSY;
- request_resource(mem_res, p);
+void pci_register_legacy_regions(struct pci_bus *bus)
+{
+ /* VGA Video RAM. */
+ pci_register_region(bus, "Video RAM area", 0xa0000UL, 0x20000UL);
- p = kzalloc(sizeof(*p), GFP_KERNEL);
- if (!p)
- return;
+ pci_register_region(bus, "System ROM", 0xf0000UL, 0x10000UL);
- p->name = "Video ROM";
- p->start = mem_res->start + 0xc0000UL;
- p->end = p->start + 0x7fffUL;
- p->flags = IORESOURCE_BUSY;
- request_resource(mem_res, p);
+ pci_register_region(bus, "Video ROM", 0xc0000UL, 0x8000UL);
}
static void pci_register_iommu_region(struct pci_pbm_info *pbm)
@@ -504,8 +509,6 @@ void pci_determine_mem_io_space(struct pci_pbm_info *pbm)
if (pbm->mem64_space.flags)
request_resource(&iomem_resource, &pbm->mem64_space);
- pci_register_legacy_regions(&pbm->io_space,
- &pbm->mem_space);
pci_register_iommu_region(pbm);
}
@@ -167,6 +167,7 @@ void pci_get_pbm_props(struct pci_pbm_info *pbm);
struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
struct device *parent);
void pci_determine_mem_io_space(struct pci_pbm_info *pbm);
+void pci_register_legacy_regions(struct pci_bus *bus);
/* Error reporting support. */
void pci_scan_for_target_abort(struct pci_pbm_info *, struct pci_bus *);