Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp3499268imb; Tue, 5 Mar 2019 10:54:16 -0800 (PST) X-Google-Smtp-Source: APXvYqyVb26DduM2BshXUHYVPblWoZQ3zrZagVxkIHXbQID+5Rx0+2MpeJdgC715/QkRMMnheQch X-Received: by 2002:a62:b2d9:: with SMTP id z86mr3284598pfl.255.1551812056135; Tue, 05 Mar 2019 10:54:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551812056; cv=none; d=google.com; s=arc-20160816; b=zZs6z3xB+g1cMDyxmJioslkGBTFtjtt3JR5R+99LJwbuZ0Nwyj3grSLkBjf9XIAKJE lMUWSxpiUQfyCs8Ep1HR48dShKDzkhwMslXGrGKMFZmT4ffMSGJSq9bQXxqznMtL6iB0 XeSzJiDlHunyt/Hr1cjw8KJlsFeazn1iLJd9hYoEBi/IHp6G92xbu0zRUP8172p0461u lcL9akHdlLqSg7o3pX5v3se6qCnEqFT9/1LVLs1dvP5YQNM38r0Hegw+tGghw/ukWTaH lWI0zvHABf/ZybmzTNQXeSARmPNaT127h1XRJM7e3RF1AxX4V066FAVSku/QUCuD1Tvx b18Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:cc:to:subject:date:from :references:in-reply-to:message-id; bh=y3xoW6YUbOkPsdJK11F3LWwFiAWi7fLdhs5WMI5x6TY=; b=NcvFo3RY68FAp8SmQQWgaym599cLuT7XvnfPtVL9Of7g5+csS+hE5nME+2l9SUuR6j 1YpVWq+vBTgVrT6uLd60U3m6WJhaLEd3qSjMvORbTgIq1VzOXz5fTT3gJXTNgnDcSgcA o35RWVsrLVrszn27pUpEhLnHUUqLJrawY7w2bgEmpjPiN4akv/RK7Rtz6ZJQJwQ5p+nx odlcukrw/eNMRGdtKOzl4SJo1c2OntZBz3otwQ6VFi5LCe66NDZZwwpvrVx9l9kot7kg hSkbdYEIGUyKKvLACWHlLKuY/OlJj7EwwTgZ6vU+YMTbfJjItyJQbMU1Q4cz289U9Jqd 488Q== 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=diasemi.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c4si8487187pgk.353.2019.03.05.10.54.01; Tue, 05 Mar 2019 10:54:16 -0800 (PST) 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=diasemi.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730894AbfCESId (ORCPT + 99 others); Tue, 5 Mar 2019 13:08:33 -0500 Received: from mail1.bemta25.messagelabs.com ([195.245.230.3]:24953 "EHLO mail1.bemta25.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726422AbfCESIb (ORCPT ); Tue, 5 Mar 2019 13:08:31 -0500 Received: from [46.226.52.98] (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256 bits)) by server-3.bemta.az-a.eu-west-1.aws.symcld.net id 7D/5E-26211-C1BBE7C5; Tue, 05 Mar 2019 18:08:28 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMIsWRWlGSWpSXmKPExsVy8IPnUV3p3XU xBlOe2FhMffiEzeLblQ4mi8u75rA5MHvsnHWX3WPTqk42j8+b5AKYo1gz85LyKxJYM1p//GQs WMZXsXLDAdYGxkk8XYxcHEIC6xglljXMYO9i5ARyKiQezDnPBGLzCiRLTN7ZDWZzCjhKHOxdx wpR4yDRePsvG4jNJmAoMe/Ne0YQm0VAVeLH2UksILawgJfEx58fwGaKCHhItG7fwAxiMwvESp yft5QFYr6gxMmZT1gg4hISB1+8AKrhAJqvJbH8WCRIWELAXmL6+6tgYQkBfYnGY7EQYUOJ77O +sUDY5hK3Vz9gncAoOAvJ0FlIhi5gZFrFaJFUlJmeUZKbmJmja2hgoGtoaKRraGmia2RkqpdY pZuol1qqW55aXKJrqJdYXqxXXJmbnJOil5dasokRGOApBYce7mA8tzz9EKMkB5OSKG/nrroYI b6k/JTKjMTijPii0pzU4kOMMhwcShK8DiA5waLU9NSKtMwcYKzBpCU4eJREeMtB0rzFBYm5xZ npEKlTjLocpxc+nMssxJKXn5cqJc57aidQkQBIUUZpHtwIWNxfYpSVEuZlZGBgEOIpSC3KzSx BlX/FKM7BqCTMWw2yiiczrwRu0yugI5iAjvh8uRrkiJJEhJRUA2P0ip/SkZdfiUg6WcanfT/2 x2O7acpb27tdZQdmedVs3X5g0YKUeb7M7Bdf6eZMS5qzIl/6ZybbspaMx5Nff3o068+f3YwV/ p4qpzhqbMQOsbzoXa1/wWsRP5P9kx1uJRI7hbdWnq6ZuMRD8eTbK+sya55sOOa4arFFmBTbfG P752l+1fH71V8qsRRnJBpqMRcVJwIASHtx+/YCAAA= X-Env-Sender: stwiss.opensource@diasemi.com X-Msg-Ref: server-20.tower-262.messagelabs.com!1551809306!2441267!8 X-Originating-IP: [193.240.73.197] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.31.5; banners=-,-,- X-VirusChecked: Checked Received: (qmail 30218 invoked from network); 5 Mar 2019 18:08:27 -0000 Received: from unknown (HELO sw-ex-cashub01.diasemi.com) (193.240.73.197) by server-20.tower-262.messagelabs.com with AES128-SHA256 encrypted SMTP; 5 Mar 2019 18:08:27 -0000 Received: from swsrvapps-01.diasemi.com (10.20.28.141) by SW-EX-CASHUB01.diasemi.com (10.20.16.140) with Microsoft SMTP Server id 14.3.408.0; Tue, 5 Mar 2019 18:08:26 +0000 Received: by swsrvapps-01.diasemi.com (Postfix, from userid 22547) id 382AB3FC11; Tue, 5 Mar 2019 18:08:25 +0000 (GMT) Message-ID: <62744c91911e8b7f9b5dadc1bbc278f69c499330.1551808797.git.stwiss.opensource@diasemi.com> In-Reply-To: References: From: Steve Twiss Date: Tue, 26 Feb 2019 15:38:56 +0000 Subject: [PATCH 07/13] regulator: ltc3676: Fix notifier mutex lock warning To: Liam Girdwood , Mark Brown CC: Support Opensource , LKML MIME-Version: 1.0 Content-Type: text/plain X-KSE-AttachmentFiltering-Interceptor-Info: protection disabled X-KSE-ServerInfo: sw-ex-cashub01.diasemi.com, 9 X-KSE-Antivirus-Interceptor-Info: scan successful X-KSE-Antivirus-Info: Clean, bases: 05/03/2019 17:23:00 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The mutex for the regulator_dev must be controlled by the caller of the regulator_notifier_call_chain(), as described in the comment for that function. Failure to mutex lock and unlock surrounding the notifier call results in a kernel WARN_ON_ONCE() which will dump a backtrace for the regulator_notifier_call_chain() when that function call is first made. The mutex can be controlled using the regulator_lock/unlock() API. Fixes: 37b918a034fe ("regulator: Add LTC3676 support") Suggested-by: Adam Thomson Signed-off-by: Steve Twiss --- drivers/regulator/ltc3676.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/ltc3676.c b/drivers/regulator/ltc3676.c index 71fd0f2..cd0f112 100644 --- a/drivers/regulator/ltc3676.c +++ b/drivers/regulator/ltc3676.c @@ -338,17 +338,23 @@ static irqreturn_t ltc3676_isr(int irq, void *dev_id) if (irqstat & LTC3676_IRQSTAT_THERMAL_WARN) { dev_warn(dev, "Over-temperature Warning\n"); event = REGULATOR_EVENT_OVER_TEMP; - for (i = 0; i < LTC3676_NUM_REGULATORS; i++) + for (i = 0; i < LTC3676_NUM_REGULATORS; i++) { + regulator_lock(ltc3676->regulators[i]); regulator_notifier_call_chain(ltc3676->regulators[i], event, NULL); + regulator_unlock(ltc3676->regulators[i]); + } } if (irqstat & LTC3676_IRQSTAT_UNDERVOLT_WARN) { dev_info(dev, "Undervoltage Warning\n"); event = REGULATOR_EVENT_UNDER_VOLTAGE; - for (i = 0; i < LTC3676_NUM_REGULATORS; i++) + for (i = 0; i < LTC3676_NUM_REGULATORS; i++) { + regulator_lock(ltc3676->regulators[i]); regulator_notifier_call_chain(ltc3676->regulators[i], event, NULL); + regulator_unlock(ltc3676->regulators[i]); + } } /* Clear warning condition */ -- 1.9.3