From patchwork Mon Apr 2 21:14:40 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 150248 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 B3D6CB6FA3 for ; Tue, 3 Apr 2012 07:15:07 +1000 (EST) Received: from localhost ([::1]:57879 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SEoaf-0007HY-HD for incoming@patchwork.ozlabs.org; Mon, 02 Apr 2012 17:15:05 -0400 Received: from eggs.gnu.org ([208.118.235.92]:60732) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SEoaT-0007EM-QJ for qemu-devel@nongnu.org; Mon, 02 Apr 2012 17:14:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SEoaR-0003TD-JO for qemu-devel@nongnu.org; Mon, 02 Apr 2012 17:14:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:61669) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SEoaR-0003Qz-Ar for qemu-devel@nongnu.org; Mon, 02 Apr 2012 17:14:51 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q32LEfVg007443 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 2 Apr 2012 17:14:41 -0400 Received: from bling.home (ovpn-113-138.phx2.redhat.com [10.3.113.138]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q32LEeMs028329; Mon, 2 Apr 2012 17:14:40 -0400 From: Alex Williamson To: david@gibson.dropbear.id.au, dwmw2@infradead.org Date: Mon, 02 Apr 2012 15:14:40 -0600 Message-ID: <20120402211440.28977.74440.stgit@bling.home> In-Reply-To: <20120402203721.28977.95285.stgit@bling.home> References: <20120402203721.28977.95285.stgit@bling.home> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: kvm@vger.kernel.org, joerg.roedel@amd.com, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, qemu-devel@nongnu.org, alex.williamson@redhat.com Subject: [Qemu-devel] [RFC PATCH 1/3] iommu: Introduce iommu_group 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 IOMMUs often do not have visibility of individual devices in the system. Due to IOMMU design, bus topology, or device quirks, we can often only identify groups of devices. Examples include Intel VT-d & AMD-Vi which often have function level visibility compared to POWER partitionable endpoints which have bridge level granularity. PCIe-to-PCI bridges also often cloud the IOMMU visibility as it cannot distiguish devices behind the bridge. Devices can also sometimes hurt themselves by initiating DMA using the wrong source ID on a multifunction PCI device. IOMMU groups are meant to help solve these problems and hopefully become the working unit of the IOMMI API. Signed-off-by: Alex Williamson --- include/linux/device.h | 2 ++ include/linux/iommu.h | 5 +++++ 2 files changed, 7 insertions(+), 0 deletions(-) diff --git a/include/linux/device.h b/include/linux/device.h index b63fb39..6acab1c 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -35,6 +35,7 @@ struct subsys_private; struct bus_type; struct device_node; struct iommu_ops; +struct iommu_group; struct bus_attribute { struct attribute attr; @@ -683,6 +684,7 @@ struct device { const struct attribute_group **groups; /* optional groups */ void (*release)(struct device *dev); + struct iommu_group *iommu_group; }; /* Get the wakeup routines, which depend on struct device */ diff --git a/include/linux/iommu.h b/include/linux/iommu.h index d937580..2ee375c 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -26,6 +26,7 @@ #define IOMMU_CACHE (4) /* DMA cache coherency */ struct iommu_ops; +struct iommu_group; struct bus_type; struct device; struct iommu_domain; @@ -78,6 +79,9 @@ struct iommu_ops { unsigned long pgsize_bitmap; }; +struct iommu_group { +}; + extern int bus_set_iommu(struct bus_type *bus, struct iommu_ops *ops); extern bool iommu_present(struct bus_type *bus); extern struct iommu_domain *iommu_domain_alloc(struct bus_type *bus); @@ -140,6 +144,7 @@ static inline int report_iommu_fault(struct iommu_domain *domain, #else /* CONFIG_IOMMU_API */ struct iommu_ops {}; +struct iommu_group {}; static inline bool iommu_present(struct bus_type *bus) {