Subject: DMA troubles
To: None <tech-kern@NetBSD.org>
From: Filka Michal <michal.filka@strom.cz>
List: tech-kern
Date: 04/24/2006 14:34:33
Hi all,
I have a problem (possibly) with DMA. I can allocate a DMA memory in my
driver and work with it without any troubles. However, If I unload
driver (it is a LKM) and try to load it again, kernel crashes during DMA
memory allocation. I did a DMA deinitialization when unloading driver
without any error.
Code related to DMA:
Initialization:
if( bus_dmamem_alloc( munInfo->pciInfo.pa_dmat,
BUF_BUF_SIZE,
PAGE_SIZE,
0, =09
&munInfo->dmaMem[ 0],
1, =09
&munInfo->dmaSegs,
BUS_DMA_NOWAIT) !=3D 0 )
goto error4;
=09
if( bus_dmamem_map( munInfo->pciInfo.pa_dmat,
munInfo->dmaMem,
munInfo->dmaSegs,
BUF_BUF_SIZE,
&munInfo->dmaBuf,
BUS_DMA_NOWAIT | BUS_DMA_NOCACHE) !=3D 0)
goto error3;
if( bus_dmamap_create( munInfo->pciInfo.pa_dmat,=20
BUF_BUF_SIZE,=20
1,
BUF_BUF_SIZE,=20
0,=20
BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW,
&munInfo->dmaMap) !=3D 0)
goto error2;
if( bus_dmamap_load( munInfo->pciInfo.pa_dmat, =20
munInfo->dmaMap,=20
munInfo->dmaBuf,=20
BUF_BUF_SIZE,=20
NULL,
BUS_DMA_NOWAIT) !=3D 0)
goto error1;
Deinitialization:
bus_dmamap_unload(munInfo->pciInfo.pa_dmat, munInfo->dmaMap);
bus_dmamap_destroy(munInfo->pciInfo.pa_dmat, munInfo->dmaMap);
bus_dmamem_unmap(munInfo->pciInfo.pa_dmat, munInfo->dmaBuf,
BUF_BUF_SIZE);
bus_dmamem_free( munInfo->pciInfo.pa_dmat, munInfo->dmaMem,
munInfo->dmaSegs);
Any ideas what can be wrong?
Thanks all
Michal Filka