Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 May 2011 18:25:40 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 192608 for review
Message-ID:  <201105041825.p44IPepw079264@skunkworks.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@192608?ac=10

Change 192608 by jhb@jhb_jhbbsd on 2011/05/04 18:24:39

	Axe the old host res code and just go with the filter approach
	now.

Affected files ...

.. //depot/projects/pci/sys/dev/acpica/acpi_pcib_acpi.c#15 edit
.. //depot/projects/pci/sys/dev/pci/pci_domain.c#7 edit
.. //depot/projects/pci/sys/dev/pci/pcib_private.h#14 edit

Differences ...

==== //depot/projects/pci/sys/dev/acpica/acpi_pcib_acpi.c#15 (text+ko) ====

@@ -90,16 +90,6 @@
 			    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,
-			    u_long start, u_long end);
-static int		acpi_pcib_acpi_release_resource(device_t dev,
-			    device_t child, int type, int rid,
-			    struct resource *r);
-#endif
-#endif
 
 static device_method_t acpi_pcib_acpi_methods[] = {
     /* Device interface */
@@ -114,13 +104,8 @@
     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_XXX
-    DEVMETHOD(bus_adjust_resource,	acpi_pcib_acpi_adjust_resource),
-    DEVMETHOD(bus_release_resource,	acpi_pcib_acpi_release_resource),
-#else
     DEVMETHOD(bus_adjust_resource,	bus_generic_adjust_resource),
     DEVMETHOD(bus_release_resource,	bus_generic_release_resource),
-#endif
     DEVMETHOD(bus_activate_resource,	bus_generic_activate_resource),
     DEVMETHOD(bus_deactivate_resource,	bus_generic_deactivate_resource),
     DEVMETHOD(bus_setup_intr,		bus_generic_setup_intr),
@@ -561,28 +546,3 @@
 	count, flags));
 #endif
 }
-
-#if 0
-#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));
-}
-
-int
-acpi_pcib_acpi_release_resource(device_t dev, device_t child, int type, int rid,
-    struct resource *r)
-{
-	struct acpi_hpcib_softc *sc;
-
-	sc = device_get_softc(dev);
-	return (pcib_host_res_release(&sc->ap_host_res, child, type, rid, r));
-}
-#endif
-#endif

==== //depot/projects/pci/sys/dev/pci/pci_domain.c#7 (text+ko) ====

@@ -1,5 +1,5 @@
 /*-
- * XXX: Rename this file to something else, maybe pcib.c?
+ * XXX: Rename this file to something else, maybe pcib_subr.c?
  *
  * Support utilities for Host to PCI bridge drivers.
  */
@@ -111,240 +111,29 @@
  * decode and should only allocate subranges to child PCI devices.
  * This API provides a way to manage this.  The bridge drive should
  * initialize this structure during attach and call
- * pcib_host_res_manage() on each resource range it decodes.  It can
- * then use pcib_host_res_alloc() and pcib_host_res_release() as
- * helper routines for BUS_ALLOC_RESOURCE() and
- * BUS_RELEASE_RESOURCE().
- *
- * The host bridge resource structure contains its own resource list
- * to track all the resources allocated from the parent.  This may
- * duplicate an existing resource list in the bridge drivers ivars.
- * We attempt to make this work by assigning new resources allocated
- * from the parent via pcib_host_res_manage() unused RIDs.
+ * 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().
  */
-#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)
-{
-	char buf[64];
-	int error;
-
-	rm->rm_start = start;
-	rm->rm_end = end;
-	rm->rm_type = RMAN_ARRAY;
-	snprintf(buf, sizeof(buf), "%s %s", device_get_nameunit(hr->hr_pcib),
-	    name);
-	rm->rm_descr = strdup(buf, M_DEVBUF);
-	error = rman_init(rm);
-	if (error)
-		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)
 {
 
 	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;
-
-	error = rman_fini(&hr->hr_mem_rman);
-	if (error) {
-		device_printf(pcib, "memory resources busy\n");
-		return (error);
-	}
-	error = rman_fini(&hr->hr_io_rman);
-	if (error) {
-		device_printf(pcib, "I/O port resources busy\n");
-		return (error);
-	}
-#ifdef PCI_RES_BUS
-	error = rman_fini(&hr->hr_bus_rman);
-	if (error) {
-		device_printf(pcib, "bus numbers busy\n");
-		return (error);
-	}
-#endif
 
-	/*
-	 * Release all allocated resources and remove them from the
-	 * parent's resource list.
-	 */
-	STAILQ_FOREACH(rle, &hr->hr_rl, link) {
-		if (rle->res != NULL) {
-			bus_release_resource(pcib, rle->type, rle->rid,
-			    rle->res);
-			rle->res = NULL;
-		}
-		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)
-{
-
-	switch (type) {
-	case SYS_RES_IOPORT:
-		return (&hr->hr_io_rman);
-	case SYS_RES_MEMORY:
-		return (&hr->hr_mem_rman);
-#ifdef PCI_RES_BUS
-	case PCI_RES_BUS:
-		return (&hr->hr_bus_rman);
-#endif
-	default:
-		return (NULL);
-	}
-}
-
-static int
-pcib_host_res_is_resource_managed(struct pcib_host_resources *hr, int type,
-    struct resource *r)
-{
-	struct rman *rm;
-
-	rm = pcib_host_res_rman(hr, type);
-	return (rm != NULL && rman_is_region_manager(r, rm));
-}
-
-int
-pcib_host_res_manage(struct pcib_host_resources *hr, int type,
-    u_long start, u_long end)
-{
-	struct resource_list_entry *rle;
-	struct resource *r;
-	struct rman *rm;
-	u_long count;
-	int error, rid;
-
-	rm = pcib_host_res_rman(hr, type);
-	if (rm == NULL)
-		return (EINVAL);
-	count = end - start + 1;
-	for (rid = 0;; rid++)
-		if (bus_get_resource(hr->hr_pcib, type, rid, NULL, NULL) != 0)
-			break;
-	error = bus_set_resource(hr->hr_pcib, type, rid, start, count);
-	if (error)
-		return (error);
-	r = bus_alloc_resource_any(hr->hr_pcib, type, &rid, 0);
-	if (r == NULL) {
-		device_printf(hr->hr_pcib,
-		    "Failed to allocate %d res %#lx-%#lx\n", type, start, end);
-		return (ENXIO);
-	}
-	KASSERT(rman_get_start(r) == start && rman_get_end(r) == end,
-	    ("resource mismatch"));
-	error = rman_manage_region(rm, start, end);
-	if (error) {
-		device_printf(hr->hr_pcib,
-		    "Failed to add %d res %#lx-%#lx to rman\n", type, start,
-		    end);
-		bus_release_resource(hr->hr_pcib, type, rid, r);
-		return (error);
-	}
-	rle = resource_list_add(&hr->hr_rl, type, rid, start, end, count);
-	rle->res = r;
-	return (0);
-}
-
-int
-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 **rp)
-{
-	struct resource *r;
-	struct rman *rm;
-
-	rm = pcib_host_res_rman(hr, type);
-	if (rm == NULL)
-		return (EINVAL);
-	if (rman_is_empty(rm))
-		return (ENXIO);
-
-	r = rman_reserve_resource(rm, start, end, count, flags & ~RF_ACTIVE,
-	    dev);
-	if (r == NULL) {
-		*rp = NULL;
-		return (0);
-	}
-
-	if (bootverbose)
-		device_printf(hr->hr_pcib,
-		    "allocated type %d (%#lx-%#lx) for rid %x of %s\n", type,
-		    rman_get_start(r), rman_get_end(r), *rid,
-		    pcib_child_name(dev));
-	rman_set_rid(r, *rid);
-
-	/*
-	 * If the resource should be active, pass that request up the
-	 * tree.  This assumes the parent drivers can handle
-	 * activating sub-allocated resources.
-	 */
-	if (flags & RF_ACTIVE) {
-		if (bus_activate_resource(dev, type, *rid, r) != 0) {
-			rman_release_resource(r);
-			*rp = NULL;
-			return (0);
-		}
-	}
-
-	*rp = r;
-	return (0);
-}
-
-int
-pcib_host_res_adjust(struct pcib_host_resources *hr, device_t dev, int type,
-    struct resource *r, u_long start, u_long end)
-{
-
-	if (pcib_host_res_is_resource_managed(hr, type, r))
-		return (rman_adjust_resource(r, start, end));
-	return (bus_generic_adjust_resource(hr->hr_pcib, dev, type, r, start,
-	    end));
-}
-
-int
-pcib_host_res_release(struct pcib_host_resources *hr, device_t dev, int type,
-    int rid, struct resource *r)
-{
-	int error;
-
-	if (pcib_host_res_is_resource_managed(hr, type, r)) {
-		if (rman_get_flags(r) & RF_ACTIVE) {
-			error = bus_deactivate_resource(dev, type, rid, r);
-			if (error)
-				return (error);
-		}
-		return (rman_release_resource(r));
-	}
-	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)
@@ -399,4 +188,3 @@
 
 	return (NULL);
 }
-#endif

==== //depot/projects/pci/sys/dev/pci/pcib_private.h#14 (text+ko) ====

@@ -41,12 +41,7 @@
  */
 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
+	struct resource_list hr_rl;
 };
 #endif
 
@@ -118,18 +113,6 @@
 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,
-		    device_t dev, int type, int *rid, u_long start, u_long end,
-		    u_long count, u_int flags, struct resource **rp);
-int		pcib_host_res_adjust(struct pcib_host_resources *hr,
-		    device_t dev, int type, struct resource *r, u_long start,
-		    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,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201105041825.p44IPepw079264>