PERFORCE change 192553 for review
John Baldwin
jhb at FreeBSD.org
Tue May 3 20:39:06 UTC 2011
http://p4web.freebsd.org/@@192553?ac=10
Change 192553 by jhb at jhb_jhbbsd on 2011/05/03 20:38:21
Bah, the memory ranges overlap with ACPI system resources. Just
punt on using rmans for the host bridges entirely and use
something simpler.
Affected files ...
.. //depot/projects/pci/sys/dev/acpica/acpi_pcib_acpi.c#14 edit
.. //depot/projects/pci/sys/dev/pci/pci_domain.c#4 edit
.. //depot/projects/pci/sys/dev/pci/pcib_private.h#13 edit
Differences ...
==== //depot/projects/pci/sys/dev/acpica/acpi_pcib_acpi.c#14 (text+ko) ====
@@ -64,7 +64,6 @@
ACPI_BUFFER ap_prt; /* interrupt routing table */
#ifdef NEW_PCIB
struct pcib_host_resources ap_host_res;
- int ap_ignore_ioports;
#endif
};
@@ -91,6 +90,7 @@
device_t child, int type, int *rid,
u_long start, u_long end, u_long count,
u_int flags);
+#if 0
#ifdef NEW_PCIB
static int acpi_pcib_acpi_adjust_resource(device_t dev,
device_t child, int type, struct resource *r,
@@ -99,6 +99,7 @@
device_t child, int type, int rid,
struct resource *r);
#endif
+#endif
static device_method_t acpi_pcib_acpi_methods[] = {
/* Device interface */
@@ -113,7 +114,7 @@
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
+#ifdef NEW_PCIB_XXX
DEVMETHOD(bus_adjust_resource, acpi_pcib_acpi_adjust_resource),
DEVMETHOD(bus_release_resource, acpi_pcib_acpi_release_resource),
#else
@@ -231,16 +232,6 @@
return (AE_OK);
}
- if (type == SYS_RES_IOPORT) {
- if (min == 0) {
- device_printf(sc->ap_dev,
- "Ignoring I/O port ranges\n");
- sc->ap_ignore_ioports = 1;
- }
- if (sc->ap_ignore_ioports)
- break;
- }
-
/* XXX: Not sure this is correct? */
if (res->Data.Address.Decode != ACPI_POS_DECODE) {
device_printf(sc->ap_dev,
@@ -262,7 +253,7 @@
max = ULONG_MAX;
}
#endif
- error = pcib_host_res_manage(&sc->ap_host_res, type, min, max);
+ error = pcib_host_res_decodes(&sc->ap_host_res, type, min, max);
if (error)
panic("Failed to manage %d range (%#jx-%#jx): %d", type,
(uintmax_t)min, (uintmax_t)max, error);
@@ -547,8 +538,6 @@
{
#ifdef NEW_PCIB
struct acpi_hpcib_softc *sc;
- struct resource *r;
- int error;
#endif
/*
@@ -565,15 +554,15 @@
#ifdef NEW_PCIB
sc = device_get_softc(dev);
- error = pcib_host_res_alloc(&sc->ap_host_res, child, type, rid, start, end,
- count, flags, &r);
- if (error == 0)
- return (r);
-#endif
+ return (pcib_host_res_alloc(&sc->ap_host_res, child, type, rid, start, end,
+ count, flags));
+#else
return (bus_generic_alloc_resource(dev, child, type, rid, start, end,
count, flags));
+#endif
}
+#if 0
#ifdef NEW_PCIB
int
acpi_pcib_acpi_adjust_resource(device_t dev, device_t child, int type,
@@ -596,3 +585,4 @@
return (pcib_host_res_release(&sc->ap_host_res, child, type, rid, r));
}
#endif
+#endif
==== //depot/projects/pci/sys/dev/pci/pci_domain.c#4 (text+ko) ====
@@ -122,6 +122,7 @@
* We attempt to make this work by assigning new resources allocated
* from the parent via pcib_host_res_manage() unused RIDs.
*/
+#if 0
static void
pcib_host_res_init_rman(struct pcib_host_resources *hr, struct rman *rm,
u_long start, u_long end, const char *name)
@@ -140,6 +141,7 @@
panic("Failed to initialize %s %s rman",
device_get_nameunit(hr->hr_pcib), name);
}
+#endif
int
pcib_host_res_init(device_t pcib, struct pcib_host_resources *hr)
@@ -147,18 +149,21 @@
hr->hr_pcib = pcib;
resource_list_init(&hr->hr_rl);
+#if 0
#ifdef PCI_RES_BUS
pcib_host_res_init_rman(hr, &hr->hr_bus_rman, 0, 255, "bus numbers");
#endif
pcib_host_res_init_rman(hr, &hr->hr_io_rman, 0, 0xffffffff,
"I/O ports");
pcib_host_res_init_rman(hr, &hr->hr_mem_rman, 0, ~0ul, "memory");
+#endif
return (0);
}
int
pcib_host_res_free(device_t pcib, struct pcib_host_resources *hr)
{
+#if 0
struct resource_list_entry *rle;
int error;
@@ -192,10 +197,12 @@
}
bus_delete_resource(pcib, rle->type, rle->rid);
}
+#endif
resource_list_free(&hr->hr_rl);
return (0);
}
+#if 0
static struct rman *
pcib_host_res_rman(struct pcib_host_resources *hr, int type)
{
@@ -337,3 +344,48 @@
}
return (bus_generic_release_resource(hr->hr_pcib, dev, type, rid, r));
}
+#else
+int
+pcib_host_res_decodes(struct pcib_host_resources *hr, int type, u_long start,
+ u_long end)
+{
+
+ resource_list_add_next(&hr->hr_rl, type, start, end, end - start + 1);
+ return (0);
+}
+
+struct resource *
+pcib_host_res_alloc(struct pcib_host_resources *hr, device_t dev, int type,
+ int *rid, u_long start, u_long end, u_long count, u_int flags)
+{
+ struct resource_list_entry *rle;
+ struct resource *r;
+ u_long new_start, new_end;
+
+ 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_alloc_resource(hr->hr_pcib, dev, type, rid,
+ start, end, count, flags));
+ }
+
+ /* Try to allocate from each decoded range. */
+ for (; rle != NULL; rle = STAILQ_NEXT(rle, link)) {
+ if (rle->type != type)
+ continue;
+ new_start = ulmax(start, rle->start);
+ new_end = ulmin(end, rle->end);
+ if (new_start + count > new_end)
+ continue;
+ r = bus_generic_alloc_resource(hr->hr_pcib, dev, type, rid,
+ new_start, new_end, count, flags);
+ if (r != NULL)
+ return (r);
+ }
+
+ return (NULL);
+}
+#endif
==== //depot/projects/pci/sys/dev/pci/pcib_private.h#13 (text+ko) ====
@@ -36,14 +36,17 @@
#ifdef NEW_PCIB
/*
* Data structure and routines that Host to PCI bridge drivers can use
- * to suballocate resources to PCI devices.
+ * to restrict allocations for child devices to ranges decoded by the
+ * bridge.
*/
struct pcib_host_resources {
device_t hr_pcib;
struct resource_list hr_rl; /* allocated resources from parent */
+#if 0
struct rman hr_bus_rman;
struct rman hr_io_rman;
struct rman hr_mem_rman;
+#endif
};
#endif
@@ -110,6 +113,12 @@
struct pcib_host_resources *hr);
int pcib_host_res_free(device_t pcib,
struct pcib_host_resources *hr);
+int pcib_host_res_decodes(struct pcib_host_resources *hr, int type,
+ u_long start, u_long end);
+struct resource *pcib_host_res_alloc(struct pcib_host_resources *hr,
+ device_t dev, int type, int *rid, u_long start, u_long end,
+ u_long count, u_int flags);
+#if 0
int pcib_host_res_manage(struct pcib_host_resources *hr, int type,
u_long start, u_long end);
int pcib_host_res_alloc(struct pcib_host_resources *hr,
@@ -120,6 +129,7 @@
u_long end);
int pcib_host_res_release(struct pcib_host_resources *hr,
device_t dev, int type, int rid, struct resource *r);
+#endif
struct resource *pci_domain_alloc_bus(int domain, device_t dev, int *rid, u_long start,
u_long end, u_long count, u_int flags);
int pci_domain_adjust_bus(int domain, device_t dev, struct resource *r,
More information about the p4-projects
mailing list