From patchwork Thu Feb 18 14:12:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 62178 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp610549lbl; Thu, 18 Feb 2016 06:13:27 -0800 (PST) X-Received: by 10.98.65.91 with SMTP id o88mr10260778pfa.114.1455804806911; Thu, 18 Feb 2016 06:13:26 -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.26; Thu, 18 Feb 2016 06:13:26 -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 S1756769AbcBRONZ (ORCPT + 4 others); Thu, 18 Feb 2016 09:13:25 -0500 Received: from mailout3.w1.samsung.com ([210.118.77.13]:53098 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756713AbcBRONY (ORCPT ); Thu, 18 Feb 2016 09:13:24 -0500 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O2Q00KMXY69TEA0@mailout3.w1.samsung.com> for linux-samsung-soc@vger.kernel.org; Thu, 18 Feb 2016 14:13:21 +0000 (GMT) X-AuditID: cbfec7f4-f79026d00000418a-04-56c5d1814acd Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id FE.0B.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 01/13] iommu: exynos: rework iommu group initialization Date: Thu, 18 Feb 2016 15:12:48 +0100 Message-id: <1455804780-9616-2-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+GGTT3CVlsnLGe1WLS/Qks Fgv2W1t0zt7AbvH6haFF/+PXzBabHl9jtZhxfh+Txdojd9kdOD2eHJzH5LFpVSebx+Yl9R6T byxn9OjbsorR4/MmuQC2KC6blNSczLLUIn27BK6MjQvuMRYc4quYfKyLsYGxiaeLkZNDQsBE 4tTht2wQtpjEhXvrgWwuDiGBpYwSv798Z4FwmpgkDp69ywpSxSZgKNH1tgusQ0QgX+LF3r9g RcwCvxglznW2M4EkhAW8JF4d38kMYrMIqEp86f8FFucVcJe4dHETE8Q6OYn/L1eA2ZwCHhKb T21gBLGFgGr+PJzJNIGRdwEjwypG0dTS5ILipPRcQ73ixNzi0rx0veT83E2MkID7soNx8TGr Q4wCHIxKPLwcr4+ECbEmlhVX5h5ilOBgVhLh3b33aJgQb0piZVVqUX58UWlOavEhRmkOFiVx 3rm73ocICaQnlqRmp6YWpBbBZJk4OKUaGEU5PxX8E2HW6p6dHZwRxSPCbD9v1fk+xrjdJ6Nc 59xrWKktYDH/nuRSWcZavcLdlRvX5L0JudcfopCodlaNRadY5/jOU3XTDU31uNb5qa2eemRp dnrmnIYzkUuDLXSnlCwKiX5Q971u+VuVn7/+vD/39+zGr1sXzqioalvUx3Zm8XeP7b08p5VY ijMSDbWYi4oTAY/UYps0AgAA Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org This patch replaces custom code in add_device implementation with iommu_group_get_for_dev() call and provides the needed callback. Signed-off-by: Marek Szyprowski --- drivers/iommu/exynos-iommu.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 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 97c41b8ab5d9..4fc079073c86 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -1114,28 +1114,32 @@ static phys_addr_t exynos_iommu_iova_to_phys(struct iommu_domain *iommu_domain, return phys; } +static struct iommu_group *get_device_iommu_group(struct device *dev) +{ + struct iommu_group *group; + + group = iommu_group_get(dev); + if (!group) + group = iommu_group_alloc(); + + return group; +} + static int exynos_iommu_add_device(struct device *dev) { struct iommu_group *group; - int ret; if (!has_sysmmu(dev)) return -ENODEV; - group = iommu_group_get(dev); + group = iommu_group_get_for_dev(dev); - if (!group) { - group = iommu_group_alloc(); - if (IS_ERR(group)) { - dev_err(dev, "Failed to allocate IOMMU group\n"); - return PTR_ERR(group); - } - } + if (IS_ERR(group)) + return PTR_ERR(group); - ret = iommu_group_add_device(group, dev); iommu_group_put(group); - return ret; + return 0; } static void exynos_iommu_remove_device(struct device *dev) @@ -1182,6 +1186,7 @@ static struct iommu_ops exynos_iommu_ops = { .unmap = exynos_iommu_unmap, .map_sg = default_iommu_map_sg, .iova_to_phys = exynos_iommu_iova_to_phys, + .device_group = get_device_iommu_group, .add_device = exynos_iommu_add_device, .remove_device = exynos_iommu_remove_device, .pgsize_bitmap = SECT_SIZE | LPAGE_SIZE | SPAGE_SIZE,