qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Cc: qemu-devel@nongnu.org, Peter Maydell <peter.maydell@linaro.org>,
	Gerd Hoffmann <kraxel@redhat.com>, Avi Kivity <avi@redhat.com>,
	patches@linaro.org
Subject: Re: [Qemu-devel] [PATCH] dma: Define dma_context_memory and use in sysbus-ohci
Date: Fri, 26 Oct 2012 14:58:12 +1100	[thread overview]
Message-ID: <20121026035812.GK7222@truffula.fritz.box> (raw)
In-Reply-To: <CAEgOgz4saHg_OVQSduvTg_UcS2xpKy3y3WHfTU-3aV-Ua6i4nQ@mail.gmail.com>

On Fri, Oct 26, 2012 at 12:53:27PM +1000, Peter Crosthwaite wrote:
> On Fri, Oct 26, 2012 at 10:48 AM, David Gibson
> <david@gibson.dropbear.id.au> wrote:
> > On Thu, Oct 25, 2012 at 08:33:13PM +1000, Peter Crosthwaite wrote:
> >> On Oct 24, 2012 3:27 AM, "Peter Maydell" <peter.maydell@linaro.org> 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 <peter.maydell@linaro.org>
> >> Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> >
> > 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	other threads:[~2012-10-26  6:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-23 17:26 [Qemu-devel] [PATCH] dma: Define dma_context_memory and use in sysbus-ohci Peter Maydell
2012-10-25 10:33 ` Peter Crosthwaite
2012-10-26  0:48   ` David Gibson
2012-10-26  2:53     ` Peter Crosthwaite
2012-10-26  3:58       ` David Gibson [this message]
2012-10-26 13:09         ` Paolo Bonzini
2012-10-26 16:00           ` Peter Maydell
2012-11-13 11:44             ` Peter Maydell
2012-11-13 15:04               ` Paolo Bonzini
2012-11-13 15:21                 ` Gerd Hoffmann
2012-11-13 15:26                   ` Paolo Bonzini
2012-11-18 16:53               ` Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121026035812.GK7222@truffula.fritz.box \
    --to=david@gibson.dropbear.id.au \
    --cc=avi@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=patches@linaro.org \
    --cc=peter.crosthwaite@xilinx.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).