Subject: Re: Call for testers: power management branch
To: None <current-users@netbsd.org>
From: Pierre Pronchery <khorben@defora.org>
List: current-users
Date: 11/28/2007 16:17:24
This is a multi-part message in MIME format.
--------------070803000102010803080104
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Kevin Lahey wrote:
> On Tue, 27 Nov 2007 06:36:44 -0500
> "Jared D. McNeill" <jmcneill@invisible.ca> wrote:
> 
>> On 27-Nov-07, at 1:12 AM, Kevin Lahey wrote:
> 
>>> Any suggestions (besides writing the relevant mii code and sending
>>> y'all patches :-))?
>> That is the proper fix -- if every device driver doesn't support power  
>> management, we cannot guarantee that the suspend/resume cycle will work.
>>
>> I don't know why your device list is so short -- my T61 has a handful  
>> of drivers lacking support. I can have a look at igphy this evening if  
>> you want..
> 
> Actually, the only other problems I saw from my lightly-modified
> GENERIC_LAPTOP config were sysbeep and midi, which I figured I could
> live without.  Thanks for all of the hard work on this stuff!

I have made a patch for some of these. It would be nice if it could be
reviewed and committed :)

Cheers,
-- 
khorben

--------------070803000102010803080104
Content-Type: text/x-patch;
 name="pm.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="pm.diff"

Index: arch/amd64/conf/GENERIC.local
===================================================================
RCS file: /cvsroot/src/sys/arch/amd64/conf/GENERIC.local,v
retrieving revision 1.1
diff -p -u -r1.1 GENERIC.local
--- arch/amd64/conf/GENERIC.local	26 Apr 2003 18:39:34 -0000	1.1
+++ arch/amd64/conf/GENERIC.local	24 Nov 2007 09:22:02 -0000
@@ -3,3 +3,48 @@
 #	GENERIC.local -- local additions to the GENERIC configuration
 #
 
+acpiacad* 	at acpi?
+acpibat* 	at acpi?
+acpibut* 	at acpi?
+acpiec* 	at acpi?
+acpilid* 	at acpi?
+acpitz* 	at acpi?
+
+com*		at acpi?
+fdc*		at acpi?
+joy*		at acpi?
+lpt*		at acpi?
+mpu*		at acpi?
+pckbc*		at acpi?
+attimer*	at acpi?
+pcppi*		at acpi?
+ug*		at acpi?
+wss*		at acpi?
+
+#agp*		at pchb?
+
+cbb*		at pci? dev ? function ?
+cardslot*	at cbb?
+
+cardbus*	at cardslot?
+pcmcia*		at cardslot?
+
+com*		at pcmcia? function ?
+
+com*		at cardbus? function ?
+
+wdc*		at pcmcia? function ?
+
+wi*		at pcmcia? function ?
+
+ehci*		at cardbus? function ?
+ohci*		at cardbus? function ?
+
+#aps*		at isa? port 0x1600
+#options		APSDEBUG
+cdce*		at uhub? port ?
+ichsmb*		at pci? dev ? function ?
+iic*		at ichsmb?
+wpi*		at pci? dev ? function ?
+
+#options		ENHANCED_SPEEDSTEP
Index: arch/x86/isa/clock.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/isa/clock.c,v
retrieving revision 1.9.8.3
diff -p -u -r1.9.8.3 clock.c
--- arch/x86/isa/clock.c	21 Nov 2007 21:53:38 -0000	1.9.8.3
+++ arch/x86/isa/clock.c	24 Nov 2007 09:22:33 -0000
@@ -559,6 +559,9 @@ sysbeepattach(struct device *parent, str
 
 	ppicookie = ((struct pcppi_attach_args *)aux)->pa_cookie;
 	ppi_attached = 1;
+
+	if (!pnp_device_register(self, NULL, NULL))
+		aprint_error_dev(self, "couldn't establish power handler\n");
 }
 #endif
 
Index: dev/ic/com.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/com.c,v
retrieving revision 1.261.6.3
diff -p -u -r1.261.6.3 com.c
--- dev/ic/com.c	21 Nov 2007 21:54:49 -0000	1.261.6.3
+++ dev/ic/com.c	24 Nov 2007 09:22:40 -0000
@@ -178,7 +178,7 @@ void	com_modem(struct com_softc *, int);
 void	tiocm_to_com(struct com_softc *, u_long, int);
 int	com_to_tiocm(struct com_softc *);
 void	com_iflush(struct com_softc *);
-void	com_power(int, void *);
+bool	com_resume(device_t dv);
 
 int	com_common_getc(dev_t, struct com_regs *);
 void	com_common_putc(dev_t, struct com_regs *, int);
@@ -549,11 +549,13 @@ fifodone:
 
 	com_config(sc);
 
-	sc->sc_powerhook = powerhook_establish(sc->sc_dev.dv_xname,
+/*	sc->sc_powerhook = powerhook_establish(sc->sc_dev.dv_xname,
 	    com_power, sc);
 	if (sc->sc_powerhook == NULL)
 		aprint_error("%s: WARNING: unable to establish power hook\n",
-			sc->sc_dev.dv_xname);
+			sc->sc_dev.dv_xname); */
+	if (!pnp_device_register(&sc->sc_dev, NULL, com_resume))
+		aprint_error_dev(&sc->sc_dev, "couldn't establish power handler\n");
 
 	SET(sc->sc_hwflags, COM_HW_DEV_OK);
 }
@@ -615,8 +617,8 @@ com_detach(struct device *self, int flag
 	int maj, mn;
 
 	/* kill the power hook */
-	if (sc->sc_powerhook != NULL)
-		powerhook_disestablish(sc->sc_powerhook);
+/*	if (sc->sc_powerhook != NULL)
+		powerhook_disestablish(sc->sc_powerhook); */
 
 	/* locate the major number */
 	maj = cdevsw_lookup_major(&com_cdevsw);
@@ -2464,24 +2466,13 @@ com_cleanup(void *arg)
 		CSR_WRITE_1(&sc->sc_regs, COM_REG_FIFO, 0);
 }
 
-void
-com_power(int why, void *arg)
+bool
+com_resume(device_t dv)
 {
-	struct com_softc *sc = arg;
+	struct com_softc *sc = device_private(dv);
 
 	mutex_spin_enter(&sc->sc_lock);
-	switch (why) {
-	case PWR_SUSPEND:
-	case PWR_STANDBY:
-		/* XXX should we do something to stop the device? */
-		break;
-	case PWR_RESUME:
-		com_loadchannelregs(sc);
-		break;
-	case PWR_SOFTSUSPEND:
-	case PWR_SOFTSTANDBY:
-	case PWR_SOFTRESUME:
-		break;
-	}
+	com_loadchannelregs(sc);
 	mutex_spin_exit(&sc->sc_lock);
+	return true;
 }
Index: dev/ic/comvar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/comvar.h,v
retrieving revision 1.55.6.1
diff -p -u -r1.55.6.1 comvar.h
--- dev/ic/comvar.h	26 Oct 2007 15:44:41 -0000	1.55.6.1
+++ dev/ic/comvar.h	24 Nov 2007 09:22:40 -0000
@@ -220,7 +220,7 @@ struct com_softc {
 #if NRND > 0 && defined(RND_COM)
 	rndsource_element_t  rnd_source;
 #endif
-	void			*sc_powerhook;	/* power management hook */
+/*	void			*sc_powerhook;	*//* power management hook */
 	kmutex_t		sc_lock;
 };
 
Index: dev/isa/midi_pcppi.c
===================================================================
RCS file: /cvsroot/src/sys/dev/isa/midi_pcppi.c,v
retrieving revision 1.15.22.1
diff -p -u -r1.15.22.1 midi_pcppi.c
--- dev/isa/midi_pcppi.c	26 Oct 2007 15:45:25 -0000	1.15.22.1
+++ dev/isa/midi_pcppi.c	24 Nov 2007 09:22:42 -0000
@@ -114,6 +114,9 @@ midi_pcppi_attach(parent, self, aux)
 
 	midisyn_attach(&sc->sc_mididev, ms);
 	midi_attach(&sc->sc_mididev, parent);
+
+	if (!pnp_device_register(self, NULL, NULL))
+		aprint_error_dev(self, "couldn't establish power handler\n");
 }
 
 void
Index: dev/mii/makphy.c
===================================================================
RCS file: /cvsroot/src/sys/dev/mii/makphy.c,v
retrieving revision 1.23
diff -p -u -r1.23 makphy.c
--- dev/mii/makphy.c	23 Feb 2007 03:03:10 -0000	1.23
+++ dev/mii/makphy.c	24 Nov 2007 09:22:44 -0000
@@ -165,6 +165,9 @@ makphyattach(struct device *parent, stru
 	else
 		mii_phy_add_media(sc);
 	aprint_normal("\n");
+
+	if (!pnp_device_register(self, NULL, NULL)) /* FIXME implement */
+		aprint_error_dev(self, "couldn't establish power handler\n");
 }
 
 static void
Index: dev/pad/pad.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pad/pad.c,v
retrieving revision 1.2.4.2
diff -p -u -r1.2.4.2 pad.c
--- dev/pad/pad.c	14 Nov 2007 19:04:26 -0000	1.2.4.2
+++ dev/pad/pad.c	24 Nov 2007 09:22:44 -0000
@@ -272,6 +272,9 @@ pad_attach(struct device *parent, struct
 	sc->sc_rpos = sc->sc_wpos = 0;
 	sc->sc_audiodev = (void *)audio_attach_mi(&pad_hw_if, sc, &sc->sc_dev);
 
+	if (!pnp_device_register(self, NULL, NULL))
+		aprint_error_dev(self, "couldn't establish power handler\n");
+
 	return;
 }
 
Index: dev/pci/if_wpi.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/if_wpi.c,v
retrieving revision 1.17.4.11
diff -p -u -r1.17.4.11 if_wpi.c
--- dev/pci/if_wpi.c	21 Nov 2007 21:55:30 -0000	1.17.4.11
+++ dev/pci/if_wpi.c	24 Nov 2007 09:22:49 -0000
@@ -2078,7 +2078,7 @@ wpi_read_eeprom(struct wpi_softc *sc)
 
 	/* read and print regulatory domain */
 	wpi_read_prom_data(sc, WPI_EEPROM_DOMAIN, domain, 4);
-	aprint_normal(", %.4s", domain);
+	aprint_normal(": domain %.4s", domain);
 
 	/* read and print MAC address */
 	wpi_read_prom_data(sc, WPI_EEPROM_MAC, ic->ic_myaddr, 6);
Index: dev/pci/pccbb.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/pccbb.c,v
retrieving revision 1.145.6.5
diff -p -u -r1.145.6.5 pccbb.c
--- dev/pci/pccbb.c	21 Nov 2007 21:55:35 -0000	1.145.6.5
+++ dev/pci/pccbb.c	24 Nov 2007 09:22:53 -0000
@@ -443,7 +443,7 @@ pccbbattach(struct device *parent, struc
 			    NULL)) {
 				printf("%s: can't map socket base address"
 				    " 0x%lx: io mode\n", sc->sc_dev.dv_xname,
-				    (unsigned long)sockbase);
+				    (unsigned long)sock_base);
 				/* give up... allocate reg space via rbus. */
 				pci_conf_write(pc, pa->pa_tag, PCI_SOCKBASE, 0);
 			} else

--------------070803000102010803080104--