From patchwork Wed Jun 20 20:11:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Baron X-Patchwork-Id: 166143 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 B9889B6FBC for ; Thu, 21 Jun 2012 06:19:22 +1000 (EST) Received: from localhost ([::1]:45579 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ShRFt-0005er-IQ for incoming@patchwork.ozlabs.org; Wed, 20 Jun 2012 16:11:57 -0400 Received: from eggs.gnu.org ([208.118.235.92]:32849) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ShRFJ-0003w7-DE for qemu-devel@nongnu.org; Wed, 20 Jun 2012 16:11:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ShRFH-0003Fw-CI for qemu-devel@nongnu.org; Wed, 20 Jun 2012 16:11:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1028) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ShRFH-0003FZ-3p for qemu-devel@nongnu.org; Wed, 20 Jun 2012 16:11:19 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q5KKBFox008701 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 20 Jun 2012 16:11:15 -0400 Received: from redhat.com (dhcp-185-114.bos.redhat.com [10.16.185.114]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q5KKBEVu030209; Wed, 20 Jun 2012 16:11:14 -0400 Date: Wed, 20 Jun 2012 16:11:14 -0400 From: Jason Baron To: anthony@codemonkey.ws, benh@kernel.crashing.org Message-Id: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: mst@redhat.com, jan.kiszka@siemens.com, armbru@redhat.com, qemu-devel@nongnu.org, yamahata@valinux.co.jp, alex.williamson@redhat.com, ddutile@redhat.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH 3/3] iommu: add generic mapping support for the isa bus 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 Introduce 'isa_setup_iommu()' to allow chipsets to associate an iommu mapping function with the isa bus. This allows isa devices which sit behind an iommu to be correctly configured. This is based on Benjamin Herrenschmidt's iommu series. It has no consumers for now. Signed-off-by: Jason Baron --- hw/isa-bus.c | 11 +++++++++++ hw/isa.h | 5 +++++ 2 files changed, 16 insertions(+), 0 deletions(-) diff --git a/hw/isa-bus.c b/hw/isa-bus.c index cfd7501..0232799 100644 --- a/hw/isa-bus.c +++ b/hw/isa-bus.c @@ -118,10 +118,17 @@ void isa_register_portio_list(ISADevice *dev, uint16_t start, portio_list_add(piolist, isabus->address_space_io, start); } +void isa_setup_iommu(ISABus *bus, ISADMAContextFunc fn, void *opaque) +{ + bus->dma_context_fn = fn; + bus->dma_context_opaque = opaque; +} + static int isa_qdev_init(DeviceState *qdev) { ISADevice *dev = ISA_DEVICE(qdev); ISADeviceClass *klass = ISA_DEVICE_GET_CLASS(dev); + ISABus *isabus; dev->isairq[0] = -1; dev->isairq[1] = -1; @@ -132,6 +139,10 @@ static int isa_qdev_init(DeviceState *qdev) /* iommu setup */ dev->dma = NULL; + isabus = FROM_QBUS(ISABus, qdev_get_parent_bus(qdev)); + if (isabus->dma_context_fn) { + dev->dma = isabus->dma_context_fn(isabus, isabus->dma_context_opaque); + } return 0; } diff --git a/hw/isa.h b/hw/isa.h index a1c3f25..e6a0bb1 100644 --- a/hw/isa.h +++ b/hw/isa.h @@ -26,10 +26,15 @@ typedef struct ISADeviceClass { int (*init)(ISADevice *dev); } ISADeviceClass; +typedef DMAContext *(*ISADMAContextFunc)(ISABus *, void *); +void isa_setup_iommu(ISABus *bus, ISADMAContextFunc fn, void *opaque); + struct ISABus { BusState qbus; MemoryRegion *address_space_io; qemu_irq *irqs; + ISADMAContextFunc dma_context_fn; + void *dma_context_opaque; }; struct ISADevice {