From patchwork Tue Oct 23 17:26:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 12449 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id C0F4D23F58 for ; Tue, 23 Oct 2012 17:26:59 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 768DBA1869B for ; Tue, 23 Oct 2012 17:26:59 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so5475895iej.11 for ; Tue, 23 Oct 2012 10:26:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:x-gm-message-state; bh=s3j90ZbEMVfUQO9t0T+DmqLIBYVGWFQXjg9/iEdhlVg=; b=fT3de/cSK4ggfCWpYDZQ3O7CqFK8Wem8GtM+PtxzfEbvK8S/0iga+te39dfP2VYeFy 1Fs1il8bPpF3J/TwTNQwoY2d3NBpvvaIAUln8RmIma9EEsUKfDBLLR6RJYAzQSq5k2e5 2KKRrLBGhK052EbR0XdmCOnC4FN2s2MgbLLejIwL6sRM9hAFLhfiD/PSyodykqbxgul6 FgvkJ2GKffP0pgtxAMGXNxF/DsTt+/B3ipH23fuJxew/qLXiUCWoLqC2wG1LB2H6a2dB ljNZDseDKv0nk8n5mcKauXqoUuHfYfHqXGqY0225pymTafD0uStd/c4/jdCr72W2+6M3 M/JA== Received: by 10.50.161.169 with SMTP id xt9mr20645580igb.62.1351013219249; Tue, 23 Oct 2012 10:26:59 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp469696igt; Tue, 23 Oct 2012 10:26:58 -0700 (PDT) Received: by 10.216.141.14 with SMTP id f14mr8104774wej.208.1351013217536; Tue, 23 Oct 2012 10:26:57 -0700 (PDT) Received: from mnementh.archaic.org.uk (1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id j56si13259321wen.3.2012.10.23.10.26.57 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 23 Oct 2012 10:26:57 -0700 (PDT) Received-SPF: neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) client-ip=2001:8b0:1d0::1; Authentication-Results: mx.google.com; spf=neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) smtp.mail=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1TQiFf-0000VD-QD; Tue, 23 Oct 2012 18:26:51 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Avi Kivity , Gerd Hoffmann , David Gibson , Benjamin Herrenschmidt Subject: [PATCH] dma: Define dma_context_memory and use in sysbus-ohci Date: Tue, 23 Oct 2012 18:26:51 +0100 Message-Id: <1351013211-1907-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 X-Gm-Message-State: ALoCoQllkXRABy4AZXq2IkEz1/YcJX3FSqAljwHjeeCHvCb/aN0kr5M+NN5zUmZwZH9RoicXbJqd 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);