From patchwork Fri Mar 9 05:01:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 145679 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 DF8B2B6FB9 for ; Fri, 9 Mar 2012 17:55:04 +1100 (EST) Received: from localhost ([::1]:60075 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S5ryk-0001i6-Cb for incoming@patchwork.ozlabs.org; Fri, 09 Mar 2012 00:02:58 -0500 Received: from eggs.gnu.org ([208.118.235.92]:58561) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S5ryJ-0000d3-OD for qemu-devel@nongnu.org; Fri, 09 Mar 2012 00:02:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S5rxx-0000GD-E2 for qemu-devel@nongnu.org; Fri, 09 Mar 2012 00:02:31 -0500 Received: from ozlabs.org ([203.10.76.45]:34401) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S5rxw-0000FZ-Vz for qemu-devel@nongnu.org; Fri, 09 Mar 2012 00:02:09 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id BCA0EB6FA5; Fri, 9 Mar 2012 16:02:06 +1100 (EST) From: David Gibson To: qemu-devel@nongnu.org Date: Fri, 9 Mar 2012 16:01:43 +1100 Message-Id: <1331269308-22372-9-git-send-email-david@gibson.dropbear.id.au> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <1331269308-22372-1-git-send-email-david@gibson.dropbear.id.au> References: <1331269308-22372-1-git-send-email-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 203.10.76.45 Cc: Kevin Wolf , mst@redhat.com, agraf@suse.de, eduard.munteanu@linux360.ro, David Gibson , rth@twiddle.net Subject: [Qemu-devel] [PATCH 08/13] ide/ahci: Use universal DMA helper functions 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 The AHCI device can provide both PCI and SysBus AHCI device emulations. For this reason, it wasn't previously converted to use the pci_dma_*() helper functions. Now that we have universal DMA helper functions, this converts AHCI to use them. The DMAContext is obtained from pci_dma_context() in the PCI case and set to NULL in the SysBus case (i.e. we assume for now that a SysBus AHCI has no IOMMU translation). Cc: Kevin Wolf Cc: Michael S. Tsirkin Signed-off-by: David Gibson --- hw/ide/ahci.c | 7 ++++--- hw/ide/ahci.h | 3 ++- hw/ide/ich.c | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 6a218b5..3d31179 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -668,7 +668,7 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist) AHCI_SG *tbl = (AHCI_SG *)prdt; /* FIXME: pass the correct DMAContext */ - qemu_sglist_init(sglist, sglist_alloc_hint, NULL); + qemu_sglist_init(sglist, sglist_alloc_hint, ad->hba->dma); for (i = 0; i < sglist_alloc_hint; i++) { /* flags_size is zero-based */ qemu_sglist_add(sglist, le64_to_cpu(tbl[i].addr), @@ -1115,11 +1115,12 @@ static const IDEDMAOps ahci_dma_ops = { .reset = ahci_dma_reset, }; -void ahci_init(AHCIState *s, DeviceState *qdev, int ports) +void ahci_init(AHCIState *s, DeviceState *qdev, DMAContext *dma, int ports) { qemu_irq *irqs; int i; + s->dma = dma; s->ports = ports; s->dev = g_malloc0(sizeof(AHCIDevice) * ports); ahci_reg_init(s); @@ -1182,7 +1183,7 @@ static const VMStateDescription vmstate_sysbus_ahci = { static int sysbus_ahci_init(SysBusDevice *dev) { SysbusAHCIState *s = FROM_SYSBUS(SysbusAHCIState, dev); - ahci_init(&s->ahci, &dev->qdev, s->num_ports); + ahci_init(&s->ahci, &dev->qdev, NULL, s->num_ports); sysbus_init_mmio(dev, &s->ahci.mem); sysbus_init_irq(dev, &s->ahci.irq); diff --git a/hw/ide/ahci.h b/hw/ide/ahci.h index b223d2c..af8c6ef 100644 --- a/hw/ide/ahci.h +++ b/hw/ide/ahci.h @@ -299,6 +299,7 @@ typedef struct AHCIState { uint32_t idp_index; /* Current IDP index */ int ports; qemu_irq irq; + DMAContext *dma; } AHCIState; typedef struct AHCIPCIState { @@ -329,7 +330,7 @@ typedef struct NCQFrame { uint8_t reserved10; } QEMU_PACKED NCQFrame; -void ahci_init(AHCIState *s, DeviceState *qdev, int ports); +void ahci_init(AHCIState *s, DeviceState *qdev, DMAContext *dma, int ports); void ahci_uninit(AHCIState *s); void ahci_reset(void *opaque); diff --git a/hw/ide/ich.c b/hw/ide/ich.c index 560ae37..5354e13 100644 --- a/hw/ide/ich.c +++ b/hw/ide/ich.c @@ -91,7 +91,7 @@ static int pci_ich9_ahci_init(PCIDevice *dev) uint8_t *sata_cap; d = DO_UPCAST(struct AHCIPCIState, card, dev); - ahci_init(&d->ahci, &dev->qdev, 6); + ahci_init(&d->ahci, &dev->qdev, pci_dma_context(dev), 6); pci_config_set_prog_interface(d->card.config, AHCI_PROGMODE_MAJOR_REV_1);