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: 3830931 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 10C4A9F1CD for ; Fri, 14 Mar 2014 05:54:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 02E672012F for ; Fri, 14 Mar 2014 05:54:01 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C2E062012B for ; Fri, 14 Mar 2014 05:53:59 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WOKQU-0004y6-S8; Fri, 14 Mar 2014 05:13:00 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WOKPg-0000b7-Cn; Fri, 14 Mar 2014 05:12:08 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WOKPb-0000Xu-Oy for linux-arm-kernel@lists.infradead.org; Fri, 14 Mar 2014 05:12:04 +0000 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> for linux-arm-kernel@lists.infradead.org; Fri, 14 Mar 2014 14:11:41 +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 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 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrIIsWRmVeSWpSXmKPExsVy+t8zY93efqVgg0n9+hZ37p5jtZh/BEi8 OvKDyWLBfmuLztkb2C16F1xls9j0+BqrxeVdc9gsZpzfx2RxYcVGdospiw6zWhx+085qcfJP L6PF+hmvWSxm3lrD4sDv8eTgPCaP2Q0XWTz+He5n8rhzbQ+bx+Yl9R6Tbyxn9OjbsorR4/Mm OY8rR88wBXBGcdmkpOZklqUW6dslcGXs+byKseCXTsW6znNsDYzzVbsYOTkkBEwkJh97wARh i0lcuLeeDcQWEljGKPFgQQxMzefDz1gg4tMZJdoOAMW5gOzJTBLbpzWCNbMIqEq0nesAs9kE tCRWzz3OCFIkItDGJPG18RALiMMsMJdZ4uO3OWArhAWcJI59WccIYvMKOEpc/rqY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66XnJ+7iRGcHJ5J7WBc2WBxiFGAg1GJh9fhsGKwEGtiWXFl 7iFGCQ5mJRHeqgilYCHelMTKqtSi/Pii0pzU4kOMyUB/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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140314_011204_024712_578CB21A X-CRM114-Status: GOOD ( 11.53 ) X-Spam-Score: -6.9 (------) Cc: Kukjin Kim , Prathyush , Grant Grundler , Joerg Roedel , Sachin Kamat , Sylwester Nawrocki , Varun Sethi , Antonios Motakis , Tomasz Figa , Rahul Sharma X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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;