Module Name:    src
Committed By:   dyoung
Date:           Wed Aug 19 21:36:47 UTC 2009

Modified Files:
        src/sys/dev/pci: pci.c

Log Message:
Since the intention in capturing a device's PCI Configuration Space
in pci_probe_device() is for pcidevdetached() to restore the device's
original PCI Configuration Space after it is detached, let's capture
a device's PCI configuration before attaching a driver to it instead
of after.  Capturing the configuration after attaching is too late,
because a driver such as ath(4) may put a device to sleep promptly
after attaching it, and putting a PCI device to sleep often entails
changing PCI configuration from defaults.


To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.124 src/sys/dev/pci/pci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/pci.c
diff -u src/sys/dev/pci/pci.c:1.123 src/sys/dev/pci/pci.c:1.124
--- src/sys/dev/pci/pci.c:1.123	Sat Jul  4 21:01:10 2009
+++ src/sys/dev/pci/pci.c	Wed Aug 19 21:36:47 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci.c,v 1.123 2009/07/04 21:01:10 cegger Exp $	*/
+/*	$NetBSD: pci.c,v 1.124 2009/08/19 21:36:47 dyoung Exp $	*/
 
 /*
  * Copyright (c) 1995, 1996, 1997, 1998
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.123 2009/07/04 21:01:10 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.124 2009/08/19 21:36:47 dyoung Exp $");
 
 #include "opt_pci.h"
 
@@ -276,7 +276,6 @@
 	pcireg_t id, csr, class, intr, bhlcr;
 	int ret, pin, bus, device, function;
 	int locs[PCICF_NLOCS];
-	device_t subdev;
 
 	pci_decompose_tag(pc, tag, &bus, &device, &function);
 
@@ -363,17 +362,17 @@
 		locs[PCICF_DEV] = device;
 		locs[PCICF_FUNCTION] = function;
 
-		subdev = config_found_sm_loc(sc->sc_dev, "pci", locs, &pa,
-					     pciprint, config_stdsubmatch);
-
 		c = &sc->PCI_SC_DEVICESC(device, function);
-		c->c_dev = subdev;
 		pci_conf_capture(pc, tag, &c->c_conf);
 		if (pci_get_powerstate(pc, tag, &c->c_powerstate) == 0)
 			c->c_psok = true;
 		else
 			c->c_psok = false;
-		ret = (subdev != NULL);
+
+		c->c_dev = config_found_sm_loc(sc->sc_dev, "pci", locs, &pa,
+					     pciprint, config_stdsubmatch);
+
+		ret = (c->c_dev != NULL);
 	}
 
 	return ret;

Reply via email to