From patchwork Thu Mar 26 12:43:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 6098801 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 143029F350 for ; Thu, 26 Mar 2015 12:51:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 132A3203AA for ; Thu, 26 Mar 2015 12:51:00 +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 6AC6E203A1 for ; Thu, 26 Mar 2015 12:50:54 +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 1Yb7Ci-00026B-AX; Thu, 26 Mar 2015 12:48:08 +0000 Received: from 8bytes.org ([2a01:238:4383:600:38bc:a715:4b6d:a889] helo=theia.8bytes.org) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Yb799-0007Ea-BD; Thu, 26 Mar 2015 12:44:33 +0000 Received: by theia.8bytes.org (Postfix, from userid 1000) id E0CEB3EE; Thu, 26 Mar 2015 13:43:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1427373822; bh=5fdcZJHaIlzD2pfLxR+v3+2f9hckp9xcWE3R/Jg4iAg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dYUpK/xKXQomh4QHrED+hR+qJwKzljcu0z9wNGDX0bCZ2qdBxRf/i0H3fx5GdKGVz NwmTBogdO05RBv/opd/F6XiT49+oXb1sAbZlQN0c5JgbTCHdPi7zfObvhMNc/vob2y 4Cm4hhPvgKeYLzHuiQibNN28GWmlY486MghEfJctpxE+bsmjDLpeBw1KfGT2ghfHqj RWhGAvyYuWqhBwtraKv+FOZ2sDSo/tyFrs79hAKj9dqTOmAEtqoW6pwGGKmKOEQQNs M1aR8qzsNyqYPr0WI0ra/LCppx9dVd1scCcmIUkbZ7PCboT27VTqsiRo7QeiEjwgrR mWQhWGnqyKtNg== From: Joerg Roedel To: iommu@lists.linux-foundation.org Subject: [PATCH 06/16] iommu/omap: Make use of domain_alloc and domain_free Date: Thu, 26 Mar 2015 13:43:09 +0100 Message-Id: <1427373799-18662-7-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1427373799-18662-1-git-send-email-joro@8bytes.org> References: <1427373799-18662-1-git-send-email-joro@8bytes.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150326_054427_890924_38B9F23D X-CRM114-Status: GOOD ( 13.21 ) 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, Yingjoe Chen , 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 Implement the new domain_alloc and domain_free call-backs and remove the old domain_init/destroy ones. Signed-off-by: Joerg Roedel --- drivers/iommu/omap-iommu.c | 49 +++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c index a4ba851..a22c33d 100644 --- a/drivers/iommu/omap-iommu.c +++ b/drivers/iommu/omap-iommu.c @@ -59,6 +59,7 @@ struct omap_iommu_domain { struct omap_iommu *iommu_dev; struct device *dev; spinlock_t lock; + struct iommu_domain domain; }; #define MMU_LOCK_BASE_SHIFT 10 @@ -80,6 +81,15 @@ static struct platform_driver omap_iommu_driver; static struct kmem_cache *iopte_cachep; /** + * to_omap_domain - Get struct omap_iommu_domain from generic iommu_domain + * @dom: generic iommu domain handle + **/ +static struct omap_iommu_domain *to_omap_domain(struct iommu_domain *dom) +{ + return container_of(dom, struct omap_iommu_domain, domain); +} + +/** * omap_iommu_save_ctx - Save registers for pm off-mode support * @dev: client device **/ @@ -901,7 +911,7 @@ static irqreturn_t iommu_fault_handler(int irq, void *data) u32 *iopgd, *iopte; struct omap_iommu *obj = data; struct iommu_domain *domain = obj->domain; - struct omap_iommu_domain *omap_domain = domain->priv; + struct omap_iommu_domain *omap_domain = to_omap_domain(domain); if (!omap_domain->iommu_dev) return IRQ_NONE; @@ -1113,7 +1123,7 @@ static u32 iotlb_init_entry(struct iotlb_entry *e, u32 da, u32 pa, int pgsz) static int omap_iommu_map(struct iommu_domain *domain, unsigned long da, phys_addr_t pa, size_t bytes, int prot) { - struct omap_iommu_domain *omap_domain = domain->priv; + struct omap_iommu_domain *omap_domain = to_omap_domain(domain); struct omap_iommu *oiommu = omap_domain->iommu_dev; struct device *dev = oiommu->dev; struct iotlb_entry e; @@ -1140,7 +1150,7 @@ static int omap_iommu_map(struct iommu_domain *domain, unsigned long da, static size_t omap_iommu_unmap(struct iommu_domain *domain, unsigned long da, size_t size) { - struct omap_iommu_domain *omap_domain = domain->priv; + struct omap_iommu_domain *omap_domain = to_omap_domain(domain); struct omap_iommu *oiommu = omap_domain->iommu_dev; struct device *dev = oiommu->dev; @@ -1152,7 +1162,7 @@ static size_t omap_iommu_unmap(struct iommu_domain *domain, unsigned long da, static int omap_iommu_attach_dev(struct iommu_domain *domain, struct device *dev) { - struct omap_iommu_domain *omap_domain = domain->priv; + struct omap_iommu_domain *omap_domain = to_omap_domain(domain); struct omap_iommu *oiommu; struct omap_iommu_arch_data *arch_data = dev->archdata.iommu; int ret = 0; @@ -1212,17 +1222,20 @@ static void _omap_iommu_detach_dev(struct omap_iommu_domain *omap_domain, static void omap_iommu_detach_dev(struct iommu_domain *domain, struct device *dev) { - struct omap_iommu_domain *omap_domain = domain->priv; + struct omap_iommu_domain *omap_domain = to_omap_domain(domain); spin_lock(&omap_domain->lock); _omap_iommu_detach_dev(omap_domain, dev); spin_unlock(&omap_domain->lock); } -static int omap_iommu_domain_init(struct iommu_domain *domain) +static struct iommu_domain *omap_iommu_domain_alloc(unsigned type) { struct omap_iommu_domain *omap_domain; + if (type != IOMMU_DOMAIN_UNMANAGED) + return NULL; + omap_domain = kzalloc(sizeof(*omap_domain), GFP_KERNEL); if (!omap_domain) { pr_err("kzalloc failed\n"); @@ -1244,25 +1257,21 @@ static int omap_iommu_domain_init(struct iommu_domain *domain) clean_dcache_area(omap_domain->pgtable, IOPGD_TABLE_SIZE); spin_lock_init(&omap_domain->lock); - domain->priv = omap_domain; + omap_domain->domain.geometry.aperture_start = 0; + omap_domain->domain.geometry.aperture_end = (1ULL << 32) - 1; + omap_domain->domain.geometry.force_aperture = true; - domain->geometry.aperture_start = 0; - domain->geometry.aperture_end = (1ULL << 32) - 1; - domain->geometry.force_aperture = true; - - return 0; + return &omap_domain->domain; fail_nomem: kfree(omap_domain); out: - return -ENOMEM; + return NULL; } -static void omap_iommu_domain_destroy(struct iommu_domain *domain) +static void omap_iommu_domain_free(struct iommu_domain *domain) { - struct omap_iommu_domain *omap_domain = domain->priv; - - domain->priv = NULL; + struct omap_iommu_domain *omap_domain = to_omap_domain(domain); /* * An iommu device is still attached @@ -1278,7 +1287,7 @@ static void omap_iommu_domain_destroy(struct iommu_domain *domain) static phys_addr_t omap_iommu_iova_to_phys(struct iommu_domain *domain, dma_addr_t da) { - struct omap_iommu_domain *omap_domain = domain->priv; + struct omap_iommu_domain *omap_domain = to_omap_domain(domain); struct omap_iommu *oiommu = omap_domain->iommu_dev; struct device *dev = oiommu->dev; u32 *pgd, *pte; @@ -1358,8 +1367,8 @@ static void omap_iommu_remove_device(struct device *dev) } static const struct iommu_ops omap_iommu_ops = { - .domain_init = omap_iommu_domain_init, - .domain_destroy = omap_iommu_domain_destroy, + .domain_alloc = omap_iommu_domain_alloc, + .domain_free = omap_iommu_domain_free, .attach_dev = omap_iommu_attach_dev, .detach_dev = omap_iommu_detach_dev, .map = omap_iommu_map,