Subject: kern/28360: usb ugen reads hang when talking to APC UPS
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <wolfgang@wsrcc.com>
List: netbsd-bugs
Date: 11/19/2004 20:55:03
>Number:         28360
>Category:       kern
>Synopsis:       usb ugen reads hang when talking to APC UPS
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Nov 19 20:55:02 +0000 2004
>Originator:     Wolfgang S. Rupprecht
>Release:        NetBSD 2.99.10
>Organization:
W S Rupprecht Computer Consulting, Fremont CA
>Environment:
	
	
System: NetBSD capsicum.wsrcc.com 2.99.10 NetBSD 2.99.10 (WSRCC_ATHLON) #15: Tue Nov 16 19:23:29 PST 2004 wolfgang@capsicum.wsrcc.com:/var/obj/netbsd/sys/arch/i386/compile/WSRCC_ATHLON i386
Architecture: i386
Machine: i386
>Description:

	The usb ugen driver will hang after a minute or two of talking
	to an "American Power Conversion Back-UPS RS 1500".
	Everything works fine before that time and apcupsd can read
	the UPS status and voltages etc.

	$ ps -axlww | egrep 'apc|PID'
	UID  PID PPID CPU PRI NI   VSZ   RSS WCHAN    STAT TT     TIME COMMAND
	  0  238    1   0  -6  0  2208  1028 usbsyn   Dsa  ??  0:00.18 /sbin/apcupsd --kill-on-powerfail 

	The process is unkillable (neg priority), but the hang can be 
	cleared by unplugging the usb cable and plugging it back in.

	A debug trace with the following turned on is available below.

	usbdebug 6
	ugendebug 6
	uhcidebug 6

	http://www.wsrcc.com/wolfgang/private/ups-hang-log3.txt.gz

>How-To-Repeat:
	
	compile and install apcupsd-3.10.16-test2 run with usb cable,
	usb protocol selected in the config file.  A version of
	apcupsd w. usb support that compiles on netbsd can be found
	here.  (I didn't do this port, but can't find the orignal site
	right now.)

	http://www.wsrcc.com/wolfgang/private/apcupsd-3.10.16-test2-wsr.tar.gz

cat << EOF > /etc/apcupsd/apcupsd.conf
UPSCABLE usb
UPSTYPE usb
LOCKFILE /var/spool/lock
ONBATTERYDELAY 6
BATTERYLEVEL 20
MINUTES 10
TIMEOUT 0
ANNOY 300
ANNOYDELAY 60
NOLOGON disable
KILLDELAY 0
NETSERVER on
NISIP 0.0.0.0
NISPORT 3551
EVENTSFILE /var/log/apcupsd.events
EVENTSFILEMAX 10
UPSCLASS standalone
UPSMODE disable
STATTIME 0
STATFILE /var/log/apcupsd.status
LOGSTATS off
DATATIME 0
EOF

	Kernel needs to be compiled without uhidev and children (uhid,
	ukbd, wsmouse etc).

	The above trace very clearly shows when the usb starts to
	hang.  Perhaps someone familiar with the USB can spot what is
	going wrong.  My inexperienced eye didn't spot any funny
	exchanges just before hang.

>Fix:
	

>Unformatted: