virt_to_bus and DMA

Manish Joshi mjoshi_blr at yahoo.com
Sat Nov 25 04:18:14 EST 2006


you can use __pa() along with kmalloc(..., GFP_KERNEL | GFP_DMA).



----- Original Message ----
From: Ilse Reyneke <reynekejunk at hotmail.com>
To: linuxppc-embedded at ozlabs.org
Sent: Friday, November 24, 2006 9:07:58 PM
Subject: virt_to_bus and DMA


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
_______________________________________________
Linuxppc-embedded mailing list
Linuxppc-embedded at ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-embedded


 
____________________________________________________________________________________
Cheap talk?
Check out Yahoo! Messenger's low PC-to-Phone call rates.
http://voice.yahoo.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://ozlabs.org/pipermail/linuxppc-embedded/attachments/20061124/479ab64e/attachment.htm 


More information about the Linuxppc-embedded mailing list