Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 Mar 2011 12:00:57 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 189492 for review
Message-ID:  <201103041200.p24C0vwF065639@skunkworks.freebsd.org>

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

Change 189492 by jhb@jhb_kavik on 2011/03/04 12:00:27

	More hacking.  Going to retire pm_enabled and calulate it for the
	ioctl instead.

Affected files ...

.. //depot/projects/pci/sys/dev/pci/pci.c#3 edit
.. //depot/projects/pci/sys/dev/pci/pci_private.h#3 edit
.. //depot/projects/pci/sys/dev/pci/pci_user.c#3 edit

Differences ...

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

@@ -2453,8 +2453,9 @@
 }
 
 static void
-pci_write_bar(device_t dev, int reg, pci_addr_t base)
+pci_write_bar(device_t dev, struct pci_map *pm, pci_addr_t base)
 {
+	struct pci_map *pm;
 	pci_addr_t map;
 	int ln2range;
 
@@ -2483,6 +2484,14 @@
 	return (NULL);
 }
 
+int
+pci_bar_enabled(device_t dev, struct pci_map *pm)
+{
+	uint16_t cmd;
+
+	if (pm->
+}
+
 struct pci_map *
 pci_add_bar(device_t dev, int reg)
 {
@@ -3938,6 +3947,7 @@
 pci_activate_resource(device_t dev, device_t child, int type, int rid,
     struct resource *r)
 {
+	struct pci_map *pm;
 	int error;
 
 	error = bus_generic_activate_resource(dev, child, type, rid, r);
@@ -3947,9 +3957,12 @@
 	/* Enable decoding in the command register when activating BARs. */
 	if (device_get_parent(child) == dev) {
 		/* Device ROMs need their decoding explicitly enabled. */
-		if (rid == PCIR_BIOS)
-			pci_write_config(child, rid, rman_get_start(r) |
+		if (rid == PCIR_BIOS) {
+			pm = pci_get_bar(child, PCIR_BIOS);
+			pm->pm_enabled = 1;
+			pci_write_config(child, PCIR_BIOS, rman_get_start(r) |
 			    PCIM_BIOS_ENABLE, 4);
+		}
 		switch (type) {
 		case SYS_RES_IOPORT:
 		case SYS_RES_MEMORY:
@@ -3971,8 +3984,11 @@
 		return (error);
 
 	/* Disable decoding for device ROMs. */
-	if (rid == PCIR_BIOS)
-		pci_write_config(child, rid, rman_get_start(r), 4);
+	if (rid == PCIR_BIOS) {
+		pci_write_config(child, PCIR_BIOS, rman_get_start(r), 4);
+		pm = pci_read_bar(child, PCIR_BIOS);
+		pm->pm_enabled = 0;
+	}
 	return (0);
 }
 
@@ -4171,9 +4187,11 @@
 	 */
 	if (pci_get_powerstate(dev) != PCI_POWERSTATE_D0)
 		pci_set_powerstate(dev, PCI_POWERSTATE_D0);
+#if 0
 	for (i = 0; i < dinfo->cfg.nummaps; i++)
 		pci_write_config(dev, PCIR_BAR(i), dinfo->cfg.bar[i], 4);
 	pci_write_config(dev, PCIR_BIOS, dinfo->cfg.bios, 4);
+#endif
 	pci_write_config(dev, PCIR_COMMAND, dinfo->cfg.cmdreg, 2);
 	pci_write_config(dev, PCIR_INTLINE, dinfo->cfg.intline, 1);
 	pci_write_config(dev, PCIR_INTPIN, dinfo->cfg.intpin, 1);
@@ -4207,9 +4225,11 @@
 	 */
 	if ((dinfo->cfg.hdrtype & PCIM_HDRTYPE) != PCIM_HDRTYPE_NORMAL)
 		return;
+#if 0
 	for (i = 0; i < dinfo->cfg.nummaps; i++)
 		dinfo->cfg.bar[i] = pci_read_config(dev, PCIR_BAR(i), 4);
 	dinfo->cfg.bios = pci_read_config(dev, PCIR_BIOS, 4);
+#endif
 
 	/*
 	 * Some drivers apparently write to these registers w/o updating our

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

@@ -105,6 +105,7 @@
 int		pci_resume(device_t dev);
 int		pci_suspend(device_t dev);
 struct pci_map *pci_find_bar(device_t dev, int reg);
+int		pci_bar_enabled(device_t dev, struct pci_map *pm);
 
 /** Restore the config register state.  The state must be previously
  * saved with pci_cfg_save.  However, the pci bus driver takes care of

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

@@ -692,7 +692,7 @@
 		}
 		bio->pbi_base = pm->pm_value;
 		bio->pbi_length = (pci_addr_t)1 << pm->pm_size;
-		bio->pbi_enabled = pm->pm_enabled;
+		bio->pbi_enabled = pci_bar_enabled(pcidev, pm);
 		error = 0;
 		break;
 	case PCIOCATTACHED:



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