From owner-freebsd-current@FreeBSD.ORG Tue Sep 27 10:12:45 2011 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 528321065676; Tue, 27 Sep 2011 10:12:45 +0000 (UTC) (envelope-from gavin.atkinson@ury.york.ac.uk) Received: from ixe-mta-27.emailfiltering.com (ixe-mta-27-tx.emailfiltering.com [194.116.199.158]) by mx1.freebsd.org (Postfix) with ESMTP id 8BDC78FC15; Tue, 27 Sep 2011 10:12:43 +0000 (UTC) Received: from mail-gw12.york.ac.uk ([144.32.129.162]) by ixe-mta-27.emailfiltering.com with emfmta (version 4.8.3.54) by TLS id 1300664618 for jhb@freebsd.org;fb2407b1b8ecf27c; Tue, 27 Sep 2011 11:12:42 +0100 Received: from buffy-128.york.ac.uk ([144.32.128.160]:36632) by mail-gw12.york.ac.uk with esmtpsa (SSL3.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1R8UeX-0002DS-SO; Tue, 27 Sep 2011 11:12:41 +0100 X-Authenticated-User: ga9 From: Gavin Atkinson To: John Baldwin In-Reply-To: <201109260930.39309.jhb@freebsd.org> References: <75E1A2A7D185F841A975979B0906BBA67BCCAB7609@AVEXMB1.qlogic.org> <201109222007.19182.hselasky@c2i.net> <1316791266.39972.3.camel@buffy.york.ac.uk> <201109260930.39309.jhb@freebsd.org> Content-Type: text/plain; charset="ASCII" Date: Tue, 27 Sep 2011 11:12:41 +0100 Message-ID: <1317118361.95805.7.camel@buffy.york.ac.uk> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit Cc: freebsd-current@freebsd.org, freebsd-drivers@freebsd.org, Hans Petter Selasky Subject: Re: Choosing between DELAY(useconds) and pause() X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Sep 2011 10:12:45 -0000 On Mon, 2011-09-26 at 09:30 -0400, John Baldwin wrote: > On Friday, September 23, 2011 11:21:06 am Gavin Atkinson wrote: > > On Thu, 2011-09-22 at 20:07 +0200, Hans Petter Selasky wrote: > > > On Thursday 22 September 2011 19:55:23 David Somayajulu wrote: > > > > It appears that the pause() function cannot be used in driver functions > > > > which are invoked early in the boot process. Is there is a kernel api > > > > which a device driver can use to determine whether to use pause() or > > > > DELAY(), for delays which are say greater than 10hz - may be even 1 hz ? > > > > > > Maybe you want to use something like this: > > > > > > if (cold) > > > DELAY() > > > else > > > pause() > > > > > > In your code. > > > > Note that this still shouldn't be done in your suspend/resume paths, as > > "cold" isn't set there, however there also appears to be no guarantee > > that pause() will ever return (as you could be running after the timer > > has been suspended, or before it resumes). > > > > I'm not sure what the correct answer is for suspend/resume code. > > Hmmm, on x86 the timers are explicitly shutdown after the DEVICE_SUSPEND() > pass over the tree and re-enabled before DEVICE_RESUME(). Perhaps this has > changed in HEAD though with the eventtimers stuff. I do think it is best > however, to use DELAY() in the suspend/resume path always regardless. I don't think head is any different from stable/8 in this respect - the same hack patch that fixes suspend/resume for me on head also fixes it on stable/8 (the patch basically fakes "cold" during USB suspend/resume). See my email to -usb a few months ago: http://docs.FreeBSD.org/cgi/mid.cgi?alpine.LNX.2.00.1106041548370.26975 I'd really like some guidance as to the correct solution to this, I have four separate laptops which fail out of the box on 8 and 9, but suspend/resume perfectly with this hack. Thanks, Gavin