From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:44494) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TRKka-0006E6-8n for qemu-devel@nongnu.org; Thu, 25 Oct 2012 06:33:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TRKkV-0002JX-Fg for qemu-devel@nongnu.org; Thu, 25 Oct 2012 06:33:20 -0400 Received: from mail-vc0-f173.google.com ([209.85.220.173]:55751) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TRKkV-0002JR-A9 for qemu-devel@nongnu.org; Thu, 25 Oct 2012 06:33:15 -0400 Received: by mail-vc0-f173.google.com with SMTP id fl15so840313vcb.4 for ; Thu, 25 Oct 2012 03:33:13 -0700 (PDT) MIME-Version: 1.0 Sender: peter.crosthwaite@petalogix.com In-Reply-To: <1351013211-1907-1-git-send-email-peter.maydell@linaro.org> References: <1351013211-1907-1-git-send-email-peter.maydell@linaro.org> Date: Thu, 25 Oct 2012 20:33:13 +1000 Message-ID: From: Peter Crosthwaite Content-Type: multipart/alternative; boundary=20cf3071c852fb374704ccdfbac3 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 Maydell Cc: Avi Kivity , David Gibson , Gerd Hoffmann , patches@linaro.org, qemu-devel@nongnu.org --20cf3071c852fb374704ccdfbac3 Content-Type: text/plain; charset=ISO-8859-1 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 > --- > As suggested by Avi. I could have split this patch into one defining > the new global and one actually using it, but since the hcd-ohci > change would be a one-liner it didn't seem worthwhile. > > dma.h | 5 +++++ > exec.c | 5 +++++ > hw/usb/hcd-ohci.c | 2 +- > 3 files changed, 11 insertions(+), 1 deletion(-) > > diff --git a/dma.h b/dma.h > index 1bd6f4a..f7cf5e7 100644 > --- a/dma.h > +++ b/dma.h > @@ -68,6 +68,11 @@ struct DMAContext { > DMAUnmapFunc *unmap; > }; > > +/* A global DMA context corresponding to the address_space_memory > + * AddressSpace, for sysbus devices which do DMA. > + */ > +extern DMAContext dma_context_memory; > + > static inline void dma_barrier(DMAContext *dma, DMADirection dir) > { > /* > diff --git a/exec.c b/exec.c > index 750008c..a59ed31 100644 > --- a/exec.c > +++ b/exec.c > @@ -34,6 +34,7 @@ > #include "hw/xen.h" > #include "qemu-timer.h" > #include "memory.h" > +#include "dma.h" > #include "exec-memory.h" > #if defined(CONFIG_USER_ONLY) > #include > @@ -103,6 +104,7 @@ static MemoryRegion *system_io; > > AddressSpace address_space_io; > AddressSpace address_space_memory; > +DMAContext dma_context_memory; > > MemoryRegion io_mem_ram, io_mem_rom, io_mem_unassigned, io_mem_notdirty; > static MemoryRegion io_mem_subpage_ram; > @@ -3276,6 +3278,9 @@ static void memory_map_init(void) > memory_listener_register(&core_memory_listener, &address_space_memory); > memory_listener_register(&io_memory_listener, &address_space_io); > memory_listener_register(&tcg_memory_listener, &address_space_memory); > + > + dma_context_init(&dma_context_memory, &address_space_memory, > + NULL, NULL, NULL); > } > > MemoryRegion *get_system_memory(void) > diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c > index 59c7055..eb1cb70 100644 > --- a/hw/usb/hcd-ohci.c > +++ b/hw/usb/hcd-ohci.c > @@ -1846,7 +1846,7 @@ static int ohci_init_pxa(SysBusDevice *dev) > > /* Cannot fail as we pass NULL for masterbus */ > usb_ohci_init(&s->ohci, &dev->qdev, s->num_ports, s->dma_offset, NULL, 0, > - NULL); > + &dma_context_memory); > sysbus_init_irq(dev, &s->ohci.irq); > sysbus_init_mmio(dev, &s->ohci.mem); > > -- > 1.7.9.5 > > --20cf3071c852fb374704ccdfbac3 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable


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 correspon= ding
> 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>

> ---
> As suggested by Avi. I could have split this patch into one defining > the new global and one actually using it, but since the hcd-ohci
> change would be a one-liner it didn't seem worthwhile.
>
> =A0dma.h =A0 =A0 =A0 =A0 =A0 =A0 | =A0 =A05 +++++
> =A0exec.c =A0 =A0 =A0 =A0 =A0 =A0| =A0 =A05 +++++
> =A0hw/usb/hcd-ohci.c | =A0 =A02 +-
> =A03 files changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/dma.h b/dma.h
> index 1bd6f4a..f7cf5e7 100644
> --- a/dma.h
> +++ b/dma.h
> @@ -68,6 +68,11 @@ struct DMAContext {
> =A0 =A0 =A0DMAUnmapFunc *unmap;
> =A0};
>
> +/* A global DMA context corresponding to the address_space_memory
> + * AddressSpace, for sysbus devices which do DMA.
> + */
> +extern DMAContext dma_context_memory;
> +
> =A0static inline void dma_barrier(DMAContext *dma, DMADirection dir) > =A0{
> =A0 =A0 =A0/*
> diff --git a/exec.c b/exec.c
> index 750008c..a59ed31 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -34,6 +34,7 @@
> =A0#include "hw/xen.h"
> =A0#include "qemu-timer.h"
> =A0#include "memory.h"
> +#include "dma.h"
> =A0#include "exec-memory.h"
> =A0#if defined(CONFIG_USER_ONLY)
> =A0#include <qemu.h>
> @@ -103,6 +104,7 @@ static MemoryRegion *system_io;
>
> =A0AddressSpace address_space_io;
> =A0AddressSpace address_space_memory;
> +DMAContext dma_context_memory;
>
> =A0MemoryRegion io_mem_ram, io_mem_rom, io_mem_unassigned, io_mem_notd= irty;
> =A0static MemoryRegion io_mem_subpage_ram;
> @@ -3276,6 +3278,9 @@ static void memory_map_init(void)
> =A0 =A0 =A0memory_listener_register(&core_memory_listener, &ad= dress_space_memory);
> =A0 =A0 =A0memory_listener_register(&io_memory_listener, &addr= ess_space_io);
> =A0 =A0 =A0memory_listener_register(&tcg_memory_listener, &add= ress_space_memory);
> +
> + =A0 =A0dma_context_init(&dma_context_memory, &address_space_= memory,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 NULL, NULL, NULL);
> =A0}
>
> =A0MemoryRegion *get_system_memory(void)
> diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
> index 59c7055..eb1cb70 100644
> --- a/hw/usb/hcd-ohci.c
> +++ b/hw/usb/hcd-ohci.c
> @@ -1846,7 +1846,7 @@ static int ohci_init_pxa(SysBusDevice *dev)
>
> =A0 =A0 =A0/* Cannot fail as we pass NULL for masterbus */
> =A0 =A0 =A0usb_ohci_init(&s->ohci, &dev->qdev, s->num= _ports, s->dma_offset, NULL, 0,
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0NULL);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0&dma_context_memory);
> =A0 =A0 =A0sysbus_init_irq(dev, &s->ohci.irq);
> =A0 =A0 =A0sysbus_init_mmio(dev, &s->ohci.mem);
>
> --
> 1.7.9.5
>
>

--20cf3071c852fb374704ccdfbac3--