From patchwork Tue Feb 16 14:56:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 62040 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1711995lbl; Tue, 16 Feb 2016 06:57:54 -0800 (PST) X-Received: by 10.66.102.40 with SMTP id fl8mr31212844pab.126.1455634670378; Tue, 16 Feb 2016 06:57:50 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 70si51706761pfk.205.2016.02.16.06.57.50; Tue, 16 Feb 2016 06:57:50 -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 S932273AbcBPO5s (ORCPT + 4 others); Tue, 16 Feb 2016 09:57:48 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:25233 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755273AbcBPO5m (ORCPT ); Tue, 16 Feb 2016 09:57:42 -0500 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O2N00J54AW4DD30@mailout2.w1.samsung.com> for linux-samsung-soc@vger.kernel.org; Tue, 16 Feb 2016 14:57:40 +0000 (GMT) X-AuditID: cbfec7f4-f79026d00000418a-80-56c338e4702c Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 71.96.16778.4E833C65; Tue, 16 Feb 2016 14:57:40 +0000 (GMT) Received: from amdc1339.digital.local ([106.116.147.30]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O2N00BHIAVXJJA0@eusync3.samsung.com>; Tue, 16 Feb 2016 14:57:40 +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 02/11] iommu: exynos: add support for IOMMU_DOMAIN_DMA domain type Date: Tue, 16 Feb 2016 15:56:55 +0100 Message-id: <1455634624-18130-3-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.2 In-reply-to: <1455634624-18130-1-git-send-email-m.szyprowski@samsung.com> References: <1455634624-18130-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprPLMWRmVeSWpSXmKPExsVy+t/xq7pPLA6HGax7xW2xccZ6VotJ9yew WCzYb23ROXsDu8XrF4YW/Y9fM1tsenyN1WLG+X1MFmuP3GV34PR4cnAek8emVZ1sHpuX1HtM vrGc0aNvyypGj8+b5ALYorhsUlJzMstSi/TtErgyOl7+ZS54I1Dx6OkG9gbGNr4uRk4OCQET icbVvUwQtpjEhXvr2boYuTiEBJYySpye9pAFwmlikrg9ZwsbSBWbgKFE19suMFtEIF/ixd6/ YEXMAr8YJc51toONEhYIkTg+bStQgoODRUBVYuVnc5Awr4CHxIXtU9khtslJ/H+5ggmkhFPA U+Lm5ziQsBBQydFdE1gmMPIuYGRYxSiaWppcUJyUnmuoV5yYW1yal66XnJ+7iRESbF92MC4+ ZnWIUYCDUYmHl8PjUJgQa2JZcWXuIUYJDmYlEd5/r4BCvCmJlVWpRfnxRaU5qcWHGKU5WJTE eefueh8iJJCeWJKanZpakFoEk2Xi4JRqYJw4/9cleU5VSxcNzh2PdsV6iC/hK4qMrBDreOV7 2mB6fsv+H3Jnjnh13LQU0vszZaHB9h0WkyvTF2sVsET83SwnZfLGmc90Goun/SVdQRu5bZzT L/TKuPtPvXFchcXrYFznlw3bql+k7vzpctojctXzgpXL57AVXpBdGPjCUOV+FSur2mf1ZUos xRmJhlrMRcWJAEA8JSYyAgAA 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 4fc0790..595e0da 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,