From owner-freebsd-usb@FreeBSD.ORG Fri Aug 30 10:11:55 2013 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 58275CC1; Fri, 30 Aug 2013 10:11:55 +0000 (UTC) (envelope-from hps@bitfrost.no) Received: from mta.bitpro.no (mta.bitpro.no [92.42.64.202]) by mx1.freebsd.org (Postfix) with ESMTP id D41E32814; Fri, 30 Aug 2013 10:11:54 +0000 (UTC) Received: from mail.lockless.no (mail.lockless.no [46.29.221.38]) by mta.bitpro.no (Postfix) with ESMTP id BC84D7A234; Fri, 30 Aug 2013 12:11:52 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail.lockless.no (Postfix) with ESMTP id B4FAB8F503B; Fri, 30 Aug 2013 12:12:05 +0200 (CEST) X-Virus-Scanned: by amavisd-new-2.6.4 (20090625) (Debian) at lockless.no Received: from mail.lockless.no ([127.0.0.1]) by localhost (mail.lockless.no [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pejz1jwiK1cK; Fri, 30 Aug 2013 12:12:04 +0200 (CEST) Received: from laptop015.home.selasky.org (cm-176.74.213.204.customer.telag.net [176.74.213.204]) by mail.lockless.no (Postfix) with ESMTPSA id C4E7B8F503A; Fri, 30 Aug 2013 12:12:04 +0200 (CEST) Message-ID: <52207030.8050107@bitfrost.no> Date: Fri, 30 Aug 2013 12:13:04 +0200 From: Hans Petter Selasky Organization: Bitfrost A/S User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:17.0) Gecko/20130522 Thunderbird/17.0.6 MIME-Version: 1.0 To: "Lundberg, Johannes" Subject: Re: xhci broken on 10-CURRENT and 2013 MacBook Air? References: <521B9CD7.8010902@bitfrost.no> <521C6C26.7050207@bitfrost.no> <52203EC9.4060808@bitfrost.no> In-Reply-To: Content-Type: multipart/mixed; boundary="------------070205030908040509070208" Cc: FreeBSD Current , "freebsd-usb@freebsd.org" X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Aug 2013 10:11:55 -0000 This is a multi-part message in MIME format. --------------070205030908040509070208 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 08/30/13 11:35, Lundberg, Johannes wrote: > Hi Hans > > I tried the patch and the result is the same. However, I found the command > that causes the freeze. Also, it is not always it freezes but maybe 9/10 > reboots or more frequently. > > At the end of the function xhci_start_controller(..) there is a for loop: > > 487 for (i = 0; i != 100; i++) { > 488 usb_pause_mtx(NULL, hz / 100); > 489 temp = XREAD4(sc, oper, XHCI_USBSTS) & XHCI_STS_HCH; > 490 if (!temp) > 491 break; > 492 } > > and it freezes at usb_pause_mtx(...) > value of i is 0 > value of hz is 1000 Hi, Can you try the attached patch? I think this is a problem inside DELAY(). Maybe you have to select another timing source for DELAY(), mav @ CC'ed? --HPS --------------070205030908040509070208 Content-Type: text/x-patch; name="pause_fix.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pause_fix.diff" === sys/kern/kern_synch.c ================================================================== --- sys/kern/kern_synch.c (revision 254832) +++ sys/kern/kern_synch.c (local) @@ -356,11 +356,8 @@ int pause_sbt(const char *wmesg, sbintime_t sbt, sbintime_t pr, int flags) { - int sbt_sec; + KASSERT(sbt >= 0, ("pause: timeout must be >= 0")); - sbt_sec = sbintime_getsec(sbt); - KASSERT(sbt_sec >= 0, ("pause: timo must be >= 0")); - /* silently convert invalid timeouts */ if (sbt == 0) sbt = tick_sbt; @@ -370,11 +367,14 @@ * We delay one second at a time to avoid overflowing the * system specific DELAY() function(s): */ - while (sbt_sec > 0) { + while (sbt >= SBT_1S) { DELAY(1000000); - sbt_sec--; + sbt -= SBT_1S; } - DELAY((sbt & 0xffffffff) / SBT_1US); + /* Do the delay remainder */ + sbt /= SBT_1US; + if (sbt != 0) + DELAY(sbt); return (0); } return (_sleep(&pause_wchan[curcpu], NULL, 0, wmesg, sbt, pr, flags)); --------------070205030908040509070208--