From patchwork Thu Feb 18 14:12:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 62180 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp610596lbl; Thu, 18 Feb 2016 06:13:33 -0800 (PST) X-Received: by 10.66.63.104 with SMTP id f8mr10331571pas.109.1455804808740; Thu, 18 Feb 2016 06:13:28 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f63si9683783pfj.137.2016.02.18.06.13.28; Thu, 18 Feb 2016 06:13:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756806AbcBRON1 (ORCPT + 4 others); Thu, 18 Feb 2016 09:13:27 -0500 Received: from mailout4.w1.samsung.com ([210.118.77.14]:37168 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756749AbcBRONZ (ORCPT ); Thu, 18 Feb 2016 09:13:25 -0500 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O2Q00LF6Y69DTA0@mailout4.w1.samsung.com> for linux-samsung-soc@vger.kernel.org; Thu, 18 Feb 2016 14:13:21 +0000 (GMT) X-AuditID: cbfec7f4-f79026d00000418a-06-56c5d181c45a Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 90.1B.16778.181D5C65; Thu, 18 Feb 2016 14:13:21 +0000 (GMT) Received: from amdc1339.digital.local ([106.116.147.30]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O2Q00576Y5X95B0@eusync4.samsung.com>; Thu, 18 Feb 2016 14:13:21 +0000 (GMT) From: Marek Szyprowski To: iommu@lists.linux-foundation.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Marek Szyprowski , Joerg Roedel , Inki Dae , Kukjin Kim , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz Subject: [PATCH v2 02/13] iommu: exynos: add support for IOMMU_DOMAIN_DMA domain type Date: Thu, 18 Feb 2016 15:12:49 +0100 Message-id: <1455804780-9616-3-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.2 In-reply-to: <1455804780-9616-1-git-send-email-m.szyprowski@samsung.com> References: <1455804780-9616-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrILMWRmVeSWpSXmKPExsVy+t/xa7qNF4+GGSybqWuxccZ6VotJ9yew WCzYb23ROXsDu8XrF4YW/Y9fM1tsenyN1WLG+X1MFmuP3GV34PR4cnAek8emVZ1sHpuX1HtM vrGc0aNvyypGj8+b5ALYorhsUlJzMstSi/TtErgyPvV/ZSn4JlBx9fo51gbGCXxdjJwcEgIm Ept/bWKGsMUkLtxbz9bFyMUhJLCUUeLSk8uMEE4Tk8TBs3dZQarYBAwlut52sYHYIgL5Ei/2 /mUBKWIW+MUoca6znQkkISwQLtHSu5kRxGYRUJX49OgsWAOvgLvEsobTLBDr5CT+v1wBVs8p 4CGx+dQGsHohoJo/D2cyTWDkXcDIsIpRNLU0uaA4KT3XUK84Mbe4NC9dLzk/dxMjJOC+7GBc fMzqEKMAB6MSDy/H6yNhQqyJZcWVuYcYJTiYlUR4d+89GibEm5JYWZValB9fVJqTWnyIUZqD RUmcd+6u9yFCAumJJanZqakFqUUwWSYOTqkGxva/Gp1XZfqmPrt87sIppkuVPbtPRC2MC9+h xbNhhu6WiQfXSG50qeZ8MV1V1pVPTn2ReP0sp9BPhlo/cpwuWZ+Oe1Mqo+gYZnlry9EgUYUt kSsYHMsqVvEueDBjw4doz8dHThXqTPyXnjn1Y2Tjenvf5rJbm7LX7I+PCY9/fXqpZZznS6WD n5RYijMSDbWYi4oTAcfaTtY0AgAA Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org This patch adds support for DMA domain type. Such domain have DMA cookie prepared and can be used by generic DMA-IOMMU glue layer. Signed-off-by: Marek Szyprowski --- drivers/iommu/exynos-iommu.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) -- 1.9.2 -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index 4fc079073c86..595e0da55db4 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -25,9 +25,9 @@ #include #include #include +#include #include -#include #include typedef u32 sysmmu_iova_t; @@ -662,16 +662,21 @@ static struct iommu_domain *exynos_iommu_domain_alloc(unsigned type) struct exynos_iommu_domain *domain; int i; - if (type != IOMMU_DOMAIN_UNMANAGED) - return NULL; domain = kzalloc(sizeof(*domain), GFP_KERNEL); if (!domain) return NULL; + if (type == IOMMU_DOMAIN_DMA) { + if (iommu_get_dma_cookie(&domain->domain) != 0) + goto err_pgtable; + } else if (type != IOMMU_DOMAIN_UNMANAGED) { + goto err_pgtable; + } + domain->pgtable = (sysmmu_pte_t *)__get_free_pages(GFP_KERNEL, 2); if (!domain->pgtable) - goto err_pgtable; + goto err_dma_cookie; domain->lv2entcnt = (short *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, 1); if (!domain->lv2entcnt) @@ -703,6 +708,9 @@ static struct iommu_domain *exynos_iommu_domain_alloc(unsigned type) err_counter: free_pages((unsigned long)domain->pgtable, 2); +err_dma_cookie: + if (type == IOMMU_DOMAIN_DMA) + iommu_put_dma_cookie(&domain->domain); err_pgtable: kfree(domain); return NULL; @@ -727,6 +735,9 @@ static void exynos_iommu_domain_free(struct iommu_domain *iommu_domain) spin_unlock_irqrestore(&domain->lock, flags); + if (iommu_domain->type == IOMMU_DOMAIN_DMA) + iommu_put_dma_cookie(iommu_domain); + for (i = 0; i < NUM_LV1ENTRIES; i++) if (lv1ent_page(domain->pgtable + i)) kmem_cache_free(lv2table_kmem_cache,