All of lore.kernel.org
 help / color / mirror / Atom feed
* virtual, physical and bus address on Dom0
@ 2012-02-17 18:20 Eric Camachat
  2012-02-17 19:08 ` Konrad Rzeszutek Wilk
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Camachat @ 2012-02-17 18:20 UTC (permalink / raw)
  To: xen-devel

Consider the code:

dma_addr_t dma_addr, dma_addr2;
phys_addr_t phys_addr;
cpu_addr = pci_alloc_consistent(pdev, size, &dma_addr);
phys_addr = virt_to_phys(cpu_addr);
dma_addr2 = virt_to_bus(cpu_addr);

In Dom0 the outputs are:

dma_addr: 0xbc800000
phys_addr: 0x5b000000
dma_addr2: 0x5b000000

Why the addresses are different in dma_addr and dma_addr2?
Which one is the correct value I should use in DMA operations?

Eric

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: virtual, physical and bus address on Dom0
  2012-02-17 18:20 virtual, physical and bus address on Dom0 Eric Camachat
@ 2012-02-17 19:08 ` Konrad Rzeszutek Wilk
  0 siblings, 0 replies; 2+ messages in thread
From: Konrad Rzeszutek Wilk @ 2012-02-17 19:08 UTC (permalink / raw)
  To: Eric Camachat; +Cc: xen-devel

On Fri, Feb 17, 2012 at 10:20:21AM -0800, Eric Camachat wrote:
> Consider the code:
> 
> dma_addr_t dma_addr, dma_addr2;
> phys_addr_t phys_addr;

> cpu_addr = pci_alloc_consistent(pdev, size, &dma_addr);
> phys_addr = virt_to_phys(cpu_addr);
> dma_addr2 = virt_to_bus(cpu_addr);
> 
> In Dom0 the outputs are:
> 
> dma_addr: 0xbc800000

You should use the dma_addr.

> phys_addr: 0x5b000000
> dma_addr2: 0x5b000000
> 
> Why the addresses are different in dma_addr and dma_addr2?

B/c you are doing a bit shift on the cpu_addr - both virt_to_phys
and virt_to_bus do exactly the same thing.

> Which one is the correct value I should use in DMA operations?

The one that pci_alloc_coherent gives you.
> 
> Eric
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-02-17 19:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-17 18:20 virtual, physical and bus address on Dom0 Eric Camachat
2012-02-17 19:08 ` Konrad Rzeszutek Wilk

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.