DMA driver. Cache.

From: virgil (vanuichi_at_yahoo.com)
Date: 11/05/04


Date: 5 Nov 2004 06:30:42 -0800

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;i<8;i++)
   {
     sursa[i] = i+40;
   }

printk("sursa:%x %x %x
%x\n",sursa[0],sursa[1],sursa[2],sursa[3]);//these should be the
values I see
printk("dma:%x %x %x %x\n",dma_t,dma_r,DMA_SPACE(0),DMA_SPACE(1));

   if (readl(&dma_t->dsr) & 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]);

}



Relevant Pages

  • DMA driver. Cache.
    ... It's a DMA ... Local to local memory. ... like a cache problem. ... static int direct_dma_init ...
    (comp.os.linux.embedded)
  • DMA driver. Cache.
    ... It's a DMA ... Local to local memory. ... like a cache problem. ... static int direct_dma_init ...
    (comp.os.linux.powerpc)
  • DMA driver. Cache.
    ... It's a DMA ... Local to local memory. ... like a cache problem. ... static int direct_dma_init ...
    (comp.os.linux.development.apps)
  • [patch 47/76] b43: Backport bcm4311 fix
    ... This is a backport of upstream commit 013978b6 ("b43: ... Remove some magic numbers in the DMA setup. ... the DMA error appeared. ... static int alloc_ringmemory ...
    (Linux-Kernel)
  • [patch 01/36] atl1: disable broken 64-bit DMA
    ... The L1 network chip can DMA to 64-bit addresses, ... static int cards_found = 0; ... int err; ... /* Mark all PCI regions associated with PCI device ...
    (Linux-Kernel)