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: 1419901 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 6EEAA3FC85 for ; Fri, 7 Sep 2012 06:14:03 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1T9rmh-0005zz-Rt; Fri, 07 Sep 2012 06:11:20 +0000 Received: from mail-pz0-f49.google.com ([209.85.210.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1T9rmd-0005zT-V1 for linux-arm-kernel@lists.infradead.org; Fri, 07 Sep 2012 06:11:16 +0000 Received: by dajq27 with SMTP id q27so1598577daj.36 for ; Thu, 06 Sep 2012 23:11:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=h1byQzWuaXiRlWwgSGSg89aaZTZbwmulOsJLnjC+Ak8=; b=mHAb61k7NOsPLe6ZX8I/iYMfGOejCymBKEBqdhXkcVOPN4aT+uOHhmN8xG8x6j5mTF bO/b4secFRgXep8APyQQqdCTbllkz0x4m1yoizSyFBbiIvT3uZOgetu0fVDsI2QYt7s9 GPam5y7jOdqvdCATsL/ghoygMdEo/9BhXWHePC/x3gq/+DLgwI3BDqIeHoaiPkfD7kHJ 2VubI4zb24pD85YwOYOPHuwFrXIwwazqRwV1e7IH0dl8qp7zNaf8LMUOxbXFDlXNr/Qv WLMj3MIDRLOtSI+4MeOEdymtFodSPMz8uiO1qvt2Z3p2TLik3inwDgLKsSikFHOtJE06 RPEg== 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 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: ALoCoQmvYiQtgICfSv5b8jFn8m/Hu13C0LW/jBD9FE5zphqijf6g2ox9s2PajJXob4lVg6x2r/I6 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.210.49 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: kgene.kim@samsung.com, patches@linaro.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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; }