From patchwork Mon Oct 7 01:58:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cho KyongHo X-Patchwork-Id: 2994081 Return-Path: X-Original-To: patchwork-linux-arm@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 A763CBF924 for ; Mon, 7 Oct 2013 02:15:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9C7F1201C8 for ; Mon, 7 Oct 2013 02:15:47 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 415FF20136 for ; Mon, 7 Oct 2013 02:15:46 +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 1VT06n-0005s8-1N; Mon, 07 Oct 2013 01:59:42 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VT05y-00077H-PF; Mon, 07 Oct 2013 01:58:50 +0000 Received: from mailout2.samsung.com ([203.254.224.25]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VT05n-00073I-C4 for linux-arm-kernel@lists.infradead.org; Mon, 07 Oct 2013 01:58:42 +0000 Received: from epcpsbgr4.samsung.com (u144.gpu120.samsung.co.kr [203.254.230.144]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MUA00KQC056E010@mailout2.samsung.com> for linux-arm-kernel@lists.infradead.org; Mon, 07 Oct 2013 10:58:19 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [203.254.230.48]) by epcpsbgr4.samsung.com (EPCPMTA) with SMTP id 92.AC.31253.A3512525; Mon, 07 Oct 2013 10:58:18 +0900 (KST) X-AuditID: cbfee690-b7f3b6d000007a15-df-5252153a0707 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id F6.2F.05832.A3512525; Mon, 07 Oct 2013 10:58:18 +0900 (KST) Received: from DO-PULLIP-CHO07.dsn.sec.samsung.com ([12.23.118.94]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MUA00IJF056M590@mmp1.samsung.com>; Mon, 07 Oct 2013 10:58:18 +0900 (KST) Date: Mon, 07 Oct 2013 10:58:18 +0900 From: Cho KyongHo To: Linux ARM Kernel , Linux DeviceTree , Linux IOMMU , Linux Kernel , Linux Samsung SOC Subject: [PATCH v10 18/20] iommu/exynos: change rwlock to spinlock Message-id: <20131007105818.916595496f5fa52c5bf372bf@samsung.com> X-Mailer: Sylpheed 3.3.0 (GTK+ 2.10.14; i686-pc-mingw32) MIME-version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOIsWRmVeSWpSXmKPExsVy+t8zA10r0aAggxM/zS3u3D3HajH/CJB4 deQHk8WC/dYWnbM3sFv0LrjKZrHp8TVWi8u75rBZzDi/j8niwoqN7BZTFh1mtTj8pp3V4uSf XkaLluu9TBbrZ7xmsZh5aw2Lg4DHk4PzmDxmN1xk8fh3uJ/J4861PWwem5fUe0y+sZzRo2/L KkaPz5vkPK4cPcMUwBnFZZOSmpNZllqkb5fAlXFm12PWgrnqFe+7pzM3MD5S6GLk5JAQMJFo 2n2bDcIWk7hwbz2QzcUhJLCMUeLnz8lMMEXLDzxmh0gsYpRoXbOcFcKZxCRx7MdhdpAqFgFV ia4/21hBbDYBLYnVc48zghSJCLQxSXxtPMQC4jALnGaWWLV7BXMXIweHsICTxMSTBiANv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O94sTc4tK8dL3k/NxNjOA08Ux6B+OqBotDjAIcjEo8vDvu BwYJsSaWFVfmHmKU4GBWEuG9VAcU4k1JrKxKLcqPLyrNSS0+xJgM9PZEZinR5HxgCssriTc0 NjEzsjQyszAyMTcnTVhJnPdgq3WgkEB6YklqdmpqQWoRzBYmDk6pBsZlLX8ypL7YtU122aRl vWXmIvslS4IYbf0WybE+/qdf/+NUgsKrWdo8rP4fHC2qFZ6u53jQpVn6bMXy5xx+z97/trFu Tng5zyQz7F1ODcvcPd2OiwPO7lw1McpNamf80Z7Ll15smBO28fPfwN/XnKcm8+y9ffdRlktj /AqZ7PBbLh+CfM7++vhfiaU4I9FQi7moOBEAPA9Cf1cDAAA= 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-20131006_215840_139865_BD52BC15 X-CRM114-Status: GOOD ( 12.44 ) X-Spam-Score: -6.9 (------) Cc: Kukjin Kim , Prathyush , Grant Grundler , Joerg Roedel , Subash Patel , 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, 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 | 35 ++++++++++++++++++----------------- 1 files changed, 18 insertions(+), 17 deletions(-) diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index e48c2fb..26ba554 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -183,7 +183,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; unsigned long pgtable; @@ -298,11 +298,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)); clk_enable(data->clk_master); + + spin_lock(&data->lock); + itype = (enum exynos_sysmmu_inttype) __ffs(__raw_readl(data->sfrbase + REG_INT_STATUS)); if (WARN_ON(!((itype >= 0) && (itype < SYSMMU_FAULT_UNKNOWN)))) @@ -335,7 +336,7 @@ static irqreturn_t exynos_sysmmu_irq(int irq, void *dev_id) clk_disable(data->clk_master); - read_unlock(&data->lock); + spin_unlock(&data->lock); return IRQ_HANDLED; } @@ -356,7 +357,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); @@ -373,7 +374,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; } @@ -421,7 +422,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; @@ -439,7 +440,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; } @@ -503,7 +504,7 @@ static void sysmmu_tlb_invalidate_entry(struct device *dev, unsigned long iova, data = dev_get_drvdata(client->sysmmu); - read_lock_irqsave(&data->lock, flags); + spin_lock_irqsave(&data->lock, flags); if (is_sysmmu_active(data) && data->runtime_active) { unsigned int num_inv = 1; /* @@ -526,7 +527,7 @@ static void sysmmu_tlb_invalidate_entry(struct device *dev, unsigned long iova, dev_dbg(dev, "disabled. Skipping TLB invalidation @ %#lx\n", iova); } - read_unlock_irqrestore(&data->lock, flags); + spin_unlock_irqrestore(&data->lock, flags); } void exynos_sysmmu_tlb_invalidate(struct device *dev) @@ -537,7 +538,7 @@ void exynos_sysmmu_tlb_invalidate(struct device *dev) data = dev_get_drvdata(client->sysmmu); - read_lock_irqsave(&data->lock, flags); + spin_lock_irqsave(&data->lock, flags); if (is_sysmmu_active(data) && data->runtime_active) { clk_enable(data->clk_master); if (sysmmu_block(data->sfrbase)) { @@ -548,7 +549,7 @@ void exynos_sysmmu_tlb_invalidate(struct device *dev) } else { dev_dbg(dev, "disabled. Skipping TLB invalidation\n"); } - read_unlock_irqrestore(&data->lock, flags); + spin_unlock_irqrestore(&data->lock, flags); } static int __init exynos_sysmmu_probe(struct platform_device *pdev) @@ -609,7 +610,7 @@ static int __init exynos_sysmmu_probe(struct platform_device *pdev) } data->sysmmu = dev; - rwlock_init(&data->lock); + spin_lock_init(&data->lock); platform_set_drvdata(pdev, data); @@ -625,11 +626,11 @@ static int sysmmu_suspend(struct device *dev) { struct sysmmu_drvdata *data = dev_get_drvdata(dev); unsigned long flags; - read_lock_irqsave(&data->lock, flags); + spin_lock_irqsave(&data->lock, flags); if (is_sysmmu_active(data) && (!pm_runtime_enabled(dev) || data->runtime_active)) __sysmmu_disable_nocount(data); - read_unlock_irqrestore(&data->lock, flags); + spin_unlock_irqrestore(&data->lock, flags); return 0; } @@ -637,11 +638,11 @@ static int sysmmu_resume(struct device *dev) { struct sysmmu_drvdata *data = dev_get_drvdata(dev); unsigned long flags; - read_lock_irqsave(&data->lock, flags); + spin_lock_irqsave(&data->lock, flags); if (is_sysmmu_active(data) && (!pm_runtime_enabled(dev) || data->runtime_active)) __sysmmu_enable_nocount(data); - read_unlock_irqrestore(&data->lock, flags); + spin_unlock_irqrestore(&data->lock, flags); return 0; } #endif