From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Collins Subject: Re: Deadlock scenario in regulator core Date: Tue, 22 Mar 2011 16:08:58 -0700 Message-ID: <4D892C0A.1090606@codeaurora.org> References: <4D891C59.1030009@codeaurora.org> <20110322223702.GO14675@home.goodmis.org> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Return-path: Received: from wolverine01.qualcomm.com ([199.106.114.254]:52869 "EHLO wolverine01.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754436Ab1CVXI7 (ORCPT ); Tue, 22 Mar 2011 19:08:59 -0400 In-Reply-To: <20110322223702.GO14675@home.goodmis.org> Sender: linux-arm-msm-owner@vger.kernel.org List-Id: linux-arm-msm@vger.kernel.org To: Steven Rostedt Cc: Liam Girdwood , Mark Brown , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org On 03/22/2011 03:37 PM, Steven Rostedt wrote: > On Tue, Mar 22, 2011 at 03:02:01PM -0700, David Collins wrote: >> Assume that A has already called regulator_enable for S1 some time in the >> past. >> >> Consumer A thread execution: >> regulator_disable(S1) >> mutex_lock(S1) >> _regulator_disable(S1) >> _notifier_call_chain(S1) >> mutex_lock(L2) >> >> Consumer B thread execution: >> regulator_enable(L2) >> mutex_lock(L2) >> _regulator_enable(L2) >> mutex_lock(S1) >> >> The locks for S1 and L2 are taken in opposite orders in the two threads; >> therefore, it is possible to achieve deadlock. I am not sure about the >> best way to resolve this situation. Is there a correctness requirement >> that regulator_enable holds the child regulator's lock when it attempts to >> enable the parent regulator? Likewise, is the lock around >> _notifier_call_chain required? > > I'm curious, if you had enabled lockdep, do you get a warning? If not, > why not? > > Thanks, > > -- Steve > > -- > To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html I have tried running with lockdep enabled. It does not produce a warning about possible deadlock from locks being taken in opposite orders in two threads. I assume that this is because it can only keep track of locks taken in the current stack backtrace. It does produce a warning for regulator_disable by itself though on a regulator with a non-empty supply_list: ============================================= [ INFO: possible recursive locking detected ] 2.6.38-rc7+ #231 --------------------------------------------- sh/25 is trying to acquire lock: (&rdev->mutex){+.+...}, at: [] _notifier_call_chain+0x28/0x6c but task is already holding lock: (&rdev->mutex){+.+...}, at: [] regulator_disable+0x24/0x74 The locks that it is noting are different; one is for the parent regulator and the other is for the child regulator. Any thoughts? Thanks, David -- Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.