Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5582931img; Wed, 27 Mar 2019 11:07:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqwN6HmofSh88OOi6RCr5/auBHDXgzL/AzmhoAFpY7Oi2NfJ3mXuh7hUZpURFg5xBsyDwNVw X-Received: by 2002:a63:4542:: with SMTP id u2mr35114733pgk.291.1553710068008; Wed, 27 Mar 2019 11:07:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553710068; cv=none; d=google.com; s=arc-20160816; b=tM9++09YeYpP89R8iBH+gaIXA+Evo9Kp+6FN0eE7qGvCtcpethcpnO541GgTTFE/Vy pVkbyswqaQdHIi2Gezg4cOdshOnevXwZwiLrWH5SYhWMBQVM9ZbY3uqcZCCXS60vhwXD JFoCCQIx0tZPmzfrFv/NOh1/F0SNTvl6VPWGKidWOxr7OQEpyG4Z29uskMMdQEFOvlDj mWU1P78cBaQBPLq8BxE7YON50U1eoVsToEYIOh0z32+oWqPoKmqo83YVSd5HVuo6OKci 661qeAsKthxi+MitpcF+hJcqeetHzhCkg/dJfuUUe/1l9c6jbhT0REhxwFs7juyMDuk5 lehw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2sv0TiMx8+2EBVQEWkwQftJ0FQHVpc7wIpr5D7qFdbM=; b=dyPRP6UrE3a+tO/RyJfd7ShM+PHilA1/8olkH/n1dF8NeO0H5JSSjDShZ2k4zrzdEz ob704DJPX/MdR5v294Dcx350po+KWjECGo19XkRWzt6JRSrTDzyV/We779WX2A6gQxxU RqWrYScK+WnKc579l5XvV4jw3051zIQX8tMlqNpc7nzSJziznohCIeqcnOQM/Qo1no9w ya3czcNWi+yEOOxv7csDyUZDTa4kviWXx57YBb/pi234btL6R36rV0toxVyQA6brZhpB 2h9JsqFuDNvMk2/aS877yeBIceGyMhvdISwQehL3zDsU+GQ/QnsbtwXVAOWB+x48CC9t hW0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XX3LhIyh; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w2si18378548pgp.266.2019.03.27.11.07.32; Wed, 27 Mar 2019 11:07:47 -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; dkim=pass header.i=@kernel.org header.s=default header.b=XX3LhIyh; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387882AbfC0SGL (ORCPT + 99 others); Wed, 27 Mar 2019 14:06:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:47638 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387865AbfC0SGI (ORCPT ); Wed, 27 Mar 2019 14:06:08 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A5B2E217D9; Wed, 27 Mar 2019 18:06:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553709967; bh=U7tU5y2CRENKlerLOQ5CeCmU75qni7Iu4sfRbfu8gk8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XX3LhIyhKtv8c6DZJpnc2ADJZDTfC/hxK4e8nFV2Ykk4AYhgvf6f1qIiJhE/Csaz6 KLcoDtSS0X4rIMUEXpv9naItaBowr1PgD6VDBWflo10b50pSC9gozOQZUNfeNcAZBZ FrTq55RYzwtWl487hsasGBFlTd7UmZvJ8FlblKI4= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Niklas Cassel , Mark Brown , Sasha Levin Subject: [PATCH AUTOSEL 5.0 136/262] regulator: core: Take lock before applying system load Date: Wed, 27 Mar 2019 13:59:51 -0400 Message-Id: <20190327180158.10245-136-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Niklas Cassel [ Upstream commit e5e21f70bfd3a201e627b48aed82793d1bcd6f78 ] Take the regulator lock before applying system load. Fixes the following lockdep splat: [ 5.583581] WARNING: CPU: 1 PID: 16 at drivers/regulator/core.c:925 drms_uA_update+0x114/0x360 [ 5.588467] Modules linked in: [ 5.596833] CPU: 1 PID: 16 Comm: kworker/1:0 Not tainted 5.0.0-rc6-next-20190213-00002-g0fce66ab480f #18 [ 5.599933] Hardware name: Qualcomm Technologies, Inc. APQ 8016 SBC (DT) [ 5.609544] Workqueue: events qcom_channel_state_worker [ 5.616209] pstate: 60000005 (nZCv daif -PAN -UAO) [ 5.621152] pc : drms_uA_update+0x114/0x360 [ 5.626006] lr : drms_uA_update+0x110/0x360 [ 5.630084] sp : ffff0000124b3490 [ 5.634242] x29: ffff0000124b3490 x28: ffff800005326e00 [ 5.637735] x27: ffff0000124b35f8 x26: 000000000032bc48 [ 5.643117] x25: ffff800004c7e800 x24: ffff800004c6d500 [ 5.648411] x23: ffff800004c38a80 x22: 00000000000000d1 [ 5.653706] x21: 00000000001ab3f0 x20: ffff800004c7e800 [ 5.659001] x19: ffff0000114c3000 x18: ffffffffffffffff [ 5.664297] x17: 0000000000000000 x16: 0000000000000000 [ 5.669592] x15: ffff0000114c3808 x14: 0720072007200720 [ 5.674888] x13: 00000000199c9b28 x12: ffff80002bcccc40 [ 5.680183] x11: ffff000012286000 x10: ffff0000114c3808 [ 5.685477] x9 : 0720072007200720 x8 : ffff000010e9e808 [ 5.690772] x7 : ffff0000106da568 x6 : 0000000000000000 [ 5.696067] x5 : 0000000000000000 x4 : 0000000000000000 [ 5.701362] x3 : 0000000000000004 x2 : 0000000000000000 [ 5.706658] x1 : 0000000000000000 x0 : 0000000000000000 [ 5.711952] Call trace: [ 5.717223] drms_uA_update+0x114/0x360 [ 5.719405] regulator_register+0xb30/0x1140 [ 5.723230] devm_regulator_register+0x4c/0xa8 [ 5.727745] rpm_reg_probe+0xfc/0x1b0 [ 5.731992] platform_drv_probe+0x50/0xa0 [ 5.735727] really_probe+0x20c/0x2b8 [ 5.739718] driver_probe_device+0x58/0x100 [ 5.743368] __device_attach_driver+0x90/0xd0 [ 5.747363] bus_for_each_drv+0x64/0xc8 [ 5.751870] __device_attach+0xd8/0x138 [ 5.755516] device_initial_probe+0x10/0x18 [ 5.759341] bus_probe_device+0x98/0xa0 [ 5.763502] device_add+0x3d0/0x640 [ 5.767319] of_device_add+0x48/0x58 [ 5.770793] of_platform_device_create_pdata+0xb0/0x128 [ 5.774629] of_platform_bus_create+0x174/0x370 [ 5.779569] of_platform_populate+0x78/0xe0 [ 5.784082] qcom_smd_rpm_probe+0x80/0xa0 [ 5.788245] rpmsg_dev_probe+0x114/0x1a0 [ 5.792411] really_probe+0x20c/0x2b8 [ 5.796401] driver_probe_device+0x58/0x100 [ 5.799964] __device_attach_driver+0x90/0xd0 [ 5.803960] bus_for_each_drv+0x64/0xc8 [ 5.808468] __device_attach+0xd8/0x138 [ 5.812115] device_initial_probe+0x10/0x18 [ 5.815936] bus_probe_device+0x98/0xa0 [ 5.820099] device_add+0x3d0/0x640 [ 5.823916] device_register+0x1c/0x28 [ 5.827391] rpmsg_register_device+0x4c/0x90 [ 5.831216] qcom_channel_state_worker+0x170/0x298 [ 5.835651] process_one_work+0x294/0x6e8 [ 5.840241] worker_thread+0x40/0x450 [ 5.844318] kthread+0x11c/0x120 [ 5.847961] ret_from_fork+0x10/0x18 [ 5.851260] irq event stamp: 9090 [ 5.854820] hardirqs last enabled at (9089): [] console_unlock+0x3e0/0x5b0 [ 5.858086] hardirqs last disabled at (9090): [] do_debug_exception+0x104/0x140 [ 5.866596] softirqs last enabled at (9086): [] __do_softirq+0x474/0x574 [ 5.875446] softirqs last disabled at (9079): [] irq_exit+0x13c/0x148 [ 5.883598] ---[ end trace 6984ef7f081afa21 ]--- Fixes: fa94e48e13a1 ("regulator: core: Apply system load even if no consumer loads") Signed-off-by: Niklas Cassel Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/regulator/core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index b9d7b45c7295..e2caf11598c7 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1349,7 +1349,9 @@ static int set_machine_constraints(struct regulator_dev *rdev, * We'll only apply the initial system load if an * initial mode wasn't specified. */ + regulator_lock(rdev); drms_uA_update(rdev); + regulator_unlock(rdev); } if ((rdev->constraints->ramp_delay || rdev->constraints->ramp_disable) -- 2.19.1