Subject: kern/11714: OHCI card causes resume failure after APM suspend
To: None <gnats-bugs@gnats.netbsd.org>
From: ITOH Yasufumi <itohy@netbsd.org>
List: netbsd-bugs
Date: 12/12/2000 17:35:13
>Number:         11714
>Category:       kern
>Synopsis:       OHCI card causes resume failure after APM suspend
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Dec 12 17:35:01 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     ITOH Yasufumi
>Release:        1.5L (Dec. 8, 2000)
>Organization:
>Environment:
System: NetBSD pino.my.domain 1.5L NetBSD 1.5L (PINO) #247: Sun Dec 10 14:13:46 JST 2000 itohy@pino.my.domain:/w/src/sys/arch/i386/compile/PINO i386
Architecture: i386
Machine: i386

machine: Toshiba Libretto 100
kernel dmesg:
	:
cbb0 at pci0 dev 19 function 0: Toshiba ToPIC95B CardBus-PCI Bridge (rev. 0x07)
cbb1 at pci0 dev 19 function 1: Toshiba ToPIC95B CardBus-PCI Bridge (rev. 0x07)
cbb0: interrupting at irq 11
cbb0: cacheline 0x0 lattimer 0x0
cbb0: bhlc 0x820000 lscp 0x141400
cardslot0 at cbb0 slot 0 flags 0
cardbus0 at cardslot0: bus 20 device 0 cacheline 0x0, lattimer 0x0
pcmcia0 at cardslot0
cbb1: interrupting at irq 11
cbb1: cacheline 0x0 lattimer 0x0
cbb1: bhlc 0x820000 lscp 0x151500
cardslot1 at cbb1 slot 1 flags 0
cardbus1 at cardslot1: bus 21 device 0 cacheline 0x0, lattimer 0x0
pcmcia1 at cardslot1
	:
ohci0 at cardbus1 dev 0 function 0: Opti RM861HA (rev. 0x10)
ohci0: interrupting at 11
ohci0: OHCI version 1.0, legacy support
usb0 at ohci0: USB revision 1.0
uhub0 at usb0
uhub0: Opti OHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub0: 2 ports with 2 removable, self powered
ums0 at uhub0 port 1 configuration 1 interface 0
ums0: vendor 0x05e3 USB Mouse, rev 1.00/1.01, addr 2, iclass 3/1
ums0: 3 buttons and Z dir.
wsmouse1 at ums0 mux 0

>Description:
	If you suspend the system while OHCI CardBus card is present,
	APM suspend/resume will always fails.

>How-To-Repeat:
	 1. Insert OHCI USB card into a CardBus slot.
	 2. suspend the system
		# zzz
	 3. resume the system, and you will feel sorrow
	    at seeing resuming failed.

>Fix:
	Implement suspend/resume of OHCI.

	The following change works around the APM suspend/resume failure,
	but the device will not work after suspend/resume cycle.

diff -uF^[a-zA-Z_][a-z 	A-Z0-9_]*([^;]*$ sys/dev/usb/ohci.c.orig sys/dev/usb/ohci.c
--- sys/dev/usb/ohci.c.orig	Sat Nov 11 16:32:47 2000
+++ sys/dev/usb/ohci.c	Sun Dec 10 18:14:22 2000
@@ -939,12 +939,32 @@ ohci_shutdown(void *v)
 void
 ohci_power(int why, void *v)
 {
-#ifdef OHCI_DEBUG
+#if 1
 	ohci_softc_t *sc = v;
+	int s;
 
+	s = splusb();
+#endif
+#ifdef OHCI_DEBUG
 	DPRINTF(("ohci_power: sc=%p, why=%d\n", sc, why));
 	/* XXX should suspend/resume */
 	ohci_dumpregs(sc);
+#endif
+#if 1
+	switch (why) {
+	case PWR_SUSPEND:
+	case PWR_STANDBY:
+		OWRITE4(sc, OHCI_CONTROL, OHCI_HCFS_SUSPEND);
+		break;
+	case PWR_RESUME:
+		OWRITE4(sc, OHCI_CONTROL, OHCI_HCFS_RESUME);
+		break;
+	case PWR_SOFTSUSPEND:
+	case PWR_SOFTSTANDBY:
+	case PWR_SOFTRESUME:
+		break;
+	}
+	splx(s);
 #endif
 }
 
>Release-Note:
>Audit-Trail:
>Unformatted: