virt_to_bus and DMA

Ilse Reyneke reynekejunk at hotmail.com
Sat Nov 25 02:37:58 EST 2006


Hi there,

Question from a relative newby.

Can someone please tell me how to get the bus/physical address from a 
virtual address? To familiarise myself with the PPC4xx DMA API I'm trying to 
get a simple mem-mem DMA working (any good samples out there??). The 
following code snippet seems to be the way of allocating memory buffers for 
the transfer:

  int size = 2*1024;
  uint32_t* sourceaddr = (uint32_t *)__get_free_pages(GFP_KERNEL 
|GFP_DMA,get_order(size));
  uint32_t* destaddr = (uint32_t *)__get_free_pages(GFP_KERNEL |GFP_DMA,
get_order(size));

  phys_addr_t physdest = virt_to_bus((u32 *)destaddr);
  phys_addr_t physsource = virt_to_bus((u32 *)sourceaddr);


The problem is that virt_to_bus seems to be returning 0. I understand that 
it is generally undesirable to use the deprecated virt_to_bus, but what are 
the alternatives?

Am I also correct in saying the "standard DMA API" (request_dma, 
set_dma_addr etc) is NOT available on the 4xx?

We're making use of the 440EPx, Linux 2.6.14 kernel.

Cheers
   Jan Reyneke

_________________________________________________________________
Windows Live™ Messenger has arrived. Click here to download it for free! 
http://imagine-msn.com/messenger/launch80/?locale=en-gb




More information about the Linuxppc-embedded mailing list