From patchwork Fri Sep 7 06:08:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tushar Behera X-Patchwork-Id: 11219 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 8508223F22 for ; Fri, 7 Sep 2012 06:11:16 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 36284A18D08 for ; Fri, 7 Sep 2012 06:11:16 +0000 (UTC) Received: by ieak11 with SMTP id k11so4156634iea.11 for ; Thu, 06 Sep 2012 23:11:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:x-gm-message-state; bh=h1byQzWuaXiRlWwgSGSg89aaZTZbwmulOsJLnjC+Ak8=; b=l+0Ydicw6bgyht+cOQgBsrjvrRpC8C0qdpEQveVsp7b4rJX4zEVVOuQbFKKLuD7NhY W88qsj86wyEOBavRHlh5qDt/xxWxOQ94ahsHMi+nehDmOWaUF6cf2ZyH88M32GHjwltJ 5HSAraummI+d8YxJAxwFgdEqWM0XGQTusTDsvDngEIU31KKhUq78A28f8AKiOB8H6zhJ rM5t3AP7e+z13q+7bRsDZISr5lVPAEae29c9MbvLu94T62PWEuYcgCu/QnTnH6l3Hbyw nd/sWJiEC6QNhhsvbs600B5mgkQi+7/VytUR/4a5YWRP/sDJ4d6atoCJRmNiI15QOxIH f0QA== Received: by 10.50.180.129 with SMTP id do1mr6747276igc.28.1346998275394; Thu, 06 Sep 2012 23:11:15 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp361973igc; Thu, 6 Sep 2012 23:11:14 -0700 (PDT) Received: by 10.68.135.39 with SMTP id pp7mr8579213pbb.127.1346998274154; Thu, 06 Sep 2012 23:11:14 -0700 (PDT) Received: from mail-pz0-f50.google.com (mail-pz0-f50.google.com [209.85.210.50]) by mx.google.com with ESMTPS id ip5si7377274pbc.18.2012.09.06.23.11.13 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 06 Sep 2012 23:11:14 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of tushar.behera@linaro.org) client-ip=209.85.210.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of tushar.behera@linaro.org) smtp.mail=tushar.behera@linaro.org Received: by dade7 with SMTP id e7so1772617dad.37 for ; Thu, 06 Sep 2012 23:11:13 -0700 (PDT) Received: by 10.68.234.41 with SMTP id ub9mr6809431pbc.21.1346998273457; Thu, 06 Sep 2012 23:11:13 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id qb6sm2593288pbb.18.2012.09.06.23.11.09 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 06 Sep 2012 23:11:12 -0700 (PDT) From: Tushar Behera To: linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Cc: kgene.kim@samsung.com, patches@linaro.org Subject: [PATCH] ARM: SAMSUNG: Use spin_lock_{irqsave, irqrestore} in clk_set_rate Date: Fri, 7 Sep 2012 11:38:22 +0530 Message-Id: <1346998102-5317-1-git-send-email-tushar.behera@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-Gm-Message-State: ALoCoQlAK95TO9wdnZJwMcLqJzsMcWs0zwHWk+Xy3ErK+8i0mYyFkx2Zgq/LhNn0YVXF4buUMgt4 The spinlock clocks_lock can be held during ISR, hence it is not safe to hold that lock with disabling interrupts. It fixes following potential deadlock. ========================================================= [ INFO: possible irq lock inversion dependency detected ] 3.6.0-rc4+ #2 Not tainted --------------------------------------------------------- swapper/0/1 just changed the state of lock: (&(&host->lock)->rlock){-.....}, at: [] sdhci_irq+0x15/0x564 but this lock took another, HARDIRQ-unsafe lock in the past: (clocks_lock){+.+...} and interrupts could create inverse lock ordering between them. other info that might help us debug this: Possible interrupt unsafe locking scenario: CPU0 CPU1 ---- ---- lock(clocks_lock); local_irq_disable(); lock(&(&host->lock)->rlock); lock(clocks_lock); lock(&(&host->lock)->rlock); *** DEADLOCK *** Signed-off-by: Tushar Behera --- arch/arm/plat-samsung/clock.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/arm/plat-samsung/clock.c b/arch/arm/plat-samsung/clock.c index 65c5eca..9b71719 100644 --- a/arch/arm/plat-samsung/clock.c +++ b/arch/arm/plat-samsung/clock.c @@ -144,6 +144,7 @@ long clk_round_rate(struct clk *clk, unsigned long rate) int clk_set_rate(struct clk *clk, unsigned long rate) { + unsigned long flags; int ret; if (IS_ERR(clk)) @@ -159,9 +160,9 @@ int clk_set_rate(struct clk *clk, unsigned long rate) if (clk->ops == NULL || clk->ops->set_rate == NULL) return -EINVAL; - spin_lock(&clocks_lock); + spin_lock_irqsave(&clocks_lock, flags); ret = (clk->ops->set_rate)(clk, rate); - spin_unlock(&clocks_lock); + spin_unlock_irqrestore(&clocks_lock, flags); return ret; }