PERFORCE change 193005 for review
John Baldwin
jhb at FreeBSD.org
Thu May 12 12:04:36 UTC 2011
http://p4web.freebsd.org/@@193005?ac=10
Change 193005 by jhb at jhb_fiver on 2011/05/12 12:04:15
Add an adjust resource helper for the host_res API to fail attempts
to adjust a resource if the new range would not be contained in a
decoded range.
Affected files ...
.. //depot/projects/pci/sys/dev/acpica/acpi_pcib_acpi.c#18 edit
.. //depot/projects/pci/sys/dev/pci/pci_domain.c#11 edit
Differences ...
==== //depot/projects/pci/sys/dev/acpica/acpi_pcib_acpi.c#18 (text+ko) ====
@@ -90,6 +90,11 @@
device_t child, int type, int *rid,
u_long start, u_long end, u_long count,
u_int flags);
+#ifdef NEW_PCIB
+static int acpi_pcib_acpi_adjust_resource(device_t dev,
+ device_t child, int type, struct resource *r,
+ u_long start, u_long end);
+#endif
static device_method_t acpi_pcib_acpi_methods[] = {
/* Device interface */
@@ -104,7 +109,11 @@
DEVMETHOD(bus_read_ivar, acpi_pcib_read_ivar),
DEVMETHOD(bus_write_ivar, acpi_pcib_write_ivar),
DEVMETHOD(bus_alloc_resource, acpi_pcib_acpi_alloc_resource),
+#ifdef NEW_PCIB
+ DEVMETHOD(bus_adjust_resource, acpi_pcib_acpi_adjust_resource),
+#else
DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource),
+#endif
DEVMETHOD(bus_release_resource, bus_generic_release_resource),
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
@@ -559,3 +568,16 @@
count, flags));
#endif
}
+
+#ifdef NEW_PCIB
+int
+acpi_pcib_acpi_adjust_resource(device_t dev, device_t child, int type,
+ struct resource *r, u_long start, u_long end)
+{
+ struct acpi_hpcib_softc *sc;
+
+ sc = device_get_softc(dev);
+ return (pcib_host_res_adjust(&sc->ap_host_res, child, type, r, start,
+ end));
+}
+#endif
==== //depot/projects/pci/sys/dev/pci/pci_domain.c#11 (text+ko) ====
@@ -112,10 +112,10 @@
* This API provides a way to manage this. The bridge drive should
* initialize this structure during attach and call
* pcib_host_res_decodes() on each resource range it decodes. It can
- * then use pcib_host_res_alloc() as a helper routine for
- * BUS_ALLOC_RESOURCE(). This API assumes that resources for any
- * decoded ranges can be safely allocated from the parent via
- * bus_generic_alloc_resource().
+ * then use pcib_host_res_alloc() and pcib_host_res_adjust() as helper
+ * routines for BUS_ALLOC_RESOURCE() and BUS_ADJUST_RESOURCE(). This
+ * API assumes that resources for any decoded ranges can be safely
+ * allocated from the parent via bus_generic_alloc_resource().
*/
int
pcib_host_res_init(device_t pcib, struct pcib_host_resources *hr)
@@ -215,3 +215,28 @@
}
return (NULL);
}
+
+int
+pcib_host_res_adjust(struct pcib_host_resources *hr, device_t dev, int type,
+ struct resource *r, u_long start, u_long end)
+{
+ struct resource_list_entry *rle;
+
+ rle = resource_list_find(&hr->hr_rl, type, 0);
+ if (rle == NULL) {
+ /*
+ * No decoding ranges for this resource type, just pass
+ * the request up to the parent.
+ */
+ return (bus_generic_adjust_resource(hr->hr_pcib, dev, type, r,
+ start, end));
+ }
+
+ /* Only allow adjustments that stay within a decoded range. */
+ for (; rle != NULL; rle = STAILQ_NEXT(rle, link)) {
+ if (rle->start <= start && rle->end >= end)
+ return (bus_generic_adjust_resource(hr->hr_pcib, dev,
+ type, r, start, end));
+ }
+ return (ERANGE);
+}
More information about the p4-projects
mailing list