PERFORCE change 230995 for review

John Baldwin jhb at FreeBSD.org
Thu Jul 11 03:30:01 UTC 2013


http://p4web.freebsd.org/@@230995?ac=10

Change 230995 by jhb at jhb_pippin on 2013/07/11 03:29:51

	- Partial cardbus updates for the bus renumbering bits.
	- Don't leak PCI bus number resources.

Affected files ...

.. //depot/projects/pci/sys/dev/cardbus/cardbus.c#8 edit
.. //depot/projects/pci/sys/dev/cardbus/cardbusvar.h#3 edit
.. //depot/projects/pci/sys/dev/pccbb/pccbb.c#5 edit
.. //depot/projects/pci/sys/dev/pccbb/pccbb_pci.c#5 edit
.. //depot/projects/pci/sys/dev/pci/pci.c#43 edit

Differences ...

==== //depot/projects/pci/sys/dev/cardbus/cardbus.c#8 (text+ko) ====

@@ -96,17 +96,36 @@
 cardbus_attach(device_t cbdev)
 {
 	struct cardbus_softc *sc;
+#ifdef PCI_RES_BUS
+	int rid;
+#endif
 
 	sc = device_get_softc(cbdev);
 	sc->sc_dev = cbdev;
+#ifdef PCI_RES_BUS
+	rid = 0;
+	sc->sc_bus = bus_alloc_resource(cbdev, PCI_RES_BUS, &rid,
+	    pcib_get_bus(cbdev), pcib_get_bus(cbdev), 1, 0);
+	if (sc->sc_bus == NULL) {
+		device_printf(cbdev, "failed to allocate bus number\n");
+		return (ENXIO);
+	}
+#endif
 	return (0);
 }
 
 static int
 cardbus_detach(device_t cbdev)
 {
+#ifdef PCI_RES_BUS
+	struct cardbus_softc *sc;
+#endif
 
 	cardbus_detach_card(cbdev);
+#ifdef PCI_RES_BUS
+	sc = device_get_softc(cbdev);
+	(void)bus_release_resource(cbdev, PCI_RES_BUS, 0, sc->sc_bus));
+#endif
 	return (0);
 }
 

==== //depot/projects/pci/sys/dev/cardbus/cardbusvar.h#3 (text+ko) ====

@@ -69,6 +69,9 @@
 struct cardbus_softc 
 {
 	device_t	sc_dev;
+#ifdef PCI_RES_BUS
+	struct resource *sc_bus;
+#endif
 };
 
 /*

==== //depot/projects/pci/sys/dev/pccbb/pccbb.c#5 (text+ko) ====

@@ -1203,6 +1203,9 @@
 	u_long align;
 
 	switch (type) {
+#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
+		/* XXX: PCI_RES_BUS handling */
+#endif
 	case SYS_RES_IRQ:
 		tmp = rman_get_start(sc->irq_res);
 		if (start > tmp || end < tmp || count != 1) {

==== //depot/projects/pci/sys/dev/pccbb/pccbb_pci.c#5 (text+ko) ====

@@ -321,6 +321,9 @@
 	sc->secbus = pci_read_config(brdev, PCIR_SECBUS_2, 1);
 	sc->subbus = pci_read_config(brdev, PCIR_SUBBUS_2, 1);
 	sc->pribus = pcib_get_bus(parent);
+#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
+	/* XXX: Need something like pci_setup_secbus() here. */
+#endif
 	SLIST_INIT(&sc->rl);
 	cbb_powerstate_d0(brdev);
 

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

@@ -3868,6 +3868,10 @@
 		pci_printf(&dinfo->cfg, "Device leaked memory resources\n");
 	if (resource_list_release_active(rl, dev, child, SYS_RES_IOPORT) != 0)
 		pci_printf(&dinfo->cfg, "Device leaked I/O resources\n");
+#ifdef PCI_RES_BUS
+	if (resource_list_release_active(rl, dev, child, PCI_RES_BUS) != 0)
+		pci_printf(&dinfo->cfg, "Device leaked PCI bus numbers\n");
+#endif
 
 	pci_cfg_save(child, dinfo, 1);
 }


More information about the p4-projects mailing list