From owner-freebsd-usb@FreeBSD.ORG Mon Jan 12 18:28:31 2009 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DF54C1065780 for ; Mon, 12 Jan 2009 18:28:31 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe14.swipnet.se [212.247.155.161]) by mx1.freebsd.org (Postfix) with ESMTP id 72F298FC19 for ; Mon, 12 Jan 2009 18:28:31 +0000 (UTC) (envelope-from hselasky@c2i.net) X-Cloudmark-Score: 0.000000 [] X-Cloudmark-Analysis: v=1.0 c=1 a=Ss_yWbxXmtgA:10 a=ON4qaVFYhWoA:10 a=nklthdr5v5AUSfVrlghuJA==:17 a=h6OiMtqcTUh4KVEAMcoA:9 a=RCKUs9xIWDQmXCTxykU2NZfIVTEA:4 a=LY0hPdMaydYA:10 Received: from [62.113.132.62] (account mc467741@c2i.net [62.113.132.62] verified) by mailfe14.swip.net (CommuniGate Pro SMTP 5.2.6) with ESMTPA id 436526018; Mon, 12 Jan 2009 19:28:30 +0100 From: Hans Petter Selasky To: freebsd-usb@freebsd.org Date: Mon, 12 Jan 2009 19:30:50 +0100 User-Agent: KMail/1.9.7 References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200901121930.51916.hselasky@c2i.net> Cc: Subject: Re: [ prevent ehci_takecontroller from looping at infinite ] X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Jan 2009 18:28:32 -0000 On Monday 12 January 2009, lementec fabien wrote: > Hi, > > On an Acer Aspire 5500, freebsd is hanging in > usb/ehci_pci in the ehci_takecontroller function. > The device pci conf space reads invalid values > 0xffffffff, making the function looping at infinite, > thus never entering ehci_init. > > I dont know if the problem does not come from > earlier, but I did the following patch: Hi, The EHCI PCI is looping infinitely in USB1 because "int eecp" is a signed number. Sign-extension happens during the shift inside XXX_NEXT(), and it will actually loop in all cases where "cparams & 0x80000000" is non-zero! Try making the eecp variable "uint32_t". This is not a problem with USB2. Where "eecp" is already unsigned. --HPS > > --- orig/sys/dev/usb/ehci_pci.c 2009-01-11 06:14:12.000000000 +0100 > +++ new/sys/dev/usb/ehci_pci.c 2009-01-11 06:15:14.000000000 +0100 > @@ -549,6 +549,10 @@ > > cparams = EREAD4(sc, EHCI_HCCPARAMS); > > + /* prevent from looping ad infinite. ehci_init will fail. */ > + if (cparams == 0xffffffff) > + return ; > + > /* Synchronise with the BIOS if it owns the controller. */ > for (eecp = EHCI_HCC_EECP(cparams); eecp != 0; > eecp = EHCI_EECP_NEXT(eec)) { > @@ -584,6 +588,9 @@ > int eecp; > > cparams = EREAD4(sc, EHCI_HCCPARAMS); > + if (cparams == 0xffffffff) > + return ; > + > for (eecp = EHCI_HCC_EECP(cparams); eecp >= 0x40; > eecp = EHCI_EECP_NEXT(eec)) { > eec = pci_read_config(self, eecp, 4); > > I hop it helps, > > Fabien.