Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp3502144imb; Tue, 5 Mar 2019 10:59:54 -0800 (PST) X-Google-Smtp-Source: APXvYqzjXJ7hpwbaJmiVQJcOZeY0fmt7P8TPjpWW35ckxZNwElYo6fx/pT4aoXMhUFIZxDwSjqPz X-Received: by 2002:a17:902:6b08:: with SMTP id o8mr2706706plk.105.1551812394748; Tue, 05 Mar 2019 10:59:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551812394; cv=none; d=google.com; s=arc-20160816; b=Zfpvqzf2kiYOyXCGPAMUI4gtDZe8sHaCkrQQ6zKFoHKxTKeX0DL5ypJ2fPeXYEo4xd YIP2MU8rl7s10NrACcl3DAq1yVXol3jc218KFE3km7Q8+f7Xjg6nVV4PJ+Q65hhGhHbP 0YvrDeHNHjoTU7Zy0TZtccKCkGBj39q7qn4X9Vuqp3ewKHGX3EWMmpSEcK0yWRluS1Y4 2WMSq3vn9Bra1XMFSWSf5/C0xOUvobZ7K4OINiwjokyiutfy7toxuEgf2KX3W+I012nj NzdUTNRpOHTmGHG4ftE1XPjJdEz3oDIIrJPmomwT4FhonV8hZPVsD36xjyMJadA2SbNO R6Jg== 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=a7l9xoUuA1ScTHMMBdFcvO9C+8UUn6q5cWSmPtKlbeM=; b=LzPUoC44Bfhe7h4UPB+pfZ1CegZ9yTP5N9ITJdhHJPYrVoZkKm/YtmWMur4tCdphGR Od1KroBt6P5XW4wgaA/uLvJKegicewO19rt0BXE+Im4hP3jDD473d6GBvoRoZ3bLcPG+ Ohg+UcHQLwaMwsfBw92Uo9ffjUoT9GgmbWawvyQM0FCv65xo+WPBjk9UoQnMGxT9LwgQ sisRDyAIyf/u9Qfegpauz6v+x5VoAKXb07maheME45kq0y93f1Ct8gzUKilh6jGTwL0f sU1AmXQl2DjHOHyqCNphaif9PAGFyMppI7TYPIn9lMONZBE7hOP2iPElv63B6c3MPg25 p3ag== 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 v9si8248039pgr.462.2019.03.05.10.59.38; Tue, 05 Mar 2019 10:59:54 -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 S1731016AbfCESJd (ORCPT + 99 others); Tue, 5 Mar 2019 13:09:33 -0500 Received: from mail1.bemta25.messagelabs.com ([195.245.230.4]:21484 "EHLO mail1.bemta25.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726308AbfCESIb (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-4.bemta.az-a.eu-west-1.aws.symcld.net id 8F/57-04122-C1BBE7C5; Tue, 05 Mar 2019 18:08:28 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMIsWRWlGSWpSXmKPExsVy8IPnUV3p3XU xBj+nGFlMffiEzeLblQ4mi8u75rA5MHvsnHWX3WPTqk42j8+b5AKYo1gz85LyKxJYM5q3rmIu eMFbcXDBHrYGxkPcXYxcHEIC6xglljXMYO9i5ARyKiS+dX9mBLF5BZIlfp5qAYtzCjhKHOxdx wpR4yDRePsvG4jNJmAoMe/Ne7B6FgFViT83LoHVCAt4SezpXs0EYosIeEi0bt/ADGIzC8RKnJ +3lAVivqDEyZlPWCDiEhIHX7wAquEAmq8lsfxYJEhYQsBeYvr7q2BhCQF9icZjsRBhQ4nvs76 xQNjmErdXP2CdwCg4C8nQWUiGLmBkWsVokVSUmZ5RkpuYmaNraGCga2hopGtoCcQW5nqJVbqJ eqmluuWpxSW6hnqJ5cV6xZW5yTkpenmpJZsYgQGeUnBg9w7G913phxglOZiURHk7d9XFCPEl5 adUZiQWZ8QXleakFh9ilOHgUJLgdQDJCRalpqdWpGXmAGMNJi3BwaMkwlsOkuYtLkjMLc5Mh0 idYtTlOL3w4VxmIZa8/LxUKXHeUzuBigRAijJK8+BGwOL+EqOslDAvIwMDgxBPQWpRbmYJqvw rRnEORiVh3mqQVTyZeSVwm14BHcEEdMTny9UgR5QkIqSkGhjrZj/ZpvfQ5d7TO/PS4o5ejTm8 In9TUhOrujmTYcf96L7125L6Ji6u+XHdwfaPfyP7L465tU3nBcVTUh4nz/L9/X1F4p0Jao+vK 7LFS2zZxxwUx/Xz093zf+YvPawcJKqgtWFzSeOhlDK2ZSXPhdOkjt3z5A/beYyXvd/xeo3i53 9bwp22/IpQYinOSDTUYi4qTgQAdJhUa/YCAAA= X-Env-Sender: stwiss.opensource@diasemi.com X-Msg-Ref: server-20.tower-262.messagelabs.com!1551809306!2441267!7 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 30202 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 3599E3FC10; Tue, 5 Mar 2019 18:08:25 +0000 (GMT) Message-ID: In-Reply-To: References: From: Steve Twiss Date: Tue, 26 Feb 2019 15:35:35 +0000 Subject: [PATCH 06/13] regulator: ltc3589: 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: 3eb2c7ecb7ea ("regulator: Add LTC3589 support") Suggested-by: Adam Thomson Signed-off-by: Steve Twiss --- drivers/regulator/ltc3589.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/ltc3589.c b/drivers/regulator/ltc3589.c index 63f724f..75089b0 100644 --- a/drivers/regulator/ltc3589.c +++ b/drivers/regulator/ltc3589.c @@ -419,16 +419,22 @@ static irqreturn_t ltc3589_isr(int irq, void *dev_id) if (irqstat & LTC3589_IRQSTAT_THERMAL_WARN) { event = REGULATOR_EVENT_OVER_TEMP; - for (i = 0; i < LTC3589_NUM_REGULATORS; i++) + for (i = 0; i < LTC3589_NUM_REGULATORS; i++) { + regulator_lock(ltc3589->regulators[i]); regulator_notifier_call_chain(ltc3589->regulators[i], event, NULL); + regulator_unlock(ltc3589->regulators[i]); + } } if (irqstat & LTC3589_IRQSTAT_UNDERVOLT_WARN) { event = REGULATOR_EVENT_UNDER_VOLTAGE; - for (i = 0; i < LTC3589_NUM_REGULATORS; i++) + for (i = 0; i < LTC3589_NUM_REGULATORS; i++) { + regulator_lock(ltc3589->regulators[i]); regulator_notifier_call_chain(ltc3589->regulators[i], event, NULL); + regulator_unlock(ltc3589->regulators[i]); + } } /* Clear warning condition */ -- 1.9.3