Subject: Re: troubles with DMA
To: Filka Michal <firstname.lastname@example.org>
From: Quentin Garnier <email@example.com>
Date: 03/14/2006 13:51:41
Content-Type: text/plain; charset=us-ascii
On Tue, Mar 14, 2006 at 01:07:26PM +0100, Filka Michal wrote:
> Hi all,
> I have troubles with DMA in driver for proprietary device
> (developed by company I work for). I got things as far as I could
> according to man pages and J.Thorpe's paper, but it's still not working
> and I have no more ideas.
> The device uses DMA for subscribing interrupt vector(s) on particular
> interrupt type (of course it generates one interrupt on PIC but there is
> an additional info in one of device's register which). Problem is that
> when I try to read it in my interrupt handler I have no data in assigned
> memory (it is zero-filled).
> Any ideas are very welcome.
> DMA initialization (reduced) as done in attach callback:
> bus_dmamem_alloc( munInfo->pciInfo.pa_dmat, BUF_BUF_SIZE,
> PAGE_SIZE,&munInfo->dmaMem[ 0], 1, &munInfo->dmaSegs, 0)
> bus_dmamem_map( munInfo->pciInfo.pa_dmat, munInfo->dmaMem,
> munInfo->dmaSegs, BUF_BUF_SIZE,=20
> &munInfo->dmaBuf, BUS_DMA_NOWAIT | BUS_DMA_NOCACHE )
> 0, &munInfo->dmaMap)
> bus_dmamap_load( munInfo->pciInfo.pa_dmat, munInfo->dmaMap,
> munInfo->dmaBuf, BUF_BUF_SIZE, NULL, 0)
> Next thing I do is that I configure device's DMA related registers.
> E.g for the first interrupt queue: pulIntQueue=3DmunInfo->dmaBuf + 0
> For the second interrupt queue: pulIntQueue=3DmunInfo->dmaBuf +
> And so on ... and write those pulIntQueue[ i] into device ...
dmaBuf is the virtual address at which the aera is mapped. You need to
tell the device about the physical address(es) which you get in the
bus_dma_segment_t table, otherwise it will write in rather random places
of the memory...
In your case, you need at least one segment per whatever your structure
is, you don't necessarily need to put all of them into one. Then you
assign the registers to the values you get from the segments.
Quentin Garnier - firstname.lastname@example.org - cube@NetBSD.org
"When I find the controls, I'll go where I like, I'll know where I want
to be, but maybe for now I'll stay right here on a silent sea."
KT Tunstall, Silent Sea, Eye to the Telescope, 2004.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (NetBSD)
-----END PGP SIGNATURE-----