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]);
}