qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] dma: Define dma_context_memory and use in sysbu


From: David Gibson
Subject: Re: [Qemu-devel] [PATCH] dma: Define dma_context_memory and use in sysbus-ohci
Date: Fri, 26 Oct 2012 14:58:12 +1100
User-agent: Mutt/1.5.21 (2010-09-15)

On Fri, Oct 26, 2012 at 12:53:27PM +1000, Peter Crosthwaite wrote:
> On Fri, Oct 26, 2012 at 10:48 AM, David Gibson
> <address@hidden> wrote:
> > On Thu, Oct 25, 2012 at 08:33:13PM +1000, Peter Crosthwaite wrote:
> >> On Oct 24, 2012 3:27 AM, "Peter Maydell" <address@hidden> 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 <address@hidden>
> >> Reviewed-by: Peter Crosthwaite <address@hidden>
> >
> > 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]