From owner-freebsd-hackers@FreeBSD.ORG Tue Oct 25 13:16:03 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 B721016A41F for ; Tue, 25 Oct 2005 13:16:03 +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 5ABB843D49 for ; Tue, 25 Oct 2005 13:16:01 +0000 (GMT) (envelope-from dinesh@alphaque.com) Received: (qmail 61099 invoked by uid 0); 25 Oct 2005 13:15:58 -0000 Received: from lucifer.net-gw.com (HELO prophet.alphaque.com) (202.75.47.153) by lucifer.net-gw.com with SMTP; 25 Oct 2005 13:15:58 -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 j9PDFlP2024687 for ; Tue, 25 Oct 2005 21:15:47 +0800 (MYT) (envelope-from dinesh@alphaque.com) Message-ID: <435E3003.4050609@alphaque.com> Date: Tue, 25 Oct 2005 21:15:47 +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: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: correct use of bus_dmamap_sync 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, 25 Oct 2005 13:16:03 -0000 i came across this message http://lists.freebsd.org/pipermail/freebsd-current/2004-December/044395.html and while it explains the use of bus_dmamap_sync, i'm still a little confused on it's usage. i'm trying to port over a driver from freebsd 5.x to freebsd 4.x, and it uses dma mapped addresses extensively. i've been trying to figure out the best places to use bus_dmamap_sync when reading/writing to a dma mapped address space. however, i cant seem to get the gist of this, either from the mailing list discussions or the man page. i've got two buffers, one for read, and one for write. both have been set up with calls to bus_dma_tag_create, bus_dmamem_alloc and bus_dmamap_load. the buffers, which are used in the calls to bus_dmamem_alloc and bus_dmamap_load are, int *readbuf; int *writebuf; (must i malloc space for them before passing them into those functions, or will the call to bus_dmamem_alloc do it for me ?) also, i'm on FreeBSD 4.11 right now, and i notice the definitions of BUS_DMASYNC_* has changed from an enum (0-3) in 4.x to a typedef in 5.x in machine/bus_dma.h the pseudo code for the read and write, called during an interrupt cycle, are: rx_func() { POSITION A while(there_is_some_data) { memcpy(somebuf, readbuf) } POSITION B } tx_func() { POSITION C while(there_is_some_data) { memcpy(writebuf, somebuf) } POSITION D } the question is, what op should i use for bus_dmamap_sync in positions A, B, C and D ? any assistance would be gladly appreciated, as i'm seeing some really weird symptoms on this device, where data written out is being immediately read in. i'm guessing this has to do with my wrong usage of bus_dmamap_sync(). -- 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 | +=========================================================================+ -- 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 | +=========================================================================+ -- 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 | +=========================================================================+