From patchwork Tue Nov 8 13:29:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 81317 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp1549094qge; Tue, 8 Nov 2016 05:32:10 -0800 (PST) X-Received: by 10.99.238.17 with SMTP id e17mr6825315pgi.154.1478611930828; Tue, 08 Nov 2016 05:32:10 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s66si36946507pfg.201.2016.11.08.05.32.10; Tue, 08 Nov 2016 05:32:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752472AbcKHNb6 (ORCPT + 27 others); Tue, 8 Nov 2016 08:31:58 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:11982 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751736AbcKHNaV (ORCPT ); Tue, 8 Nov 2016 08:30:21 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OGB0014SS6GLF40@mailout1.w1.samsung.com>; Tue, 08 Nov 2016 13:30:16 +0000 (GMT) Received: from eusmges4.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20161108133016eucas1p2c027356e9c5d22e2e9ae41aff0e1a872~FFZzkv8kx0098300983eucas1p2g; Tue, 8 Nov 2016 13:30:16 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges4.samsung.com (EUCPMTA) with SMTP id EC.7F.28332.763D1285; Tue, 8 Nov 2016 13:30:15 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20161108133015eucas1p234c8c7076bcda5020ae8b78e87a0203d~FFZy7I2sb0086500865eucas1p2H; Tue, 8 Nov 2016 13:30:15 +0000 (GMT) X-AuditID: cbfec7f4-f791c6d000006eac-ac-5821d3677d80 Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id F8.97.07726.663D1285; Tue, 8 Nov 2016 13:30:14 +0000 (GMT) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OGB005BFS5J9G30@eusync1.samsung.com>; Tue, 08 Nov 2016 13:30:15 +0000 (GMT) From: Marek Szyprowski To: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, linux-samsung-soc@vger.kernel.org, Joerg Roedel Cc: Marek Szyprowski , Inki Dae , Kukjin Kim , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz , "Rafael J. Wysocki" , Mark Brown , "Luis R. Rodriguez" , Greg Kroah-Hartman , Tomeu Vizoso , Lukas Wunner , Kevin Hilman , Tobias Jakobi , Tomasz Figa Subject: [PATCH v6 2/7] iommu/exynos: Remove dead code Date: Tue, 08 Nov 2016 14:29:19 +0100 Message-id: <1478611764-6473-3-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1478611764-6473-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAAzWSa0hTcRjG/e+cnXNcrQ7z0h81zZEQRqYg+s9JJEgeCKRPKhLm0sO0nNqm ln4I8+7IO6vhLdO0mpqlaziLvLJ5Ce+Wk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pS3WHrnLbnFjwlNGizOnL7FatK3+wGqxatcfRou+tZfYHIQ9nhycx+Sx4+4SRo+ds+6ye2xa 1cnmsX/uGnaPyTeWM3r8O8buseVqO4tH35ZVjB6fN8l5zGjfxhrAHeVmk5GamJJapJCal5yf kpmXbqsUGuKma6GkkJeYm2qrFKHrGxKkpFCWmFMK5BkZoAEH5wD3YCV9uwS3jNU7ZrAWHFOt ODfvJHsD4ye5LkZODgkBE4m5B9cxQthiEhfurWcDsYUEljBK9B6u6WLkArKbmCQ6/kxhAUmw CRhKdL3tYgNJiAgsZpRoODSFEcRhFjjGIrG45yAzSJWwgJnEq+aFrCA2i4CqxJxHV8HG8gq4 S2z7vZsJYp2cxMljk8FqOAU8JE6seMgEsdpd4teGZ+wTGHkXMDKsYhRJLS3OTc8tNtQrTswt Ls1L10vOz93ECIy+bcd+bt7BeGlj8CFGAQ5GJR7eF/0KEUKsiWXFlbmHGCU4mJVEeC+fU4wQ 4k1JrKxKLcqPLyrNSS0+xGgKdNREZinR5HxgYsgriTc0MTS3NDQytrAwNzJSEuct+XAlXEgg PbEkNTs1tSC1CKaPiYNTqoFRkfW9hvyOsrWsr54Wdi3P/cjtMMmJRbxyemm999rfN28qa5xo 3i+y7J20iPPec5PMb+3tKNlnumWigdpD7aq1PIKLnm15rXJ9rlPG3bAHcUITkg+uUZ7J7JRp tIJZTiHWMTP5q3utTonOhru6LYLzOEJC41PsFn6cvPh7vuPPy1x/Tm3OeMqrxFKckWioxVxU nAgARwz4mtQCAAA= X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20161108133015eucas1p234c8c7076bcda5020ae8b78e87a0203d X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 X-Local-Sender: =?UTF-8?B?TWFyZWsgU3p5cHJvd3NraRtTUlBPTC1LZXJuZWwgKFRQKRs=?= =?UTF-8?B?7IK87ISx7KCE7J6QG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Global-Sender: =?UTF-8?B?TWFyZWsgU3p5cHJvd3NraRtTUlBPTC1LZXJuZWwgKFRQKRtT?= =?UTF-8?B?YW1zdW5nIEVsZWN0cm9uaWNzG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Sender-Code: =?UTF-8?B?QzEwG0VIURtDMTBDRDAyQ0QwMjczOTI=?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20161108133015eucas1p234c8c7076bcda5020ae8b78e87a0203d X-RootMTR: 20161108133015eucas1p234c8c7076bcda5020ae8b78e87a0203d References: <1478611764-6473-1-git-send-email-m.szyprowski@samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org __sysmmu_enable/disable functions were designed to do ref-count based operations, but current code always calls them only once, so the code for checking the conditions and invalid conditions can be simply removed without any influence to the driver operation. Signed-off-by: Marek Szyprowski --- drivers/iommu/exynos-iommu.c | 65 ++++++++++++-------------------------------- 1 file changed, 17 insertions(+), 48 deletions(-) -- 1.9.1 diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index 8ba0d60..4056228 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -460,9 +460,6 @@ static bool __sysmmu_disable(struct sysmmu_drvdata *data) __sysmmu_disable_nocount(data); dev_dbg(data->sysmmu, "Disabled\n"); - } else { - dev_dbg(data->sysmmu, "%d times left to disable\n", - data->activations); } spin_unlock_irqrestore(&data->lock, flags); @@ -508,29 +505,18 @@ static void __sysmmu_enable_nocount(struct sysmmu_drvdata *data) static int __sysmmu_enable(struct sysmmu_drvdata *data, phys_addr_t pgtable, struct exynos_iommu_domain *domain) { - int ret = 0; unsigned long flags; spin_lock_irqsave(&data->lock, flags); if (set_sysmmu_active(data)) { data->pgtable = pgtable; data->domain = domain; - __sysmmu_enable_nocount(data); - dev_dbg(data->sysmmu, "Enabled\n"); - } else { - ret = (pgtable == data->pgtable) ? 1 : -EBUSY; - - dev_dbg(data->sysmmu, "already enabled\n"); } - - if (WARN_ON(ret < 0)) - set_sysmmu_inactive(data); /* decrement count */ - spin_unlock_irqrestore(&data->lock, flags); - return ret; + return 0; } static void sysmmu_tlb_invalidate_flpdcache(struct sysmmu_drvdata *data, @@ -793,8 +779,8 @@ static void exynos_iommu_domain_free(struct iommu_domain *iommu_domain) spin_lock_irqsave(&domain->lock, flags); list_for_each_entry_safe(data, next, &domain->clients, domain_node) { - if (__sysmmu_disable(data)) - data->master = NULL; + __sysmmu_disable(data); + data->master = NULL; list_del_init(&data->domain_node); } @@ -829,31 +815,23 @@ static void exynos_iommu_detach_device(struct iommu_domain *iommu_domain, phys_addr_t pagetable = virt_to_phys(domain->pgtable); struct sysmmu_drvdata *data, *next; unsigned long flags; - bool found = false; if (!has_sysmmu(dev) || owner->domain != iommu_domain) return; spin_lock_irqsave(&domain->lock, flags); list_for_each_entry_safe(data, next, &domain->clients, domain_node) { - if (data->master == dev) { - if (__sysmmu_disable(data)) { - data->master = NULL; - list_del_init(&data->domain_node); - } - pm_runtime_put(data->sysmmu); - found = true; - } + __sysmmu_disable(data); + data->master = NULL; + list_del_init(&data->domain_node); + pm_runtime_put(data->sysmmu); } spin_unlock_irqrestore(&domain->lock, flags); owner->domain = NULL; - if (found) - dev_dbg(dev, "%s: Detached IOMMU with pgtable %pa\n", - __func__, &pagetable); - else - dev_err(dev, "%s: No IOMMU is attached\n", __func__); + dev_dbg(dev, "%s: Detached IOMMU with pgtable %pa\n", __func__, + &pagetable); } static int exynos_iommu_attach_device(struct iommu_domain *iommu_domain, @@ -864,7 +842,6 @@ static int exynos_iommu_attach_device(struct iommu_domain *iommu_domain, struct sysmmu_drvdata *data; phys_addr_t pagetable = virt_to_phys(domain->pgtable); unsigned long flags; - int ret = -ENODEV; if (!has_sysmmu(dev)) return -ENODEV; @@ -874,27 +851,19 @@ static int exynos_iommu_attach_device(struct iommu_domain *iommu_domain, list_for_each_entry(data, &owner->controllers, owner_node) { pm_runtime_get_sync(data->sysmmu); - ret = __sysmmu_enable(data, pagetable, domain); - if (ret >= 0) { - data->master = dev; + __sysmmu_enable(data, pagetable, domain); + data->master = dev; - spin_lock_irqsave(&domain->lock, flags); - list_add_tail(&data->domain_node, &domain->clients); - spin_unlock_irqrestore(&domain->lock, flags); - } - } - - if (ret < 0) { - dev_err(dev, "%s: Failed to attach IOMMU with pgtable %pa\n", - __func__, &pagetable); - return ret; + spin_lock_irqsave(&domain->lock, flags); + list_add_tail(&data->domain_node, &domain->clients); + spin_unlock_irqrestore(&domain->lock, flags); } owner->domain = iommu_domain; - dev_dbg(dev, "%s: Attached IOMMU with pgtable %pa %s\n", - __func__, &pagetable, (ret == 0) ? "" : ", again"); + dev_dbg(dev, "%s: Attached IOMMU with pgtable %pa\n", __func__, + &pagetable); - return ret; + return 0; } static sysmmu_pte_t *alloc_lv2entry(struct exynos_iommu_domain *domain,