Subject: Possible fix for kern/10586: wake up from power state D3
To: None <tech-kern@netbsd.org>
From: Matthias Scheler <tron@zhadum.de>
List: tech-kern
Date: 07/16/2000 13:13:03
	Hello,

after dumping the PCI configuration registers of my SMC9432TX in power
states D0 and D3 as John Hawkinson suggested I was able to enhance our
epic driver to wake up a card from power state D3:

Index: if_epic_pci.c
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/pci/if_epic_pci.c,v
retrieving revision 1.11
diff -u -r1.11 if_epic_pci.c
--- if_epic_pci.c	2000/07/15 20:57:24	1.11
+++ if_epic_pci.c	2000/07/16 11:06:09
@@ -167,18 +167,21 @@
 
 	if (pci_get_capability(pc, pa->pa_tag, PCI_CAP_PWRMGMT, &pmreg, 0)) {
 		reg = pci_conf_read(pc, pa->pa_tag, pmreg + 4) & 0x3;
-		if (reg == 3) {
-			/*
-			 * The card has lost all configuration data in
-			 * this state, so punt.
-			 */
-			printf(": unable to wake up from power state D3\n");
-			return;
-		}
 		if (reg != 0) {
 			printf(": waking up from power state D%d\n%s",
 			    reg, sc->sc_dev.dv_xname);
 			pci_conf_write(pc, pa->pa_tag, pmreg + 4, 0);
+		}
+		if (reg == 3) {
+			reg = pci_conf_read(pc, pa->pa_tag,
+					    PCI_COMMAND_STATUS_REG);
+			reg |= PCI_COMMAND_IO_ENABLE |
+			       PCI_COMMAND_MEM_ENABLE |
+			       PCI_COMMAND_MASTER_ENABLE;
+			pci_conf_write(pc, pa->pa_tag,
+				       PCI_COMMAND_STATUS_REG, reg);
+			pa->pa_flags |= PCI_FLAGS_IO_ENABLED |
+					PCI_FLAGS_MEM_ENABLED;
 		}
 	}
 

I only wonder if this change is correct. I'm especially uncertain about
the part where "pa->pa_flags" gets modified. Any comments?

	Kind regards

-- 
Matthias Scheler                            http://www.sighardstrasse.de/~tron/