From patchwork Tue Oct 8 10:17:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 175470 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp5498433ill; Tue, 8 Oct 2019 03:17:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqz9bnVxKDZsL0Bq31+7b/uCiGcDSlFFDGfuXzKQ4RBOuSsliOzC+tk5V/zfr1CP/9PuL/8h X-Received: by 2002:a05:6402:1ade:: with SMTP id ba30mr33732615edb.304.1570529844577; Tue, 08 Oct 2019 03:17:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570529844; cv=none; d=google.com; s=arc-20160816; b=HwbUbQfFSJLIL8MAGsyA+9sBahURYlAVcOfqjRNSR2uvLkbMAwdPVcUf56G00Ho20g UT4ISKh15UvkwkipGCVVBp2Zt8VHo1mcZKYD6fq40i/WembcHZYX5ERsQZ3ylnAlNJMD l1dr0ZUhWou+IsLV5qSN9kjyA0VuA+A3BkGcBWDS7lUUrxv6pWBGDzvsIT7bNbrPsV01 Ze73kMTUYLz4roOks7k5A+DhSFdsyIehQ/JUea2+4wZz8in4+w7LvRww1ls1A1GaYewS HA2yT+4nyvgJPFJR0GDI3EzyIQeMzL9Cw/MDdiQJhnQXB5fLeBhP20yAbCUoCRmt8odE 8+kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=1+wZF/yU9WuHHeCcFGJivWrHNea0iGZi/g3TN9MHMQQ=; b=e68ZMDcpdiD6WFWzcnt9K2jaPuQJAdqXQDmfIHiQmsMAwqSCWtfzrfjCOyhX4PPdr+ a61hgRw09cILqYFjYL80g4unVZeUUUZCqzH/SLBgb4SXfRKch25t1DtHuT+tVevN50oL 1jiyuzHTYDTErJ8qTa+MgHYiHsHHcVfzepfbg4J8Z72yHTlh8py4mQnywo+oiTXa7Pxq yV4HS7y8Gex1uwfk3NP/hVuNHFasLSygPmneCn1URzHsQaVelbMwvlC2C1aTkarSQFVj iHJAfdmSYKdA3IFhrOp2Id/YUdxQH/o/CynB2ED38KZMpRjwVjt3+/+ZfN/u35KvnrJd 2TyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=nm7OjTKL; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w14si8462673ejv.112.2019.10.08.03.17.24; Tue, 08 Oct 2019 03:17:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-samsung-soc-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=@samsung.com header.s=mail20170921 header.b=nm7OjTKL; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729958AbfJHKRY (ORCPT + 3 others); Tue, 8 Oct 2019 06:17:24 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:57748 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728866AbfJHKRX (ORCPT ); Tue, 8 Oct 2019 06:17:23 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20191008101721euoutp02858c2c5ba2b564735ff848ae5f6497f6~LpJHdq8WO1819918199euoutp02B for ; Tue, 8 Oct 2019 10:17:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20191008101721euoutp02858c2c5ba2b564735ff848ae5f6497f6~LpJHdq8WO1819918199euoutp02B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1570529841; bh=1+wZF/yU9WuHHeCcFGJivWrHNea0iGZi/g3TN9MHMQQ=; h=From:To:Cc:Subject:Date:References:From; b=nm7OjTKL2jIZ17MS8Abj8htkibYpqdqRN0ySelF9tMGmbhnKj7uv8jA1q4H2s4qqf +OvKfqpuJpUkjxUkgyrE3BP9Fmb5kdoBWDhDrfHRuJY5TZ3aPEiovXfd+ZW0T5MpmB h7L0pB3Du9khHUApYRoy9dH4pmB94kohYarbSO8k= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20191008101721eucas1p1959717783bc3f42f1083c985297e554d~LpJHCsV5Q1445114451eucas1p1D; Tue, 8 Oct 2019 10:17:21 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id F6.47.04469.0326C9D5; Tue, 8 Oct 2019 11:17:20 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20191008101720eucas1p2e0d1bca6e696848bf689067e05620679~LpJGmXLmf1974719747eucas1p2b; Tue, 8 Oct 2019 10:17:20 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20191008101720eusmtrp1356238c80a62f8bf1e2d8fd7539fd755~LpJGltx-A2547325473eusmtrp1E; Tue, 8 Oct 2019 10:17:20 +0000 (GMT) X-AuditID: cbfec7f2-569ff70000001175-2b-5d9c6230050c Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 11.AE.04166.0326C9D5; Tue, 8 Oct 2019 11:17:20 +0100 (BST) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20191008101719eusmtip26fec61e9f7b9e5ce9dfb2afff62043ab~LpJGFA3Rj0176301763eusmtip2L; Tue, 8 Oct 2019 10:17:19 +0000 (GMT) From: Marek Szyprowski To: linux-kernel@vger.kernel.org, Mark Brown , Dmitry Osipenko Cc: Marek Szyprowski , Liam Girdwood , Lucas Stach , Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski , linux-samsung-soc@vger.kernel.org Subject: [PATCH] regulator: core: Skip balancing of the enabled regulators in regulator_enable() Date: Tue, 8 Oct 2019 12:17:09 +0200 Message-Id: <20191008101709.13827-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBIsWRmVeSWpSXmKPExsWy7djPc7oGSXNiDZa+s7LYOGM9q8XUh0/Y LFZ/fMxocf78BnaLB3NvMll8u9LBZHF51xw2ixnn9zFZrD1yl92B02PnrLvsHptWdbJ59P81 8OjbsorR4/MmuQDWKC6blNSczLLUIn27BK6Mlg+3WQpOC1bM/fSQsYHxCV8XIyeHhICJxM0P z9m6GLk4hARWMEq8+HyPGSQhJPCFUWLBDXaIxGdGib/v1zHCdCy785cFIrGcUaL59QEmCAeo 41L/OlaQKjYBQ4mut11sILaIQLrE2vdbwYqYBRqYJF5f/gy2Q1ggSWLOqtVgY1kEVCVuLTgO 1swrYCsxo/EN1Dp5idUbDjCDNEsIPGeT+LV3JwtEwkVide8hVghbWOLV8S3sELaMxOnJPSwQ Dc2MEg/PrWWHcHoYJS43zYAaay1x+PhFoG4OoJs0Jdbv0gcxJQQcJVrWpECYfBI33gqCFDMD mZO2TWeGCPNKdLQJQcxQk5h1fB3c1oMXLjFD2B4SX37sY4UEY6z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e2zVlae3Xi4YwqMTH5G8Fa0+8W 9ryotTxV/vWH1KPeiz9/NvpeO77a1GB97eGnl05rehlPyFQvkni37oKICdudB6f2T5RXYinO SDTUYi4qTgQA/D4bhmECAAA= X-CMS-MailID: 20191008101720eucas1p2e0d1bca6e696848bf689067e05620679 X-Msg-Generator: CA X-RootMTR: 20191008101720eucas1p2e0d1bca6e696848bf689067e05620679 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20191008101720eucas1p2e0d1bca6e696848bf689067e05620679 References: Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org Commit f8702f9e4aa7 ("regulator: core: Use ww_mutex for regulators locking"), regardless of the subject, added additional call to regulator_balance_voltage() during regulator_enable(). This is basically a good idea, however it causes some issue for the regulators which are already enabled at boot and are critical for system operation (for example provides supply to the CPU). CPUfreq or other drivers typically call regulator_enable() on such regulators during their probe, although the regulators are already enabled by bootloader. The mentioned patch however added a call to regulator_balance_voltage(), what in case of system boot, where no additional requirements are set yet, typically causes to limit the voltage to the minimal value defined at regulator constraints. This causes a crash of the system when voltage on the CPU regulator is set to the lowest possible value without adjusting the operation frequency. Fix this by adding a check if regulator is already enabled - if so, then skip the balancing procedure. The voltage will be balanced later anyway once the required voltage value is requested. Fixes: f8702f9e4aa7 ("regulator: core: Use ww_mutex for regulators locking") Reported-by: "kernelci.org bot" Signed-off-by: Marek Szyprowski --- This patch fixes enabling coupled requlators on Exynos5800-based Peach-Pi board done by the following patch: https://patchwork.kernel.org/patch/11172427/ Once it has been applied, the following issue has been reported: https://patchwork.kernel.org/patch/11176661/ --- drivers/regulator/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index afe94470b67f..aca74b83f3bc 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -2481,7 +2481,8 @@ static int _regulator_enable(struct regulator *regulator) } /* balance only if there are regulators coupled */ - if (rdev->coupling_desc.n_coupled > 1) { + if (rdev->coupling_desc.n_coupled > 1 && + !_regulator_is_enabled(rdev)) { ret = regulator_balance_voltage(rdev, PM_SUSPEND_ON); if (ret < 0) goto err_disable_supply;