From patchwork Mon Apr 2 21:14:55 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 150252 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 7F312B6FBD for ; Tue, 3 Apr 2012 07:15:37 +1000 (EST) Received: from localhost ([::1]:60576 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SEob9-0000Qa-B6 for incoming@patchwork.ozlabs.org; Mon, 02 Apr 2012 17:15:35 -0400 Received: from eggs.gnu.org ([208.118.235.92]:60795) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SEoan-0008AW-3X for qemu-devel@nongnu.org; Mon, 02 Apr 2012 17:15:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SEoai-0003d8-Jp for qemu-devel@nongnu.org; Mon, 02 Apr 2012 17:15:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55123) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SEoai-0003ca-CD for qemu-devel@nongnu.org; Mon, 02 Apr 2012 17:15:08 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q32LEuMB029413 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 2 Apr 2012 17:14:56 -0400 Received: from bling.home (ovpn-113-138.phx2.redhat.com [10.3.113.138]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q32LEtYK010063; Mon, 2 Apr 2012 17:14:55 -0400 From: Alex Williamson To: david@gibson.dropbear.id.au, dwmw2@infradead.org Date: Mon, 02 Apr 2012 15:14:55 -0600 Message-ID: <20120402211454.28977.32677.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.25 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 3/3] iommu: Create attach/detach group interface 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 IOMMU ops should be working at a group level rather than a device level as we cannot arbitrarily assign devices from the same group to different domains. For now this is just a simple wrapper that makes use of the dma_dev within a group. Signed-off-by: Alex Williamson --- drivers/iommu/iommu.c | 12 ++++++++++++ include/linux/iommu.h | 15 +++++++++++++++ 2 files changed, 27 insertions(+), 0 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 6a51ed9..af77da1 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -327,6 +327,18 @@ void iommu_detach_device(struct iommu_domain *domain, struct device *dev) } EXPORT_SYMBOL_GPL(iommu_detach_device); +int iommu_attach_group(struct iommu_domain *domain, struct iommu_group *group) +{ + return iommu_attach_device(domain, group->dma_dev); +} +EXPORT_SYMBOL_GPL(iommu_attach_group); + +void iommu_detach_group(struct iommu_domain *domain, struct iommu_group *group) +{ + iommu_detach_device(domain, group->dma_dev); +} +EXPORT_SYMBOL_GPL(iommu_detach_group); + phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, unsigned long iova) { diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 24004d6..d4e9a7a 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -107,6 +107,10 @@ extern int iommu_attach_device(struct iommu_domain *domain, struct device *dev); extern void iommu_detach_device(struct iommu_domain *domain, struct device *dev); +extern int iommu_attach_group(struct iommu_domain *domain, + struct iommu_group *group); +extern void iommu_detach_group(struct iommu_domain *domain, + struct iommu_group *group); extern int iommu_map(struct iommu_domain *domain, unsigned long iova, phys_addr_t paddr, size_t size, int prot); extern size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova, @@ -194,6 +198,17 @@ static inline void iommu_detach_device(struct iommu_domain *domain, { } +static inline int iommu_attach_group(struct iommu_domain *domain, + struct iommu_group *group) +{ + return -ENODEV; +} + +static inline void iommu_detach_group(struct iommu_domain *domain, + struct iommu_group *group) +{ +} + static inline int iommu_map(struct iommu_domain *domain, unsigned long iova, phys_addr_t paddr, int gfp_order, int prot) {