From patchwork Wed Aug 5 16:02:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 51959 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by patches.linaro.org (Postfix) with ESMTPS id 4B6FE229FD for ; Wed, 5 Aug 2015 16:02:28 +0000 (UTC) Received: by wixh2 with SMTP id h2sf18268310wix.0 for ; Wed, 05 Aug 2015 09:02:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=ra4BoN3DUS6oqIJfQ6AI+LrhzMaaivh2UwzH9Of00Ao=; b=l2wiMkuGuvGQncoquxtZmP5XSAJFOM+nUpe8wOrACK01Ktg39BhaSRVaAHEBXGP1Hh Ml93Y0R+vVqXKlaVU37x1v6HXtXd09cHVANsxx/Bb0cQtKPXHg7byoT8BHevRKdejUnl Azt+HEuVTg79PsYb/kzCSOtK6EYcPW8DOiygridMCnBwRqgSiaEXTqZDSSWNNFDQGiY5 a7Rh/bLBcyQTMaTRlciHTlJjIhvwHD53YUf9RwpPWbOY+tPkAJOvpLmoIdmZyBl6Xk13 cBDcrKm2NAX+gXC3JflyvUzWubJnBKVYw/hiaVNcfM00WQ8rk4pv0Xa67G+iMJ/tIGol V7Nw== X-Gm-Message-State: ALoCoQllWhzistNV0jXpocgzy56KuOJhoHm1QXpq0SpDSpSSaILbYvP/KIwuavHkRji1QW3S2ZP3 X-Received: by 10.112.159.2 with SMTP id wy2mr1296009lbb.11.1438790547431; Wed, 05 Aug 2015 09:02:27 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.10.33 with SMTP id f1ls234929lab.49.gmail; Wed, 05 Aug 2015 09:02:27 -0700 (PDT) X-Received: by 10.112.91.196 with SMTP id cg4mr10067713lbb.10.1438790547121; Wed, 05 Aug 2015 09:02:27 -0700 (PDT) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com. [209.85.217.178]) by mx.google.com with ESMTPS id pr5si2387724lbb.140.2015.08.05.09.02.27 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Aug 2015 09:02:27 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by lbbyj8 with SMTP id yj8so27168452lbb.0 for ; Wed, 05 Aug 2015 09:02:27 -0700 (PDT) X-Received: by 10.152.9.66 with SMTP id x2mr9024321laa.76.1438790546922; Wed, 05 Aug 2015 09:02:26 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.7.198 with SMTP id l6csp451916lba; Wed, 5 Aug 2015 09:02:25 -0700 (PDT) X-Received: by 10.70.96.162 with SMTP id dt2mr21109990pdb.84.1438790544956; Wed, 05 Aug 2015 09:02:24 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id tw4si5892887pbc.225.2015.08.05.09.02.23; Wed, 05 Aug 2015 09:02:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753172AbbHEQCW (ORCPT + 28 others); Wed, 5 Aug 2015 12:02:22 -0400 Received: from mail-wi0-f173.google.com ([209.85.212.173]:36268 "EHLO mail-wi0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752051AbbHEQCU (ORCPT ); Wed, 5 Aug 2015 12:02:20 -0400 Received: by wicgj17 with SMTP id gj17so198827321wic.1 for ; Wed, 05 Aug 2015 09:02:19 -0700 (PDT) X-Received: by 10.180.21.175 with SMTP id w15mr21243102wie.58.1438790539244; Wed, 05 Aug 2015 09:02:19 -0700 (PDT) Received: from localhost.localdomain (host-92-13-246-184.as43234.net. [92.13.246.184]) by smtp.gmail.com with ESMTPSA id mc4sm8278172wic.6.2015.08.05.09.02.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 05 Aug 2015 09:02:18 -0700 (PDT) From: Srinivas Kandagatla To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [RFC PATCH] regulator: Fix recursive mutex lockdep warning Date: Wed, 5 Aug 2015 17:02:08 +0100 Message-Id: <1438790528-4435-1-git-send-email-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: srinivas.kandagatla@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , A recursive lockdep warning occurs if you call regulator_set_voltage() on a load switches that are modelled as regulators with a parent supply as there is no nesting annotation for the rdev->mutex. To avoid this warning, use the unlocked version of the get_voltage(). wiithout this patch kernel throws up below warning: ============================================= [ INFO: possible recursive locking detected ] 4.2.0-rc5-dirty #132 Not tainted --------------------------------------------- swapper/0/1 is trying to acquire lock: (&rdev->mutex){+.+.+.}, at: [] regulator_get_voltage+0x44/0x68 but task is already holding lock: (&rdev->mutex){+.+.+.}, at: [] regulator_set_voltage+0x50/0x168 other info that might help us debug this: Possible unsafe locking scenario: CPU0 ---- lock(&rdev->mutex); lock(&rdev->mutex); *** DEADLOCK *** May be due to missing lock nesting notation 3 locks held by swapper/0/1: #0: (&dev->mutex){......}, at: [] __driver_attach+0x58/0xa8 #1: (&dev->mutex){......}, at: [] __driver_attach+0x68/0xa8 #2: (&rdev->mutex){+.+.+.}, at: [] regulator_set_voltage+0x50/0x168 stack backtrace: CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.2.0-rc5-dirty #132 Hardware name: Qualcomm (Flattened Device Tree) [] (unwind_backtrace) from [] (show_stack+0x20/0x24) [] (show_stack) from [] (dump_stack+0x8c/0xc0) [] (dump_stack) from [] (__lock_acquire+0x1bf4/0x1ec0) [] (__lock_acquire) from [] (lock_acquire+0xe0/0x300) [] (lock_acquire) from [] (mutex_lock_nested+0x88/0x45c) [] (mutex_lock_nested) from [] (regulator_get_voltage+0x44/0x68) [] (regulator_get_voltage) from [] (_regulator_get_voltage+0xb8/0x190) [] (_regulator_get_voltage) from [] (regulator_set_voltage+0x12c/0x168) [] (regulator_set_voltage) from [] (mmci_sig_volt_switch+0x6c/0x110) [] (mmci_sig_volt_switch) from [] (mmc_power_up+0x78/0x114) [] (mmc_power_up) from [] (mmc_start_host+0x54/0x7c) [] (mmc_start_host) from [] (mmc_add_host+0x6c/0x90) [] (mmc_add_host) from [] (mmci_probe+0x5ac/0x854) [] (mmci_probe) from [] (amba_probe+0xdc/0x158) [] (amba_probe) from [] (driver_probe_device+0x1dc/0x280) [] (driver_probe_device) from [] (__driver_attach+0xa4/0xa8) [] (__driver_attach) from [] (bus_for_each_dev+0x64/0x98) [] (bus_for_each_dev) from [] (driver_attach+0x2c/0x30) [] (driver_attach) from [] (bus_add_driver+0xf8/0x204) [] (bus_add_driver) from [] (driver_register+0x88/0x104) [] (driver_register) from [] (amba_driver_register+0x50/0x64) [] (amba_driver_register) from [] (mmci_driver_init+0x14/0x1c) [] (mmci_driver_init) from [] (do_one_initcall+0x90/0x1e4) [] (do_one_initcall) from [] (kernel_init_freeable+0x12c/0x1f4) [] (kernel_init_freeable) from [] (kernel_init+0x1c/0xfc) [] (kernel_init) from [] (ret_from_fork+0x14/0x3c) Reported-by: Nicolas Dechesne Signed-off-by: Srinivas Kandagatla --- drivers/regulator/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 3c3137a..7717b04 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -2919,7 +2919,7 @@ static int _regulator_get_voltage(struct regulator_dev *rdev) } else if (rdev->desc->fixed_uV && (rdev->desc->n_voltages == 1)) { ret = rdev->desc->fixed_uV; } else if (rdev->supply) { - ret = regulator_get_voltage(rdev->supply); + ret = _regulator_get_voltage(rdev->supply->rdev); } else { return -EINVAL; }