From owner-freebsd-drivers@FreeBSD.ORG Tue Sep 27 18:05:01 2011 Return-Path: Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B425A106564A for ; Tue, 27 Sep 2011 18:05:01 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 4838B8FC13 for ; Tue, 27 Sep 2011 18:05:00 +0000 (UTC) Received: from alf.home (alf.kiev.zoral.com.ua [10.1.1.177]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id p8RHcgOf097757 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 27 Sep 2011 20:38:42 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from alf.home (kostik@localhost [127.0.0.1]) by alf.home (8.14.5/8.14.5) with ESMTP id p8RHcgSG044551; Tue, 27 Sep 2011 20:38:42 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by alf.home (8.14.5/8.14.5/Submit) id p8RHcgsj044550; Tue, 27 Sep 2011 20:38:42 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: alf.home: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 27 Sep 2011 20:38:42 +0300 From: Kostik Belousov To: Julian Elischer Message-ID: <20110927173842.GR1511@deviant.kiev.zoral.com.ua> References: <75E1A2A7D185F841A975979B0906BBA67BCCAB7609@AVEXMB1.qlogic.org> <201109222007.19182.hselasky@c2i.net> <1316791266.39972.3.camel@buffy.york.ac.uk> <201109260930.39309.jhb@freebsd.org> <1317118361.95805.7.camel@buffy.york.ac.uk> <4E81FC50.5040409@freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="EJCnrJiDxBM3d8Vu" Content-Disposition: inline In-Reply-To: <4E81FC50.5040409@freebsd.org> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-3.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: freebsd-current@freebsd.org, freebsd-drivers@freebsd.org, Gavin Atkinson , Hans Petter Selasky Subject: Re: Choosing between DELAY(useconds) and pause() X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Sep 2011 18:05:01 -0000 --EJCnrJiDxBM3d8Vu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Sep 27, 2011 at 10:39:44AM -0600, Julian Elischer wrote: > On 9/27/11 4:12 AM, Gavin Atkinson wrote: > >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 functi= ons > >>>>>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=20 > >>>>>? > >>>>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_SUSPEN= D() > >>pass over the tree and re-enabled before DEVICE_RESUME(). Perhaps this= =20 > >>has > >>changed in HEAD though with the eventtimers stuff. I do think it is be= st > >>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. >=20 > code for timers should have a generally readable state that says if=20 > they are useable or not, and we should test that instead of 'cold' I think that this should be encapsulated into the usable function, instead of being directly exposed to the driver authors. With the my lack of imagination, I propose driver_delay() that would do if (cold) ... inside. --EJCnrJiDxBM3d8Vu Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (FreeBSD) iEYEARECAAYFAk6CCiEACgkQC3+MBN1Mb4h2RgCgn+jfgGZjnO4VLUghH9AcKaOt J0cAoILtHFJtf80Lnbw10OhrPGTDI2i7 =OyCZ -----END PGP SIGNATURE----- --EJCnrJiDxBM3d8Vu--