From patchwork Fri Oct 26 05:47:41 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Crosthwaite X-Patchwork-Id: 194360 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E3E482C00AE for ; Fri, 26 Oct 2012 16:48:16 +1100 (EST) Received: from localhost ([::1]:33944 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TRcmF-0002FN-39 for incoming@patchwork.ozlabs.org; Fri, 26 Oct 2012 01:48:15 -0400 Received: from eggs.gnu.org ([208.118.235.92]:59156) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TRcm2-00027M-7E for qemu-devel@nongnu.org; Fri, 26 Oct 2012 01:48:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TRcm0-0000xe-RR for qemu-devel@nongnu.org; Fri, 26 Oct 2012 01:48:02 -0400 Received: from mail-da0-f45.google.com ([209.85.210.45]:49828) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TRcm0-0000xV-Ka for qemu-devel@nongnu.org; Fri, 26 Oct 2012 01:48:00 -0400 Received: by mail-da0-f45.google.com with SMTP id n15so1090001dad.4 for ; Thu, 25 Oct 2012 22:47:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:in-reply-to:references:x-gm-message-state; bh=mED5EgTcWL4xQEzhfNljuUQ3E3vsu/XUuXEAydgdUPM=; b=Y6x9qymWLLOCeyok8EvMGj3RiHrwyHd8RgNHTuHQIH5vZLaA0JqEi0z/0BaWRWjEWA h/JU+W7/Fh/mkDRpM+nts5ZTu8ARw2JqzVMWGd2r96NFQ98+mz+6Oqk2c4Peq4rlh3I+ hoIFZaZkUr90g9kWqhzX5GJ9mjUqy3tlbe5n+++GcGfML4BWP/1mgBazc9UK2eXAlZfo yJMCrTG0/wS/BEgfoX+I1g9/JvGE1h7zw2pjv8ROwl6iGEMuJYmdoxWqc//kYU0QRBoD CgZ0k5QKCwAf1JVlpEzot8iLaddd7ILb3a1CFIuWtjBjyHP5TPHe3XZ/n/FPK6E9Fepf vEIQ== Received: by 10.66.74.40 with SMTP id q8mr59224639pav.29.1351230479778; Thu, 25 Oct 2012 22:47:59 -0700 (PDT) Received: from localhost ([124.148.20.9]) by mx.google.com with ESMTPS id i4sm446621pav.20.2012.10.25.22.47.56 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 25 Oct 2012 22:47:59 -0700 (PDT) From: Peter Crosthwaite To: qemu-devel@nongnu.org Date: Fri, 26 Oct 2012 15:47:41 +1000 Message-Id: X-Mailer: git-send-email 1.7.0.4 In-Reply-To: References: In-Reply-To: References: X-Gm-Message-State: ALoCoQl3vVwlK9+ATAwEgUJYP5ryG6waqJ3UJv6S5zZ/srSMXD+miQQ0oZHWv/cZ46b7z7vO5lFo X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.210.45 Cc: vineshp@xilinx.com, peter.maydell@linaro.org, john.williams@xilinx.com, kraxel@redhat.com, edgar.iglesias@gmail.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH v2 01/11] dma: Define dma_context_memory and use in sysbus-ohci X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Peter Maydell 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 --- dma.h | 5 +++++ exec.c | 5 +++++ hw/usb/hcd-ohci.c | 2 +- 3 files changed, 11 insertions(+), 1 deletions(-) diff --git a/dma.h b/dma.h index 91ccdb5..eedf878 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 b0ed593..d2f6e79 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 0cc1e5d..a58dfa0 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);