Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp1518461ybm; Thu, 23 May 2019 02:22:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqzWTG2aT+m6wDf1IHv2DynBBgOxr3HRx/ANna6X5w7BHjhRsVJ4JqNDk5LFwEi6w+GlpEB5 X-Received: by 2002:a17:90a:d16:: with SMTP id t22mr295287pja.130.1558603357614; Thu, 23 May 2019 02:22:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558603357; cv=none; d=google.com; s=arc-20160816; b=tLCyHYEIIeIhrE2ChMPOGZHMaXCi/yKlewW5H8rOBKRlRpoogtBjRN/94imyi7GytW M3uZKuqxnP0xAQztcfc1BOtQMWi9LW5RG1ld18HeYNsBkn0HD+4f1KfjUTS9RKdMnNws 9Gbl42s1nMxBpzXvBLSBoYX6ZwiwU/xui/w9umnC5i56oPwE6hopKJLPat+XXDGqTKfV 8kyREuKrUMTYRBERnV8fcE6wphB1nHnmMBZ3ZKiKxoRCZHLI/lZMK5a2vVzZCE84EKzo k37DwS5asl+FKqwJyoUGzdIAKKUPQ1PC0uJ+k/C53/I05RpsJmYGDsYt+1FrWat0xAVZ 2uBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=oABjYlPS6rDqe14mDu45gsd/4Lsvh+AYEvgXlY4k5ws=; b=qO1pVeBSUVqLR0zTUVFCSW+MfUNAOcSD7hQ2GWumV9Qj4Dz2lQktVc4BFrthIwOV3t 1Qpl01zkcjljengB+VTJqLTSLNyOVGJ6mrsSA04D/qPNvZIDn+u5jJIMowuIuL+xoW3b C3r82s0+o9Vl9sxy5h2ALPP4PQ2hjeFE+Sg5mZeIo1UvsDgL1+ojgJqONfqlrxtr5epJ uXqdeTlBFvD8/jXK4Xz9rHV//JirMgvz63iWDao+OHdZU8iaak1NXWNG7R5TmGOwr/WM uFQHEJ0vpRxL0Ti3afByrNAXKN5YI49D4PxUkz7R0VW7LtcO+YGxNzgmKqHVA7PudLOf 7E4A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a62si28369423pgc.129.2019.05.23.02.22.22; Thu, 23 May 2019 02:22:37 -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; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729762AbfEWJUS (ORCPT + 99 others); Thu, 23 May 2019 05:20:18 -0400 Received: from mga07.intel.com ([134.134.136.100]:15388 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726299AbfEWJUR (ORCPT ); Thu, 23 May 2019 05:20:17 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 May 2019 02:20:17 -0700 X-ExtLoop1: 1 Received: from buildpc-hp-z230.iind.intel.com (HELO buildpc-HP-Z230) ([10.223.89.34]) by orsmga001.jf.intel.com with ESMTP; 23 May 2019 02:20:15 -0700 Date: Thu, 23 May 2019 14:50:34 +0530 From: Sanyog Kale To: Srinivas Kandagatla Cc: Pierre-Louis Bossart , vkoul@kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] soundwire: stream: fix bad unlock balance Message-ID: <20190523092034.GA23777@buildpc-HP-Z230> References: <20190522162528.5892-1-srinivas.kandagatla@linaro.org> <4744834c-36b1-dd8d-45fa-76c75eb3d5cb@linux.intel.com> <2dc66f9d-e508-d457-a7d6-c06c4336e7b8@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2dc66f9d-e508-d457-a7d6-c06c4336e7b8@linaro.org> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 23, 2019 at 09:43:14AM +0100, Srinivas Kandagatla wrote: > > > On 22/05/2019 17:41, Pierre-Louis Bossart wrote: > > > > > > On 5/22/19 11:25 AM, Srinivas Kandagatla wrote: > > > This patch fixes below warning due to unlocking without locking. > > > > > > ?? ===================================== > > > ?? WARNING: bad unlock balance detected! > > > ?? 5.1.0-16506-gc1c383a6f0a2-dirty #1523 Tainted: G?????????????? W > > > ?? ------------------------------------- > > > ?? aplay/2954 is trying to release lock (&bus->msg_lock) at: > > > ?? do_bank_switch+0x21c/0x480 > > > ?? but there are no more locks to release! > > > > > > Signed-off-by: Srinivas Kandagatla > > > --- > > > ?? drivers/soundwire/stream.c | 3 ++- > > > ?? 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c > > > index 544925ff0b40..d16268f30e4f 100644 > > > --- a/drivers/soundwire/stream.c > > > +++ b/drivers/soundwire/stream.c > > > @@ -814,7 +814,8 @@ static int do_bank_switch(struct > > > sdw_stream_runtime *stream) > > > ?????????????????????????? goto error; > > > ?????????????????? } > > > -?????????????? mutex_unlock(&bus->msg_lock); > > > +?????????????? if (mutex_is_locked(&bus->msg_lock)) > > > +?????????????????????? utex_unlock(&bus->msg_lock); > > > > Does this even compile? should be mutex_unlock, no? > > > > We also may want to identify the issue in more details without pushing > > it under the rug. The locking mechanism is far from simple and it's > > likely there are a number of problems with it. > > > msg_lock is taken conditionally during multi link bank switch cases, however > the unlock is done unconditionally leading to this warning. > > Having a closer look show that there could be a dead lock in this path while > executing sdw_transfer(). And infact there is no need to take msg_lock in > multi link switch cases as sdw_transfer should take care of this. > > Vinod/Sanyog any reason why msg_lock is really required in this path? > In case of multi link we use sdw_transfer_defer instead of sdw_transfer where lock is not acquired, hence lock is acquired in do_bank_switch for multi link. we should add same check of multi link to release lock in do_bank_switch. > --srini > > > > ?????????? } > > > ?????????? return ret; > > > --