From patchwork Mon Jan 26 23:51:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 5713201 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E3456C058D for ; Mon, 26 Jan 2015 23:54:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 064C5201CD for ; Mon, 26 Jan 2015 23:54:41 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 42289201BC for ; Mon, 26 Jan 2015 23:54:40 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YFtS3-00029x-Ab; Mon, 26 Jan 2015 23:52:15 +0000 Received: from 8bytes.org ([81.169.241.247] helo=theia.8bytes.org) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YFtRy-00022V-FL; Mon, 26 Jan 2015 23:52:11 +0000 Received: by theia.8bytes.org (Postfix, from userid 1000) id BA07937A; Tue, 27 Jan 2015 00:51:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1422316306; bh=ynjip6rH+vl2uWSrH5VsCAN985UyKzgoWi8uAt5mTEU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eB8LSnhdnwSQmwR96ZKQGVO7eAK7vAg2gqaO/pErVzb4ju5TxK5FJWiW+QQiB+hnX sniOrRqu9Qj4n5do1t30vSmrCPzMSIVo+La8AiZxnb7pI8g8kQ+bf0avLLMi6/X5Lc vYz2Tc0wwHYoPvWzLjIyjgdhAP2VJ2xSZFyn6MmjNg0FB8l40pd6kKFqkRMwj118Yb NszLlgPrGfPR9yW7ooxO2QxlVqO57+TCfPFz5EQ3UP92w3zxaO3Um/KWjll1dnrktj ufrb+glv+3Lb1u8eRckyZwwUFcmzvWfh0seFfjb2ds7mnLoYbGzdXw1KTsbn1v8aT2 ilpP6unxdlErQ== From: Joerg Roedel To: iommu@lists.linux-foundation.org Subject: [PATCH 02/15] iommu: Introduce iommu domain types Date: Tue, 27 Jan 2015 00:51:32 +0100 Message-Id: <1422316305-19216-3-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1422316305-19216-1-git-send-email-joro@8bytes.org> References: <1422316305-19216-1-git-send-email-joro@8bytes.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150126_155210_691971_46C943BB X-CRM114-Status: GOOD ( 11.43 ) X-Spam-Score: -0.1 (/) Cc: Alexandre Courbot , linux-samsung-soc@vger.kernel.org, Heiko Stuebner , Arnd Bergmann , Stephen Warren , Joerg Roedel , Will Deacon , linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, Alex Williamson , Kukjin Kim , Thierry Reding , jroedel@suse.de, linux-tegra@vger.kernel.org, David Woodhouse , linux-arm-kernel@lists.infradead.org, Hiroshi Doyu X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Joerg Roedel This allows to handle domains differently based on their type in the future. An IOMMU driver can implement certain optimizations for DMA-API domains for example. Signed-off-by: Joerg Roedel --- drivers/iommu/iommu.c | 5 +++-- include/linux/iommu.h | 11 ++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 684efc0..ab24d77 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -909,14 +909,15 @@ struct iommu_domain *iommu_domain_alloc(struct bus_type *bus) ops = bus->iommu_ops; if (ops->domain_alloc) - domain = ops->domain_alloc(); + domain = ops->domain_alloc(IOMMU_DOMAIN_UNMANAGED); else domain = kzalloc(sizeof(*domain), GFP_KERNEL); if (!domain) return NULL; - domain->ops = bus->iommu_ops; + domain->ops = bus->iommu_ops; + domain->type = IOMMU_DOMAIN_UNMANAGED; if (ops->domain_init && domain->ops->domain_init(domain)) goto out_free; diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 69d1d12..0b67f65 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -51,7 +51,16 @@ struct iommu_domain_geometry { bool force_aperture; /* DMA only allowed in mappable range? */ }; +/* This are the possible domain-types */ +enum iommu_domain_type { + IOMMU_DOMAIN_DMA, /* Domain used for DMA-API */ + IOMMU_DOMAIN_IDENTITY, /* Identity mapped domain */ + IOMMU_DOMAIN_UNMANAGED, /* Domain mappings are managed by a third party + user (like KVM or VFIO) */ +}; + struct iommu_domain { + enum iommu_domain_type type; const struct iommu_ops *ops; void *priv; iommu_fault_handler_t handler; @@ -117,7 +126,7 @@ struct iommu_ops { void (*domain_destroy)(struct iommu_domain *domain); /* Domain allocation and freeing by the iommu driver */ - struct iommu_domain *(*domain_alloc)(void); + struct iommu_domain *(*domain_alloc)(enum iommu_domain_type); void (*domain_free)(struct iommu_domain *); int (*attach_dev)(struct iommu_domain *domain, struct device *dev);