Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp3501454imb; Tue, 5 Mar 2019 10:58:29 -0800 (PST) X-Google-Smtp-Source: APXvYqww1f2EBFbkWX3KTV9T0Vo/lPcFdH2mMbvdtAamyWqWMELqII+OIJwhQuOBeq4eutLZpBns X-Received: by 2002:a17:902:bd47:: with SMTP id b7mr2762251plx.336.1551812309785; Tue, 05 Mar 2019 10:58:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551812309; cv=none; d=google.com; s=arc-20160816; b=xnZ+1BAjQXd7alceimXxr9Jmf3OZDjEB25ZuU4YqlRo3zrczmNce3Vhe4Yjc50JcMw PnBtOx9HsVYTjVcC88739OEPrNKrL2OW53BlKXolw9f+KcmxAM3hdgI6OY/FfYZcnNEV eeHOcDSDVQUhsL4M+8VEDgExoG2jMU6PzBcws/ZPKjf6pyyQzXYaEzds9M3N5+TczyqH 5MqSaXLRcM460vVtMlc3/KPTzqjJ9N28MFBD3JU1bAXlOxUbLozTCmgRNgTkTqyfNHEl cRc4gG/e9mlq+qSzVC2otg1L2CkyN6V+5m5YKuxZ+uwXSm33kPjUXLe/ppvLvvYa3cJG T9Fg== 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=/IpbvFfoS/a2inIAXUuCDhwFK7xa548n8VhXg/KrwCs=; b=dtVeV108UoWgk2vy80LPPvkG3PeRRF2L75qxQLyWvItfocmpXO3H/PWyZKr7iWW7XK jMq9Ek8HKFpXAba3Rnzeax2+2GMNhOfIxEZv/Yn0Or+A7d6z29PikOY1D+g57MGoq0I4 dUaTRi1KsUg27LgVnE/+smdbnYiHNBmelvZD4Uvg4OJP1U2jiprfRI2PWk+PhMMdtls7 qoQrjRvV/hR050NUa2g7AsAlsG+u94nuhM1Mq2sIlsbGoNdziEEvoL/jc72rk0vJf2OZ lclXK9Y6tVa3DZrDJ3IsMffRdlBoXBXv31sFJJmp/8tGVqNiGygZHkCgQ3StX/pen6rG 5kRA== 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 q18si8431588pgh.498.2019.03.05.10.58.14; Tue, 05 Mar 2019 10:58:29 -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 S1731009AbfCESJY (ORCPT + 99 others); Tue, 5 Mar 2019 13:09:24 -0500 Received: from mail1.bemta25.messagelabs.com ([195.245.230.1]:20553 "EHLO mail1.bemta25.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730853AbfCESIb (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-1.bemta.az-a.eu-west-1.aws.symcld.net id B1/C0-19701-B1BBE7C5; Tue, 05 Mar 2019 18:08:27 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrIIsWRWlGSWpSXmKPExsVy8IPnUV3p3XU xBhOnSFlMffiEzeLblQ4mi8u75rA5MHvsnHWX3WPTqk42j8+b5AKYo1gz85LyKxJYMxqPLWIv mMVbcXrNeZYGxlXcXYxcHEIC6xglvr97x9zFyAnkVEjMf3yavYuRg4NXIFli20sfkDCngKPEw d51rBAlDhKNt/+ygdhsAoYS8968ZwSxWQRUJXoffmMCsYUFPCW2fDrDAmKLCHhItG7fADaeWS BW4vy8pWBxXgFBiZMzn7BAxCUkDr54wQyyVkhAS2L5sUiQsISAvcT091fBwhIC+hKNx2IhwoY S32d9Y4GwzSVur37AOoFRcBaSobOQDF3AyLSK0TypKDM9oyQ3MTNH19DAQNfQ0EjX0NJY18xM L7FKN1EvtVS3PLW4RNdQL7G8WK+4Mjc5J0UvL7VkEyMwuFMKDjrtYFy3Iv0QoyQHk5Iob19XX YwQX1J+SmVGYnFGfFFpTmrxIUYZDg4lCV6HXUA5waLU9NSKtMwcYJzBpCU4eJREeMV3AqV5iw sSc4sz0yFSpxh1OU4vfDiXWYglLz8vVUqc9xRIkQBIUUZpHtwIWMxfYpSVEuZlZGBgEOIpSC3 KzSxBlX/FKM7BqCTMywIyhSczrwRu0yugI5iAjvh8uRrkiJJEhJRUA6PJm6kTHQqP2U/4sXXz 9zjlyBB33j/cYX8+h55Rbvxi3Zh/XvabRsK35ODjfbfnP1jG6lhZsX/lpI3/xOfNqZbPPeWdm H37LvfvlXlvuQI2npWaeeek6qQLN5yS+I8XzDroz1scsnf/owvqn99xfiiVaUkPmuTHlpgfmh o3p1pK3+vDXXHlh7uVWIozEg21mIuKEwFyanO79AIAAA== X-Env-Sender: stwiss.opensource@diasemi.com X-Msg-Ref: server-20.tower-262.messagelabs.com!1551809306!2441267!5 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 30170 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:25 +0000 Received: by swsrvapps-01.diasemi.com (Postfix, from userid 22547) id 308E13FBED; Tue, 5 Mar 2019 18:08:25 +0000 (GMT) Message-ID: In-Reply-To: References: From: Steve Twiss Date: Tue, 26 Feb 2019 15:27:57 +0000 Subject: [PATCH 04/13] regulator: da9211: 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: 1028a37daa14 ("regulator: da9211: new regulator driver") Suggested-by: Adam Thomson Signed-off-by: Steve Twiss --- drivers/regulator/da9211-regulator.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/regulator/da9211-regulator.c b/drivers/regulator/da9211-regulator.c index 109ee12..4d7fe48 100644 --- a/drivers/regulator/da9211-regulator.c +++ b/drivers/regulator/da9211-regulator.c @@ -322,8 +322,10 @@ static irqreturn_t da9211_irq_handler(int irq, void *data) goto error_i2c; if (reg_val & DA9211_E_OV_CURR_A) { + regulator_lock(chip->rdev[0]); regulator_notifier_call_chain(chip->rdev[0], REGULATOR_EVENT_OVER_CURRENT, NULL); + regulator_unlock(chip->rdev[0]); err = regmap_write(chip->regmap, DA9211_REG_EVENT_B, DA9211_E_OV_CURR_A); @@ -334,8 +336,10 @@ static irqreturn_t da9211_irq_handler(int irq, void *data) } if (reg_val & DA9211_E_OV_CURR_B) { + regulator_lock(chip->rdev[1]); regulator_notifier_call_chain(chip->rdev[1], REGULATOR_EVENT_OVER_CURRENT, NULL); + regulator_unlock(chip->rdev[1]); err = regmap_write(chip->regmap, DA9211_REG_EVENT_B, DA9211_E_OV_CURR_B); -- 1.9.3