Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 25 Oct 2005 21:15:47 +0800
From:      Dinesh Nair <dinesh@alphaque.com>
To:        freebsd-hackers@freebsd.org
Subject:   correct use of bus_dmamap_sync
Message-ID:  <435E3003.4050609@alphaque.com>

next in thread | raw e-mail | index | archive | help

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                                                              |
+=========================================================================+



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?435E3003.4050609>