DMA driver. Cache.

Hi all,

I'm having troubles with the following piece of code. It's a DMA driver written in kernel, for MPC8245. Local to local memory. The issue is: the values I see at the end of the transfer are the uninitilized source values, instead of the initialized ones. It looks like a cache problem. If it is I don't know how to invalidate the data cache. Or, is it the type of memory I'm using?

Thanks, Virgil

static int direct_dma_init(void) { U8* scr; U32 tt; int i; sursa = kmalloc(64,GFP_KERNEL|GFP_DMA); //sursa = __get_dma_pages(GFP_KERNEL,0); dest = kmalloc(64,GFP_KERNEL|GFP_DMA); printk("sursa:%x %x %x %x %x %x\n",sursa[0],sursa[1],sursa[2],sursa[3],sursa,dest); // these are the values I see at the end of dma transfer dma_t = (volatile DMAS*) ioremap(DMA_SPACE(0),sizeof(DMAS)); dma_r = (volatile DMAS*) ioremap(DMA_SPACE(1),sizeof(DMAS)); for(i=0;idsr) & 0x4) { printk("nu pe aici0"); return; } writel(virt_to_bus(sursa),&dma_t->sar);//source address writel(virt_to_bus(dest),&dma_t->dar);//destination address writel(4,&dma_t->bcr);// 4 bytes to transfer writel(0,&dma_t->cdar); printk("prim %x %x %x %x %x %x\n", (((U32)readl(&dma_t->dmr))),(((U32)readl(&dma_t->dsr))), (((U32)readl(&dma_t->cdar))),(((U32)readl(&dma_t->sar))), (((U32)readl(&dma_t->dar))),(((U32)readl(&dma_t->bcr))));

writel(4,&dma_t->dmr); writel(5, &dma_t->dmr);// start dma

tt = readl(&dma_t->dsr); writel(tt,&dma_t->dsr); while(tt&0x4){ // just in case: wait to finish tt = readl(&dma_t->dsr); writel(tt,&dma_t->dsr); } printk("prim %x %x %x %x %x %x \n", (((U32)readl(&dma_t->dmr))),(((U32)readl(&dma_t->dsr))), (((U32)readl(&dma_t->cdar))),(((U32)readl(&dma_t->sar))), (((U32)readl(&dma_t->dar))),(((U32)readl(&dma_t->bcr))));

printk("\ndest:%x %x %x %x",dest[0],dest[1], dest[2],dest[3]);

}
Reply to
virgil
Loading thread data ...

most (all?) platforms define a bunch of cache clearing functions in include/asm/pgalloc.h or pgtable.h

cd linux-2.4.x/include/asm-xxxxx

grep flush *.h

Rgds,

John

Reply to
John Williams

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.