From owner-freebsd-current@FreeBSD.ORG Mon Sep 26 14:00:59 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 EDDE4106564A; Mon, 26 Sep 2011 14:00:59 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id C3FD68FC14; Mon, 26 Sep 2011 14:00:59 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 76C9C46B0C; Mon, 26 Sep 2011 10:00:59 -0400 (EDT) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 1BBB68A03C; Mon, 26 Sep 2011 10:00:59 -0400 (EDT) From: John Baldwin To: freebsd-drivers@freebsd.org Date: Mon, 26 Sep 2011 09:30:39 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110617; KDE/4.5.5; amd64; ; ) References: <75E1A2A7D185F841A975979B0906BBA67BCCAB7609@AVEXMB1.qlogic.org> <201109222007.19182.hselasky@c2i.net> <1316791266.39972.3.camel@buffy.york.ac.uk> In-Reply-To: <1316791266.39972.3.camel@buffy.york.ac.uk> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201109260930.39309.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Mon, 26 Sep 2011 10:00:59 -0400 (EDT) Cc: freebsd-current@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: Mon, 26 Sep 2011 14:01:00 -0000 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. -- John Baldwin