From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konrad Rzeszutek Wilk Subject: Re: virtual, physical and bus address on Dom0 Date: Fri, 17 Feb 2012 14:08:22 -0500 Message-ID: <20120217190822.GB20584@phenom.dumpdata.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Eric Camachat Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org 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