From patchwork Wed Mar 22 16:53:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonard Crestez X-Patchwork-Id: 9639413 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C0F696020B for ; Wed, 22 Mar 2017 16:54:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ADE7528452 for ; Wed, 22 Mar 2017 16:54:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A150028458; Wed, 22 Mar 2017 16:54:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EE2A728452 for ; Wed, 22 Mar 2017 16:54:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=BPJfzhZUoNr+hxrfDVqf0wS7nEF/Sme94b0J0v31KuU=; b=QChWohPiuT/RaM buFNGILsNcaAk+7O5jdW6vIT/Crt6Ax45uG7yCiC0OZb7yPv2GK4TjTb9qrqiWyAnNeafCGSv1pal nhhLSTrcUYt1fdOVEL48dDeTGXrUP8b9tsyDLDf9Agh0JvUcaAflNDIsqlxZtLmHijCdfnpOHkj6o /5NRRCZ/R8x1SQk/wpbHbMTHv5ajyM82vZV31SVt/YsZ3w5jBKomPJHrlVGeu4xQ94O+ykkpISqcr SEUSU0S/J775rdFT348pMq1P1cSEhni2RTWOIjCIb/XPefwjw8UXw4ejSl1q5/tGSColKXaYLxG0V /+29zItnXIcE2RCclNgw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cqjX6-0003ma-9d; Wed, 22 Mar 2017 16:54:48 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cqjWQ-00034p-5l for linux-arm-kernel@bombadil.infradead.org; Wed, 22 Mar 2017 16:54:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=F1ZVBAKENiPCgQCY5cCthYbVvnp1pmdbBGAjy3yxurs=; b=x8bAclpJVMQ/Ljpr59jHsGDpC xkKhcf10AZo8G4cCfv5xwhjGXnFnU4GkPu0+jgCueF6gGYPr7HNibhd2+hUQF0vBLWumewsAcOH5z NyFsCiax24Yz1JkC0N67juRHoPsBtgGxUQxIns5cE7XV1CduuULXmDWteqmtS38bW3askzskXf0Sh PzrT5KiP7dpwgyLBFJlnn4LI7w8KpVKdvQMGJwVMsMHvY7r6qIEhRgzo5HOC2W2loV9PVuTwONP4h DN6x1v3nan/FA5/srWIcW+ESlQ3tw8io+axuaCYw+YENPZaa2fcyrrCmqNI4nuieBR0fIuOksGMWZ LMwDwvsGw==; Received: from mail-cys01nam02on0064.outbound.protection.outlook.com ([104.47.37.64] helo=NAM02-CY1-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cqjWO-0008Qh-CE for linux-arm-kernel@lists.infradead.org; Wed, 22 Mar 2017 16:54:05 +0000 Received: from BN6PR03CA0070.namprd03.prod.outlook.com (10.173.137.32) by SN2PR03MB2272.namprd03.prod.outlook.com (10.166.210.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.961.17; Wed, 22 Mar 2017 16:53:42 +0000 Received: from BN1AFFO11FD041.protection.gbl (2a01:111:f400:7c10::195) by BN6PR03CA0070.outlook.office365.com (2603:10b6:404:4c::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.977.11 via Frontend Transport; Wed, 22 Mar 2017 16:53:42 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1AFFO11FD041.mail.protection.outlook.com (10.58.52.252) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.977.7 via Frontend Transport; Wed, 22 Mar 2017 16:53:42 +0000 Received: from fsr-ub1664-115.ea.freescale.net (fsr-ub1664-115.ea.freescale.net [10.171.73.212]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v2MGrKXc024800; Wed, 22 Mar 2017 09:53:38 -0700 From: Leonard Crestez To: Mark Brown , Liam Girdwood , Viresh Kumar , "Rafael J. Wysocki" , Shawn Guo , Sascha Hauer Subject: [RFC 4/8] regulator: core: Check enabling bypass respects constraints Date: Wed, 22 Mar 2017 18:53:06 +0200 Message-ID: <1edff9bc610969b0c53fa1080d5db021c8e00b2d.1490199005.git.leonard.crestez@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: X-EOPAttributedMessage: 0 X-Matching-Connectors: 131346752222383112; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(336005)(39450400003)(39860400002)(39850400002)(39400400002)(39410400002)(39840400002)(39380400002)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(9170700003)(305945005)(48376002)(356003)(86362001)(77096006)(33646002)(47776003)(6666003)(38730400002)(39060400002)(106466001)(4326008)(50226002)(8936002)(85426001)(5003940100001)(189998001)(2950100002)(50466002)(104016004)(36756003)(50986999)(5660300001)(8676002)(54906002)(105606002)(53936002)(7416002)(81166006)(8656002)(118296001)(76176999)(2906002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN2PR03MB2272; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; A:1; MX:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD041; 1:uXYaiGOH+omOEZzhkyAl5Dx/TWSx6A3R/SjIAQ9JfZN7l3385A9wh660RLFeBpRZ5InsUh6EqTJ9vkmD/Y3bz5ucd8LcfgpWzyAgcFQHjy5uh0F1LvpwaUsEEuP/j0V6AhFLQNYc++0UTQax6BxvQNqascljL2oZYNORLAmd/32MP3OKgvqn2QgitgC/uZmzjNAQkZCGqLz4ldPpsNMA6vX7ihD+h7RtQ0shwz363z/xXqqIbDYq0MzdxwrdatqUzc/DZrx6fBU/geoNi2FtDiMPdKMEaSlNIoetRSm9bCKgivmY9LXVC7c/Aj5wT640+55q6iByaLav9pJ9Mi4xahq6wftTeCSrCpqq3xJwhCcPwGtIUWHBlNQer8UOCU5WFHesF856t0GXVun35ziBGwSW0qY6Fuli5IVTh7i2ZlP3psSuHBgNF1aDJfpU6UAS6Q5HG5+kcqh747VUsvrXLLqrG4j52c6ryOGPs3wNdrFS8sdiXYvtk/BkfRUcHR9IkBLYvArQtYlNQUaVRx/WrD2lojsGrKYo6wuBtb1GkV/neTv6TouKz6mngDZoe1QkOumrEN4K89QXTyPY8bTGX5VBAgNR/rjnkwjCdK7VWOtD1fLiZJaxFFa7wwnai4Ua MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 85588de1-a921-4492-cc08-08d47143ff14 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:SN2PR03MB2272; X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2272; 3:6mG94Nemb8o2Aeo2x8VGxPY+Z0Xps5M18YDDhI1mGOgosXRoZVlglIHI3DenmqsV5Hlfa6O5f72uNXNvna5PlFUGNtSPMAXjL79gO6hc4vax3iDUx9zJ6oBxO1cDLwEv431gYWxnlt+ChLUvH1s5fyXE4qobdLWhnsRS6R85VlwOzMYIA7TdonKopW3PMcAZdz8ZxrKtfNuqD4rSZXTzLBeN2l5b8oe5yVttedyNhDtISeRtHTWZeSbV3Vj8kKk4IQCfCevREaGayDAKgU2gLG6tWiZgmSLO9DXVlpmb25ndzi2pngonklGlbCxYwNi18XFI2zfZkXEtwpOa9Ug/38K642j9JsstnOhWVjUHuVyWdpClDUAIoINXV39XLrXE; 25:r41hDF6JAUux57qS6QxFK8gUEsZXREeCKe7ZtoocZ57RavItQ9nGdxy11rh/LEtOqRJMzYbC80SW+TnWk5a77U5OU6HfaKSQuqJMBt4sKhbmnEcid3E9CWezO5dAXMJNpjp+zriJEU4aWva3EzjzkYGoEPfEe69zQz2QTiu4sLigCR6RUEfrOZ2LTjDqT+D6j0W8Z+seDUBKJJQGS2wgxkU+tV3alYb26kcSrOkXBUwLXVk6udgE73ySTI0BT7WpksYJLEk0Myo90xAB4g/VZSkXdkLfDfiIRh8MTAypMlE0hanlkd3wBF9fs2eAWUgtj7PTW5JoKWwlhI45/WJutQ5/7k35zQ4suonDPo8NftNrbet05+eaZ5y9pUA5Rv12g9c6c1Dg3gm2Ekthl99+GcUvaDaW6qFsnPdtE/mfCA9f8m3WdZXk5WPjUesG2kcvJHlRx0UrzzJQiq/Wzk2Fgw== X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2272; 31:/5kqp0FD2/eFHriq8/6DIT6ZtlzSvyRsC+4zqUNLYt3p7g7EAdJxPqHggLb4sgAmUJl6D60kMWTLlJh8zpTS5AaL/Y6QwgecLl+VUCKyrLXAtSE9AA1f+IJwfD9/lJURCdE3AY4CBmH4ZFIO606OgUI9nkcIuYOvUn+ECMQ97wNOQljWoymrIUjZBmTOHnfxE5vdo1x4t0AU+aQRfl9t0aVGtGLdKnoSZJPGRWCDIi44maCWyfPhp12v1xxDR/99kU+Zu02nXSFdQqFiXPmAMA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095060)(601004)(2401047)(13023025)(13015025)(5005006)(13017025)(8121501046)(13024025)(13018025)(3002001)(10201501046)(6055026)(6096035)(20161123559025)(20161123556025)(20161123565025)(20161123563025)(20161123561025); SRVR:SN2PR03MB2272; BCL:0; PCL:0; RULEID:(400006); SRVR:SN2PR03MB2272; X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2272; 4:O1bLO4+8GOZDL0NhVGA7Sba18U650gf5BFNKWYvzSmWpV0TB6sjGmegMTEwD/FoY88cMvmsJAC0DMvR3cBUhK80mxryhHnJrUxllj5/vhfcb+oxintfeT3EY0+MJiOKIsONoyt7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n3hr?= =?us-ascii?Q?U61oJTYmg3iCFV9WaxLlOixT6G3I/hTN/qC1LvOYWexCZnLBaaXt6Hf4w=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2272; 6:ee+5YmPhPDzeqVTvVWqGs/S/14AaaKDnvuiaQEtkkdCWMgJTqr3DygkGBtCsHg8yNPTWTg3pug+efgh391y2LzPvfuXudLU7sDflgQwesrn9SJ4V5DmdaNd2mfwIoJNGRbcVPKxUB5Yd0cQ1C9rdFUnLVbjJDgiOIL3Ef17LaacewfkwwDYKE8SCj/vfLXsdFDNELs6A4oYPdIItP2omNNE9uzy/38QHuuolDd7aZ1gz7LV00Lxls6WBuMXi2g7NtC2NJbhCsbX3BF+PFqO2NsU2Q/Jk79+sQnW9SJrOrVlRzljeHsrwe4bL2dsgKtb8RiDSYenwbYfRqJY/RWVTHEMcUWt4Lb8BXdss8vvO4AA21pHXsTr9DmhAZXrcs+c9HoavzRejKmQSsaKOwy19+QDMDV9BTRrOH0/+uOMoi38=; 5:QOgDWDX5AqPmEqJCVuMOQwdkpWcVP5/pFR1WXB3+SpUoTSB/Gw+/i56KrA6NEpSlaeQf1Tt69oxsUGCHuwD84rBcHpX2sCazMVTyoTgmXaQbUpf2Eyt0HHF+i9HCOpxL7KExpqN3kdQqnTfS1u4QBcnskjIWbSAX3XWs276rbVE91Bi748KlmY8787sFtlAn; 24:I+lEuZXV8sNFQVQh2pK2tuqXcTlif9PDtLy+ckYdrQhqbqIelhok5hxOrHkhKGgaPW/AKaHbB1jKvrj98cYjh+OqklGT7BfsT93yUDmcqNE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2272; 7:8AGjnKmlvlMvSIC9irCBtchPXQ+TcL1KMDSOgtSNTw9UrxBhTeEkCmv7lLEn2aLdlr+3+e9R9pFbFyWntp0FHgH5dwwO/ugWTaCdoBny/PpYok8nTzVt3hgySW/CpHn4N4McQ30XUhZHMARaw4Z8POZQzdAv/3FPo7Hn5qzNERw8RiuMLdzNFyVi49jgvyTDijMFy7jgi236zzUq0qdnDR1i6RfQ6B/gapKRegNLK9MRSXu3mAnpDaqjAiKVydf9EPjlJ8ZmPHmmWvsr99WPaVjylQqrCiL9yhkBvnkw44+2mjWW1prfBFsuadeUtKSf7NyS1cvx7vAavInq9jdq7w== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Mar 2017 16:53:42.0043 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR03MB2272 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170322_125404_571142_49B7E8A6 X-CRM114-Status: GOOD ( 17.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Leonard Crestez , Anson Huang , Irina Tirdea , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Rob Herring , Octavian Purdila , Fabio Estevam , Robin Gong , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Enabling bypass mode makes a regulator passthrough the supply voltage directly. It is possible that the supply voltage is set high enough that it violates machine constraints so let's check for that. The supply voltage might be higher because of min_dropout_uV or maybe there is just an unrelated consumer who requested a higher voltage. Signed-off-by: Leonard Crestez --- drivers/regulator/core.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 53d4fc7..9d893aa 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -3453,6 +3453,54 @@ int regulator_set_load(struct regulator *regulator, int uA_load) } EXPORT_SYMBOL_GPL(regulator_set_load); +static int _regulator_set_bypass(struct regulator *regulator, bool bypass) +{ + struct regulator_dev *rdev = regulator->rdev; + int output_voltage; + int supply_voltage; + + if (bypass && !rdev->supply) { + rdev_err(rdev, "Refuse to set bypass on regulator with no supply!\n"); + return -EINVAL; + } + + /* Check that enabling bypass won't break constraints */ + if (bypass && _regulator_is_enabled(rdev)) { + output_voltage = _regulator_get_voltage(rdev); + if (output_voltage < 0) { + rdev_err(rdev, "Failed to get old output voltage before" + " enabling bypass: %d\n", output_voltage); + return output_voltage; + } + supply_voltage = _regulator_get_voltage(rdev->supply->rdev); + if (supply_voltage < 0) { + rdev_err(rdev, "Failed to get supply voltage before" + " enabling bypass: %d\n", supply_voltage); + return supply_voltage; + } + if (supply_voltage < rdev->constraints->min_uV || + supply_voltage > rdev->constraints->max_uV) { + rdev_err(rdev, "Enabling bypass would change voltage" + " from %duV to %duV violating" + " constraint range %duV to %duV\n", + output_voltage, + supply_voltage, + rdev->constraints->min_uV, + rdev->constraints->max_uV); + return -EINVAL; + } + rdev_dbg(rdev, "Enabling bypass would change voltage" + " from %duV to %duV respecting" + " constraint range %duV to %duV\n", + output_voltage, + supply_voltage, + rdev->constraints->min_uV, + rdev->constraints->max_uV); + } + + return rdev->desc->ops->set_bypass(rdev, bypass); +} + /** * regulator_allow_bypass - allow the regulator to go into bypass mode * @@ -3481,7 +3529,7 @@ int regulator_allow_bypass(struct regulator *regulator, bool enable) rdev->bypass_count++; if (rdev->bypass_count == rdev->open_count) { - ret = rdev->desc->ops->set_bypass(rdev, enable); + ret = _regulator_set_bypass(regulator, enable); if (ret != 0) rdev->bypass_count--; } @@ -3490,7 +3538,7 @@ int regulator_allow_bypass(struct regulator *regulator, bool enable) rdev->bypass_count--; if (rdev->bypass_count != rdev->open_count) { - ret = rdev->desc->ops->set_bypass(rdev, enable); + ret = _regulator_set_bypass(regulator, enable); if (ret != 0) rdev->bypass_count++; }