PERFORCE change 191580 for review
John Baldwin
jhb at FreeBSD.org
Sat Apr 16 04:08:58 UTC 2011
http://p4web.freebsd.org/@@191580?ac=10
Change 191580 by jhb at jhb_fiver on 2011/04/16 04:07:53
Update the ACPI Host-PCI bridge driver to properly handle bus
number resources (I think).
Affected files ...
.. //depot/projects/pci/sys/dev/acpica/acpi_pcib_acpi.c#6 edit
Differences ...
==== //depot/projects/pci/sys/dev/acpica/acpi_pcib_acpi.c#6 (text+ko) ====
@@ -64,7 +64,6 @@
ACPI_BUFFER ap_prt; /* interrupt routing table */
#ifdef NEW_PCIB
struct pcib_host_resources ap_host_res;
- struct resource *ap_bus_res; /* resource for 'ap_bus' */
#endif
};
@@ -219,9 +218,11 @@
case ACPI_IO_RANGE:
type = SYS_RES_IOPORT;
break;
+#ifdef PCI_RES_BUS
case ACPI_BUS_NUMBER_RANGE:
type = PCI_RES_BUS;
break;
+#endif
default:
return (AE_OK);
}
@@ -266,6 +267,11 @@
ACPI_STATUS status;
static int bus0_seen = 0;
u_int addr, slot, func, busok;
+#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
+ struct resource *bus_res;
+ u_long start, end;
+ int rid;
+#endif
uint8_t busno;
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
@@ -365,15 +371,38 @@
}
}
-#ifdef NEW_PCIB
+#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
/*
- * If we have a valid bus number, allocate it from our domain. If
- * we do not have a valid bus number, hope that ACPI at least lays
- * out the Host-PCI bridges in order and that as a result the next
- * free bus number is our bus number.
+ * If nothing else worked, hope that ACPI at least lays out the
+ * Host-PCI bridges in order and that as a result the next free
+ * bus number is our bus number.
*/
- if (busok) {
+ if (busok == 0) {
+ /*
+ * If we have a region of bus numbers, use the first
+ * number for our bus.
+ */
+ if (rman_first_free_region(&sc->ap_host_res.hr_bus_rman, &start,
+ &end) == 0)
+ sc->ap_bus = start;
+ else {
+ rid = 0;
+ bus_res = bus_alloc_resource(dev, PCI_RES_BUS, &rid, 0,
+ PCI_BUSMAX, 1, 0);
+ if (bus_res == NULL) {
+ device_printf(dev, "could not allocate bus number\n");
+ pcib_host_res_free(dev, &sc->ap_host_res);
+ return (ENXIO);
+ }
+ sc->ap_bus = rman_get_start(bus_res);
+ bus_release_resource(dev, PCI_RES_BUS, rid, bus_res);
+ }
} else {
+#ifdef INVARIANTS
+ if (rman_first_free_region(&sc->ap_host_res.hr_bus_rman, &start,
+ &end) == 0)
+ KASSERT(start == sc->ap_bus, ("bus number mismatch"));
+#endif
}
#else
/*
More information about the p4-projects
mailing list