From patchwork Fri Mar 14 05:11:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cho KyongHo X-Patchwork-Id: 3830641 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4CAFFBF540 for ; Fri, 14 Mar 2014 05:12:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 47688202F0 for ; Fri, 14 Mar 2014 05:12:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4658C202B8 for ; Fri, 14 Mar 2014 05:12:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755267AbaCNFLs (ORCPT ); Fri, 14 Mar 2014 01:11:48 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:57710 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752759AbaCNFLn (ORCPT ); Fri, 14 Mar 2014 01:11:43 -0400 Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N2E00283UFHYA40@mailout1.samsung.com>; Fri, 14 Mar 2014 14:11:42 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [203.254.230.51]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id 52.7B.10092.D8F82235; Fri, 14 Mar 2014 14:11:41 +0900 (KST) X-AuditID: cbfee68f-b7f156d00000276c-eb-53228f8db11c Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 10.26.29263.D8F82235; Fri, 14 Mar 2014 14:11:41 +0900 (KST) Received: from DO-PULLIP-CHO07.dsn.sec.samsung.com ([12.36.165.149]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N2E00F09UFGV060@mmp2.samsung.com>; Fri, 14 Mar 2014 14:11:40 +0900 (KST) Date: Fri, 14 Mar 2014 14:11:40 +0900 From: Cho KyongHo To: Linux ARM Kernel , Linux DeviceTree , Linux IOMMU , Linux Kernel , Linux Samsung SOC Cc: Antonios Motakis , Grant Grundler , Joerg Roedel , Kukjin Kim , Prathyush , Rahul Sharma , Sachin Kamat , Sylwester Nawrocki , Tomasz Figa , Varun Sethi Subject: [PATCH v11 21/27] iommu/exynos: change rwlock to spinlock Message-id: <20140314141140.8c05452abfa2375b739845d6@samsung.com> X-Mailer: Sylpheed 3.3.0 (GTK+ 2.10.14; i686-pc-mingw32) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrIIsWRmVeSWpSXmKPExsVy+t8zY93efqVgg0n9+hZ37p5jtZh/BEi8 OvKDyWLBfmuLztkb2C16F1xls9j0+BqrxeVdc9gsZpzfx2RxYcVGdospiw6zWhx+085qcfJP L6PF+hmvWSxm3lrD4sDv8eTgPCaP2Q0XWTz+He5n8rhzbQ+bx+Yl9R6Tbyxn9OjbsorR4/Mm OY8rR88wBXBGcdmkpOZklqUW6dslcGXs+byKseCXTsW6znNsDYzzVbsYOTkkBEwkJh97wARh i0lcuLeeDcQWEljGKPFgQQxMzefDz1gg4tMZJdoOAMW5gOzJTBLbpzWCNbMIqEq0nesAs9kE tCRWzz3OCFIkItDGJPG18RALiMMsMJdZ4uO3OWArhAWcJI59WccIYvMKOEpc/rqYGWKdhcSF pg52iLigxI/J98BWMwNN3bytiRXClpfYvOYtM8hQCYFODokpt4+zQJwhIPFtMsg2DqCErMSm A1AzJSUOrr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zU4kOMyUB/T2SWEk3OByauvJJ4Q2MTMyNLIzML IxNzc9KElcR5D7RaBwoJpCeWpGanphakFsFsYeLglGpgXOSR0R/e5anSsUlrmpXOUrWbPC/W cFzr4c90Y9SwfquiZsoWJ6+l4Wyl5z+5L3Fejesx+3MVf1/rTInaffc3a8KS6nkZ9levTX4k 4WfUe3k39/fTzx1OLSl92mD6OmqX8P+/H2zO3RTabOdacJMvSI9p1iu2W+ELblT9ZTQSCLK4 WMzkce2zEktxRqKhFnNRcSIAHFzLalIDAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Since acquiring read_lock is not more frequent than write_lock, it is not beneficial to use rwlock, this commit changes rwlock to spinlock. Reviewed-by: Grant Grundler Signed-off-by: Cho KyongHo --- drivers/iommu/exynos-iommu.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index 7489343..543ea2e0 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -211,7 +211,7 @@ struct sysmmu_drvdata { struct clk *clk; struct clk *clk_master; int activations; - rwlock_t lock; + spinlock_t lock; struct iommu_domain *domain; bool runtime_active; bool suspended; @@ -334,11 +334,12 @@ static irqreturn_t exynos_sysmmu_irq(int irq, void *dev_id) unsigned long addr = -1; int ret = -ENOSYS; - read_lock(&data->lock); - WARN_ON(!is_sysmmu_active(data)); + spin_lock(&data->lock); + __master_clk_enable(data); + itype = (enum exynos_sysmmu_inttype) __ffs(__raw_readl(data->sfrbase + REG_INT_STATUS)); if (WARN_ON(!((itype >= 0) && (itype < SYSMMU_FAULT_UNKNOWN)))) @@ -371,7 +372,7 @@ static irqreturn_t exynos_sysmmu_irq(int irq, void *dev_id) __master_clk_disable(data); - read_unlock(&data->lock); + spin_unlock(&data->lock); return IRQ_HANDLED; } @@ -392,7 +393,7 @@ static bool __sysmmu_disable(struct sysmmu_drvdata *data) bool disabled; unsigned long flags; - write_lock_irqsave(&data->lock, flags); + spin_lock_irqsave(&data->lock, flags); disabled = set_sysmmu_inactive(data); @@ -409,7 +410,7 @@ static bool __sysmmu_disable(struct sysmmu_drvdata *data) data->activations); } - write_unlock_irqrestore(&data->lock, flags); + spin_unlock_irqrestore(&data->lock, flags); return disabled; } @@ -457,7 +458,7 @@ static int __sysmmu_enable(struct sysmmu_drvdata *data, int ret = 0; unsigned long flags; - write_lock_irqsave(&data->lock, flags); + spin_lock_irqsave(&data->lock, flags); if (set_sysmmu_active(data)) { data->pgtable = pgtable; data->domain = domain; @@ -475,7 +476,7 @@ static int __sysmmu_enable(struct sysmmu_drvdata *data, if (WARN_ON(ret < 0)) set_sysmmu_inactive(data); /* decrement count */ - write_unlock_irqrestore(&data->lock, flags); + spin_unlock_irqrestore(&data->lock, flags); return ret; } @@ -562,7 +563,7 @@ static void sysmmu_tlb_invalidate_entry(struct device *dev, unsigned long iova, for_each_sysmmu_list(dev, list) { struct sysmmu_drvdata *data = dev_get_drvdata(list->sysmmu); - read_lock(&data->lock); + spin_lock(&data->lock); if (is_sysmmu_active(data) && data->runtime_active) { unsigned int num_inv = 1; @@ -594,7 +595,7 @@ static void sysmmu_tlb_invalidate_entry(struct device *dev, unsigned long iova, iova); } - read_unlock(&data->lock); + spin_unlock(&data->lock); } spin_unlock_irqrestore(&owner->lock, flags); @@ -610,7 +611,7 @@ void exynos_sysmmu_tlb_invalidate(struct device *dev) for_each_sysmmu_list(dev, list) { struct sysmmu_drvdata *data = dev_get_drvdata(list->sysmmu); - read_lock(&data->lock); + spin_lock(&data->lock); if (is_sysmmu_active(data) && data->runtime_active) { __master_clk_enable(data); if (sysmmu_block(data->sfrbase)) { @@ -621,7 +622,7 @@ void exynos_sysmmu_tlb_invalidate(struct device *dev) } else { dev_dbg(dev, "disabled. Skipping TLB invalidation\n"); } - read_unlock(&data->lock); + spin_unlock(&data->lock); } spin_unlock_irqrestore(&owner->lock, flags); @@ -819,7 +820,7 @@ static int __init exynos_sysmmu_probe(struct platform_device *pdev) if (!ret) { data->runtime_active = !pm_runtime_enabled(dev); data->sysmmu = dev; - rwlock_init(&data->lock); + spin_lock_init(&data->lock); platform_set_drvdata(pdev, data); } @@ -1269,12 +1270,12 @@ static int sysmmu_pm_genpd_suspend(struct device *dev) for_each_sysmmu_list(dev, list) { struct sysmmu_drvdata *data = dev_get_drvdata(list->sysmmu); unsigned long flags; - write_lock_irqsave(&data->lock, flags); + spin_lock_irqsave(&data->lock, flags); if (!data->suspended && is_sysmmu_active(data) && (!pm_runtime_enabled(dev) || data->runtime_active)) __sysmmu_disable_nocount(data); data->suspended = true; - write_unlock_irqrestore(&data->lock, flags); + spin_unlock_irqrestore(&data->lock, flags); } return 0; @@ -1288,12 +1289,12 @@ static int sysmmu_pm_genpd_resume(struct device *dev) for_each_sysmmu_list(dev, list) { struct sysmmu_drvdata *data = dev_get_drvdata(list->sysmmu); unsigned long flags; - write_lock_irqsave(&data->lock, flags); + spin_lock_irqsave(&data->lock, flags); if (data->suspended && is_sysmmu_active(data) && (!pm_runtime_enabled(dev) || data->runtime_active)) __sysmmu_enable_nocount(data); data->suspended = false; - write_unlock_irqrestore(&data->lock, flags); + spin_unlock_irqrestore(&data->lock, flags); } return pm_generic_resume(dev); @@ -1448,12 +1449,12 @@ static int sysmmu_hook_driver_register(struct notifier_block *nb, dev_get_drvdata(list->sysmmu); unsigned long flags; - write_lock_irqsave(&data->lock, flags); + spin_lock_irqsave(&data->lock, flags); if (is_sysmmu_active(data) && !data->runtime_active) __sysmmu_enable_nocount(data); data->runtime_active = true; pm_runtime_disable(data->sysmmu); - write_unlock_irqrestore(&data->lock, flags); + spin_unlock_irqrestore(&data->lock, flags); } break;