From owner-freebsd-arch@FreeBSD.ORG Sat Jun 28 09:32:16 2003 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 15D4937B401; Sat, 28 Jun 2003 09:32:16 -0700 (PDT) Received: from magic.adaptec.com (magic-mail.adaptec.com [208.236.45.100]) by mx1.FreeBSD.org (Postfix) with ESMTP id 84AD443FB1; Sat, 28 Jun 2003 09:32:15 -0700 (PDT) (envelope-from scottl@freebsd.org) Received: from redfish.adaptec.com (redfish.adaptec.com [162.62.50.11]) by magic.adaptec.com (8.11.6/8.11.6) with ESMTP id h5SGVF818914; Sat, 28 Jun 2003 09:31:15 -0700 Received: from freebsd.org (hollin.btc.adaptec.com [10.100.253.56]) by redfish.adaptec.com (8.8.8p2+Sun/8.8.8) with ESMTP id JAA15203; Sat, 28 Jun 2003 09:32:05 -0700 (PDT) Message-ID: <3EFDC2EF.1060807@freebsd.org> Date: Sat, 28 Jun 2003 10:31:43 -0600 From: Scott Long User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.3) Gecko/20030425 X-Accept-Language: en-us, en MIME-Version: 1.0 To: John Baldwin References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit cc: "Justin T. Gibbs" cc: freebsd-arch@freebsd.org Subject: Re: API change for bus_dma X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Jun 2003 16:32:16 -0000 John Baldwin wrote: > Using this approach is more flexible in case there is a driver > that uses a sx lock or a (not yet implemented) reader-writer lock > or a critical section, or whatever. This just means that the > callback uses a wrapper function but that really isn't that hard to > do and there are other cases (callouts in general) that need this. > To me this seems to be adding a special case to the API that won't > work for all situations anyways. I also don't see wrapper functions > as being all that hard. > Ok, after many semi-private discussions, how about this: 1) New flag, BUS_DMA_INSWI, to signal that the caller is busdma_swi(). 2) Remove callback_mtx and replace it with callback2, a function pointer that wraps the callback with driver-dependent locking. This makes thing more flexible for alternate locking strategies. 3) Move vm_swi to be INTR_MPSAFE. On every single arch, vm_swi only exists to call busdma_swi(). This should not preclude other tasks from being added to this SWI as long as appropriate locking is done. 4) Have busdma_swi() check that callback2==NULL. If it does, grab Giant before calling bus_dmamap_load(). If it doesn't, call bus_dmamap_load() with callback2 instead of the original callback. 5) bus_dmamap_load() checks BUS_DMA_INSWI==0 before overwriting the callback and callback_args fields of the map. It will blindly call 'callback' and rely on the caller (either the driver or busdma_swi) giving it the right pointer. Scott