From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:44120) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TRdPT-0001bF-Ux for qemu-devel@nongnu.org; Fri, 26 Oct 2012 02:28:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TRdPS-0002Jm-IT for qemu-devel@nongnu.org; Fri, 26 Oct 2012 02:28:47 -0400 Received: from ozlabs.org ([203.10.76.45]:38929) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TRdPS-0002Ji-7B for qemu-devel@nongnu.org; Fri, 26 Oct 2012 02:28:46 -0400 Date: Fri, 26 Oct 2012 14:58:12 +1100 From: David Gibson Message-ID: <20121026035812.GK7222@truffula.fritz.box> References: <1351013211-1907-1-git-send-email-peter.maydell@linaro.org> <20121026004832.GG7222@truffula.fritz.box> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [PATCH] dma: Define dma_context_memory and use in sysbus-ohci List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Crosthwaite Cc: qemu-devel@nongnu.org, Peter Maydell , Gerd Hoffmann , Avi Kivity , patches@linaro.org On Fri, Oct 26, 2012 at 12:53:27PM +1000, Peter Crosthwaite wrote: > On Fri, Oct 26, 2012 at 10:48 AM, David Gibson > wrote: > > On Thu, Oct 25, 2012 at 08:33:13PM +1000, Peter Crosthwaite wrote: > >> On Oct 24, 2012 3:27 AM, "Peter Maydell" wrote: > >> > > >> > Define a new global dma_context_memory which is a DMAContext corresponding > >> > to the global address_space_memory AddressSpace. This can be used by > >> > sysbus peripherals like sysbus-ohci which need to do DMA. > >> > > >> > In particular, use it in the sysbus-ohci device, which fixes a > >> > segfault when attempting to use that device. > >> > > >> > Signed-off-by: Peter Maydell > >> Reviewed-by: Peter Crosthwaite > > > > Hrm. So, as I originally conceived DMAContext, a NULL context pointer > > means "no translation" which is to say that DMA addresses are the same > > as memory space addresses. Which would mean a context explicitly for > > this purpose should not be necessary. > > > > Has this assumption changed with the newer memory region integrated > > dma context stuff? > > > Yes, The Segfaulting line is in dma.h: > > static inline int dma_memory_rw_relaxed(DMAContext *dma, dma_addr_t addr, > void *buf, dma_addr_t len, > DMADirection dir) > { > if (!dma_has_iommu(dma)) { > /* Fast-path for no IOMMU */ > address_space_rw(dma->as, addr, buf, len, dir == > DMA_DIRECTION_FROM_DEVICE); > return 0; > } else { > return iommu_dma_memory_rw(dma, addr, buf, len, dir); > } > } > > Dereferencing of dma->as segfaults sd dma==NULL in the cas you described. Ok. My inclination would be to special case that in that function, setting as to the standard memory as if !dma, but others may have a different opinion. -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson