From patchwork Sat Jan 29 17:40:23 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduard - Gabriel Munteanu X-Patchwork-Id: 516511 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p0THexB3005793 for ; Sat, 29 Jan 2011 17:40:59 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754588Ab1A2Rky (ORCPT ); Sat, 29 Jan 2011 12:40:54 -0500 Received: from mail-fx0-f46.google.com ([209.85.161.46]:50369 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754541Ab1A2Rkw (ORCPT ); Sat, 29 Jan 2011 12:40:52 -0500 Received: by mail-fx0-f46.google.com with SMTP id 20so4372013fxm.19 for ; Sat, 29 Jan 2011 09:40:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:sender:from:to:cc:subject:date:message-id :x-mailer:in-reply-to:references:in-reply-to:references; bh=IVFi/SlLUJ/O4NF5srM4DH5cFaBSoj51ZoBfhVL2IAo=; b=D23N3G2ZHZ8zW/8FoHRgt9JJ3FGC5etveGJo1PzRmcX2uDZuoKMU/oPOda4183kxWa PBtGk73FXkqlvLsmZcMm3cLwp0Q43s2MPmxFerh1Hn+sO3z4RC83iDJPcmIpBYd2xTrp VJRq0AxVN4GCK7rco+nwL10wyp/3cUJpSpxCg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; b=n4iUjA6gOMtZkQIm/WQn2DgU0wKyvtv+z9Z9LBBDSv/j+tfkDt+APfkufm1MhL6k/j kUlGtDVA0aspwEX/IO+bYCS8QZVJSOuhuichiCDfFwgcYTuQDVr2Z/DbYWh1pLHP/Qmj o5kWJbIXyuHMBhj9YiY31ZQ2pyAjbxqA7owFs= Received: by 10.223.83.194 with SMTP id g2mr3882103fal.75.1296322851291; Sat, 29 Jan 2011 09:40:51 -0800 (PST) Received: from localhost.localdomain ([188.25.244.101]) by mx.google.com with ESMTPS id 21sm6822801fav.17.2011.01.29.09.40.49 (version=SSLv3 cipher=RC4-MD5); Sat, 29 Jan 2011 09:40:50 -0800 (PST) From: Eduard - Gabriel Munteanu To: joro@8bytes.org Cc: blauwirbel@gmail.com, paul@codesourcery.com, avi@redhat.com, anthony@codemonkey.ws, av1474@comtv.ru, yamahata@valinux.co.jp, kvm@vger.kernel.org, qemu-devel@nongnu.org, Eduard - Gabriel Munteanu Subject: [PATCH 02/13] pci: add IOMMU support via the generic DMA layer Date: Sat, 29 Jan 2011 19:40:23 +0200 Message-Id: X-Mailer: git-send-email 1.7.3.4 In-Reply-To: References: In-Reply-To: References: Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sat, 29 Jan 2011 17:40:59 +0000 (UTC) diff --git a/hw/pci.c b/hw/pci.c index 612ccaa..0a32a93 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -738,6 +738,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, return NULL; } pci_dev->bus = bus; + pci_dev->dma.mmu = &bus->mmu; pci_dev->devfn = devfn; pstrcpy(pci_dev->name, sizeof(pci_dev->name), name); pci_dev->irq_state = 0; @@ -2163,3 +2164,9 @@ int pci_qdev_find_device(const char *id, PCIDevice **pdev) return rc; } + +void pci_register_iommu(PCIDevice *dev, DMATranslateFunc *translate) +{ + dev->bus->mmu.iommu = &dev->qdev; + dev->bus->mmu.translate = translate; +} diff --git a/hw/pci.h b/hw/pci.h index 550531b..4bb0a94 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -5,6 +5,7 @@ #include "qobject.h" #include "qdev.h" +#include "dma_rw.h" /* PCI includes legacy ISA access. */ #include "isa.h" @@ -128,6 +129,10 @@ enum { struct PCIDevice { DeviceState qdev; + + /* For devices which do DMA. */ + DMADevice dma; + /* PCI config space */ uint8_t *config; @@ -267,6 +272,8 @@ void pci_bridge_update_mappings(PCIBus *b); void pci_device_deassert_intx(PCIDevice *dev); +void pci_register_iommu(PCIDevice *dev, DMATranslateFunc *translate); + static inline void pci_set_byte(uint8_t *config, uint8_t val) { diff --git a/hw/pci_internals.h b/hw/pci_internals.h index fbe1866..6452e8c 100644 --- a/hw/pci_internals.h +++ b/hw/pci_internals.h @@ -16,6 +16,7 @@ extern struct BusInfo pci_bus_info; struct PCIBus { BusState qbus; + DMAMmu mmu; uint8_t devfn_min; pci_set_irq_fn set_irq; pci_map_irq_fn map_irq;