From owner-freebsd-hackers@FreeBSD.ORG Tue Nov 1 19:22:58 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EA7A216A41F for ; Tue, 1 Nov 2005 19:22:58 +0000 (GMT) (envelope-from dinesh@alphaque.com) Received: from ns2.alphaque.com (ns2.alphaque.com [202.75.47.153]) by mx1.FreeBSD.org (Postfix) with SMTP id ADAAD43D49 for ; Tue, 1 Nov 2005 19:22:57 +0000 (GMT) (envelope-from dinesh@alphaque.com) Received: (qmail 64478 invoked by uid 0); 1 Nov 2005 19:22:55 -0000 Received: from lucifer.net-gw.com (HELO prophet.alphaque.com) (202.75.47.153) by lucifer.net-gw.com with SMTP; 1 Nov 2005 19:22:55 -0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) by prophet.alphaque.com (8.13.4/8.13.4) with ESMTP id jA1JMapN000633; Wed, 2 Nov 2005 03:22:36 +0800 (MYT) (envelope-from dinesh@alphaque.com) Message-ID: <4367C07C.1040900@alphaque.com> Date: Wed, 02 Nov 2005 03:22:36 +0800 From: Dinesh Nair User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.8b) Gecko/20050915 MIME-Version: 1.0 To: Julian Elischer References: <4360B8EE.4070605@alphaque.com> <4360DD7B.20900@samsco.org> <4361044B.50807@alphaque.com> <20051027.205250.55834228.imp@bsdimp.com> <4361E3E0.4090409@alphaque.com> <43676121.4030801@alphaque.com> <436791ED.8010808@samsco.org> <4367AA8D.3060506@alphaque.com> <4367BBDB.7020005@elischer.org> In-Reply-To: <4367BBDB.7020005@elischer.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@freebsd.org, Scott Long Subject: Re: locking in a device driver X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2005 19:22:59 -0000 On 11/02/05 03:02 Julian Elischer said the following: > drops to splzero or similar,.. > woken process called, > starts manipulating "another buffer" > collides with next interrupt. that makes a lot of sense, i'll try with using splxxx() in the pseudo driver, to block out the real driver. it's currently splhigh() due to INTR_TYPE_MISC being used, but i guess i could change this to INTR_TYPE_NET or INTR_TYPE_TTY. what would be good for a telecommunications line card which is time sensitive and interrupts at a constant 1000Hz ? > it needs to call splxxx() while it is doing it.. > I would suggest having two buffers and swapping them under splxxx() so that > the one that the driver is accessing is not the one you are draining. > that way teh splxxx() levle needs to only be held for the small time > you are doing the swap. the first buffer is actually the buffer into which DMA reads/writes are done. what i referred to as "another buffer" is in fact a ring of buffers. the real driver writes into the top of the ring, and increments the top ring pointer. the pseudo driver reads from the bottom of the ring and increments the bottom ring pointer. buf1 buf2 buf3 buf4 buf5 buf6 buf7 buf8 ^ ^ | | | +-- top ring pointer, incremented as real driver reads | from device +-- bottom ring pointer, incremented as userland reads from pseudo > not locks, but spl, > and only step 8 needs to be changed because all teh rest are already > done at high spl. wouldnt a lockmgr() around the access to these ring buffers help since we're locking access to data and not necessarily execution ? -- Regards, /\_/\ "All dogs go to heaven." dinesh@alphaque.com (0 0) http://www.alphaque.com/ +==========================----oOO--(_)--OOo----==========================+ | for a in past present future; do | | for b in clients employers associates relatives neighbours pets; do | | echo "The opinions here in no way reflect the opinions of my $a $b." | | done; done | +=========================================================================+