From pa4dan@Vitsch.net  Fri Oct 22 12:42:38 2004
Return-Path: <pa4dan@Vitsch.net>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id EAD3C16A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 22 Oct 2004 12:42:38 +0000 (GMT)
Received: from amsfep18-int.chello.nl (amsfep18-int.chello.nl [213.46.243.13])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 6CF0A43D2F
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 22 Oct 2004 12:42:37 +0000 (GMT)
	(envelope-from pa4dan@Vitsch.net)
Received: from Vitsch.net ([212.187.78.35]) by amsfep18-int.chello.nl
          (InterMail vM.6.01.03.04 201-2131-111-106-20040729) with ESMTP
          id <20041022124235.UCN3605.amsfep18-int.chello.nl@Vitsch.net>
          for <FreeBSD-gnats-submit@freebsd.org>;
          Fri, 22 Oct 2004 14:42:35 +0200
Received: (from pa4dan@localhost)
	by Vitsch.net (8.12.3p2/8.11.3) id i9MCgXnF078625;
	Fri, 22 Oct 2004 14:42:33 +0200 (CEST)
	(envelope-from pa4dan)
Message-Id: <200410221242.i9MCgXnF078625@Vitsch.net>
Date: Fri, 22 Oct 2004 14:42:33 +0200 (CEST)
From: "Daan Vreeken [PA4DAN]" <Danovitsch@Vitsch.net>
Reply-To: "Daan Vreeken [PA4DAN]" <Danovitsch@Vitsch.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: UHCI driver fails to detect (certain) interrupts on boot
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         73000
>Category:       kern
>Synopsis:       UHCI driver fails to detect (certain) interrupts on boot
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    jhb
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Oct 22 12:50:27 GMT 2004
>Closed-Date:    Fri Jan 07 20:26:47 GMT 2005
>Last-Modified:  Fri Jan 07 20:26:47 GMT 2005
>Originator:     Daan Vreeken [PA4DAN]
>Release:        FreeBSD 5.1-RELEASE i386
>Organization:
>Environment:
System: FreeBSD Racebeest.Danovitsch.LAN 5.1-RELEASE FreeBSD 5.1-RELEASE #18: Thu Oct 7 11:39:42 CEST 2004 root@Racebeest.Danovitsch.LAN:/usr/src.5.1/sys/i386/compile/Laptop i386


	
>Description:
	During boot the UHCI driver uses the routine uhci_waitintr() to
detect interrupts (since interrupts are disabled at that point). The routine
checks the UHCI interrupt status register and if it detects an interrupt
condition it manually calls uhci_intr1() to handle the interrupt. The fault
is that uhci_waitintr() only checks for UHCI_STS_USBINTR and not all other
interrupt flags (like UHCI_STS_USBEI). 
	This causes interrupts to be ignored (if UHCI_STS_USBINTR isn't
set). Having an axe(4) USB ethernet adapter plugged in during boot causes
the system to freeze (for a very long period of time) during initialisation
of the device. Eventually uhci_waitintr() will timeout, but that can take up
to minutes per request. When using a USB WLAN device with my own driver (
http://vitsch.net/bsd/atuwi ) causes the system to stall for hours at boot,
since the driver does about 100 USB requests during attach.
	
>How-To-Repeat:
	Plugin an axe(4) or atuwi device into a system with a UHCI
controller (not sure if all UHCI controllers exhibit the same behaviour) and
boot the system. Booting should take minutes up to hours.
	
>Fix:
	Apply the following patch (to -current). The patch makes
uhci_waitintr() and uhci_poll() aware of all interrupt flags in the
interrupt status register instead of just UHCI_STS_USBINT.
	

--- uhci-waitintr-2004-10-22.diff begins here ---
--- uhci.c.org	Fri Oct 22 12:16:29 2004
+++ uhci.c	Fri Oct 22 12:21:11 2004
@@ -1552,7 +1552,7 @@
 	for (; timo >= 0; timo--) {
 		usb_delay_ms(&sc->sc_bus, 1);
 		DPRINTFN(20,("uhci_waitintr: 0x%04x\n", UREAD2(sc, UHCI_STS)));
-		if (UREAD2(sc, UHCI_STS) & UHCI_STS_USBINT)
+		if (UREAD2(sc, UHCI_STS) & UHCI_STS_ALLINTRS)
 			uhci_intr1(sc);
 		if (xfer->status != USBD_IN_PROGRESS)
 			return;
@@ -1576,7 +1576,7 @@
 {
 	uhci_softc_t *sc = (uhci_softc_t *)bus;
 
-	if (UREAD2(sc, UHCI_STS) & UHCI_STS_USBINT)
+	if (UREAD2(sc, UHCI_STS) & UHCI_STS_ALLINTRS)
 		uhci_intr1(sc);
 }
 
--- uhci-waitintr-2004-10-22.diff ends here ---

>Release-Note:
>Audit-Trail:

From: Anish Mistry <mistry.7@osu.edu>
To: freebsd-gnats-submit@FreeBSD.org, Danovitsch@Vitsch.net
Cc:  
Subject: Re: kern/73000: UHCI driver fails to detect (certain) interrupts on boot
Date: Wed, 27 Oct 2004 23:15:07 -0400

 --nextPart1420588.Id3jSuYAC9
 Content-Type: text/plain;
   charset="us-ascii"
 Content-Transfer-Encoding: quoted-printable
 Content-Disposition: inline
 
 uhci0: <VIA 83C572 USB controller> port 0xd800-0xd81f irq 3 at device 17.2 =
 on=20
 pci0
 uhci0: [GIANT-LOCKED]
 usb0: <VIA 83C572 USB controller> on uhci0
 usb0: USB revision 1.0
 uhub0: VIA UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
 uhub0: 2 ports with 2 removable, self powered
 uhub1: Texas Instruments TUSB2046 hub, class 9/0, rev 1.10/1.25, addr 2
 uhub1: 4 ports with 4 removable, self powered
 uhci1: <VIA 83C572 USB controller> port 0xdc00-0xdc1f irq 3 at device 17.3 =
 on=20
 pci0
 uhci1: [GIANT-LOCKED]
 usb1: <VIA 83C572 USB controller> on uhci1
 usb1: USB revision 1.0
 uhub2: VIA UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
 uhub2: 2 ports with 2 removable, self powered
 uhci2: <VIA 83C572 USB controller> port 0xe000-0xe01f irq 3 at device 17.4 =
 on=20
 pci0
 uhci2: [GIANT-LOCKED]
 usb2: <VIA 83C572 USB controller> on uhci2
 usb2: USB revision 1.0
 uhub3: VIA UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
 uhub3: 2 ports with 2 removable, self powered
 
 This patch causes problems with my system and plugging in usb devices, they=
 =20
 are most of the time not detected.
 
 =2D-=20
 Anish Mistry
 
 --nextPart1420588.Id3jSuYAC9
 Content-Type: application/pgp-signature
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.2.6 (FreeBSD)
 
 iD8DBQBBgGRRxqA5ziudZT0RAhU5AJ9QQp+a9IS/c+Qfp/Bjx2AB5rMylQCgj7G2
 Mia76cF0WgHhHJtA84vOoJg=
 =T42P
 -----END PGP SIGNATURE-----
 
 --nextPart1420588.Id3jSuYAC9--

From: Anish Mistry <mistry.7@osu.edu>
To: freebsd-gnats-submit@freebsd.org, Danovitsch@vitsch.net
Cc:  
Subject: Re: kern/73000: UHCI driver fails to detect (certain) interrupts on boot
Date: Wed, 27 Oct 2004 23:49:46 -0400

 --nextPart3843205.PEoKmibn7b
 Content-Type: text/plain;
   charset="us-ascii"
 Content-Transfer-Encoding: quoted-printable
 Content-Disposition: inline
 
 Removing the second change seem to not cause mine to break.  Does this stil=
 l=20
 fix the problem for you?
 
 =2D-- uhci.c.orig Wed Oct 27 23:02:43 2004
 +++ uhci.c Wed Oct 27 23:43:40 2004
 @@ -1552,7 +1552,7 @@
   for (; timo >=3D 0; timo--) {
    usb_delay_ms(&sc->sc_bus, 1);
    DPRINTFN(20,("uhci_waitintr: 0x%04x\n", UREAD2(sc, UHCI_STS)));
 =2D  if (UREAD2(sc, UHCI_STS) & UHCI_STS_USBINT)
 +  if (UREAD2(sc, UHCI_STS) & UHCI_STS_ALLINTRS)
     uhci_intr1(sc);
    if (xfer->status !=3D USBD_IN_PROGRESS)
     return;
 
 =2D-=20
 Anish Mistry
 
 --nextPart3843205.PEoKmibn7b
 Content-Type: application/pgp-signature
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.2.6 (FreeBSD)
 
 iD8DBQBBgGxlxqA5ziudZT0RAlbRAJ9RIEuAmLDab2kGEEy+GGEwdBQBugCg1nkI
 DYKAQlpCZ8XRVRuSmzSiZKI=
 =u7Le
 -----END PGP SIGNATURE-----
 
 --nextPart3843205.PEoKmibn7b--
State-Changed-From-To: open->patched 
State-Changed-By: jhb 
State-Changed-When: Thu Oct 28 20:24:58 GMT 2004 
State-Changed-Why:  
Fix committed to current.  Will be MFC'd after 5.3 is released.  Thanks! 


Responsible-Changed-From-To: freebsd-bugs->jhb 
Responsible-Changed-By: jhb 
Responsible-Changed-When: Thu Oct 28 20:24:58 GMT 2004 
Responsible-Changed-Why:  
Fix committed to current.  Will be MFC'd after 5.3 is released.  Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=73000 

From: Anish Mistry <mistry.7@osu.edu>
To: freebsd-gnats-submit@freebsd.org
Cc:  
Subject: Re: kern/73000: UHCI driver fails to detect (certain) interrupts on boot
Date: Fri, 29 Oct 2004 14:14:33 -0400

 --nextPart1806928.V1xjxehozl
 Content-Type: text/plain;
   charset="iso-8859-1"
 Content-Transfer-Encoding: quoted-printable
 Content-Disposition: inline
 
 Well I guess it must have been some freak occurance since I tried the=20
 original patch again today and everything seems to be working.
 =2D-=20
 Anish Mistry
 
 --nextPart1806928.V1xjxehozl
 Content-Type: application/pgp-signature
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.2.6 (FreeBSD)
 
 iD8DBQBBgoiTxqA5ziudZT0RAonLAJwOrs42shLmwXQNj/ipHJKCitzg1wCbBvXE
 cN9+Dx2kh0zy9vc2SJAFOGE=
 =S5lG
 -----END PGP SIGNATURE-----
 
 --nextPart1806928.V1xjxehozl--
State-Changed-From-To: patched->closed 
State-Changed-By: jhb 
State-Changed-When: Fri Jan 7 20:26:19 GMT 2005 
State-Changed-Why:  
Fix was MFC'd to RELENG_5 by iedowse and will be in 5.4. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=73000 
>Unformatted:
