Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1826867imm; Tue, 22 May 2018 09:57:25 -0700 (PDT) X-Google-Smtp-Source: AB8JxZojSBiKznvR1o3LOheBe3JpswwRcaHm1M38hW49bBOU1o8VPMZmtz2BS54bAEcbEXqBTwuc X-Received: by 2002:a63:8c05:: with SMTP id m5-v6mr1905226pgd.98.1527008245102; Tue, 22 May 2018 09:57:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527008245; cv=none; d=google.com; s=arc-20160816; b=QX5LkOyz784trJC4nBnTmQ4NBHPaPBsuGCW4HVO1JBxKDoFwDIAigKnXAsHoPDYWgl LWQh1ily29qM8ntap/fBeNzMhNSDEyQ/526E5XGID1vBBkgIUA0tydGPx2W4i8fQ4CHn bp2rDxt+KrWdVvFkcWLojdy6vbc4p3CaIIhh0R1lGegLo30uKYQrWaTGTcpRGo0nyRA6 ej1yFUfQFjFxoY3xrcjpc2+vB+WfZyk0ZItvInCwfH+xGW8TFf90wh4MtmCBVWTBdOYG qrljL5OgfA/J8PoDBm/+2+tWet1rk4CwlDCoYjWsqvpHdiRRqBCJqhrVlMI6jO69JJXv Ijow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=LGfNKm6BWIBM16eNOo1vGd5dT6d80NqR4Jh5jhoZA6c=; b=ADmAYn13tp3sG+A+SxwJspEBh/7KpntR8H3VVkRYFQVexQECM/cZw06ktpiUXqSeo1 z7K6MoNLt/QgHmoHhoKp9T5bX2JZiPjD+BZ8KcYBn/Nr8+HeUY3yxnilWXgQ9+p9HvwC LmdZhHJ0xe5ghFFwK1+WtYsMMqIlwP1ubINAM/9H9ocU+QimsyYSUMH3Ujj9qiVdKzE3 IvjauBFB8cjJck++mnn14fNP3aMdlM4Jc9Fy4aGqvSerWmHzRNJqJ0mLgeXPWlpo8ckD JZEJgGwhD+OVW6I0BDjTaiCnH6B7pS9SlOoOwUg1NtLV0XEwD9drpbcJ1q5f4u8FXgxs 9c8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=CDuF2EBv; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j12-v6si13080241pgf.222.2018.05.22.09.57.09; Tue, 22 May 2018 09:57:25 -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=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=CDuF2EBv; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751495AbeEVQzo (ORCPT + 99 others); Tue, 22 May 2018 12:55:44 -0400 Received: from heliosphere.sirena.org.uk ([172.104.155.198]:43934 "EHLO heliosphere.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751229AbeEVQzm (ORCPT ); Tue, 22 May 2018 12:55:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: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=LGfNKm6BWIBM16eNOo1vGd5dT6d80NqR4Jh5jhoZA6c=; b=CDuF2EBv9nFfG0VzoxZh0rmEt oSp6GUO+kQG/iORqOwbyNAYD3XXBrCMZ1H6+4Nb/LoICsK4J+BSHBU1ATusKyaWVHpLLqTVYW3+xT sFWDoAb1321yRP9XFn7deDQx8St+LtCAEILM1QZqV9kINUpsxwio3MO2k+6rtqgLuX69I=; Received: from debutante.sirena.org.uk ([2001:470:1f1d:6b5::3] helo=debutante) by heliosphere.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1fLAZW-00025r-OZ; Tue, 22 May 2018 16:55:38 +0000 Received: from broonie by debutante with local (Exim 4.91) (envelope-from ) id 1fLAZW-0000Il-3h; Tue, 22 May 2018 17:55:38 +0100 Date: Tue, 22 May 2018 17:55:37 +0100 From: Mark Brown To: Doug Anderson Cc: David Collins , Liam Girdwood , Rob Herring , Mark Rutland , linux-arm-msm@vger.kernel.org, Linux ARM , devicetree@vger.kernel.org, LKML , Rajendra Nayak , Stephen Boyd Subject: Re: [PATCH v3 1/2] regulator: dt-bindings: add QCOM RPMh regulator bindings Message-ID: <20180522165537.GE24776@sirena.org.uk> References: <41d5df73ddac772551d2966e0752bb0c357b1ded.1526088081.git.collinsd@codeaurora.org> <869aad59-1cc5-28ef-1fb5-4ef846696c40@codeaurora.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="OZkY3AIuv2LYvjdk" Content-Disposition: inline In-Reply-To: X-Cookie: I have not yet begun to byte! User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --OZkY3AIuv2LYvjdk Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, May 22, 2018 at 09:43:02AM -0700, Doug Anderson wrote: > On Mon, May 21, 2018 at 5:00 PM, David Collins wrote: > > Returning the cached (but not sent) initial voltage equal to the min > > constraint voltage in get_voltage() calls should not cause any problems. > > This represents the highest voltage that is guaranteed to be output by the > > regulator. Consumer's should call regulator_set_voltage() to specify > > their voltage needs. If they simply call regulator_enable(), then the > > cached voltage will be sent along with the enable request. > I'm still not seeing the argument for initial-voltage here. If we > added a feature like you describe where we don't send the voltage > until the first enable couldn't we use the minimum voltage here? If a > consumer calls regulator_enable() without setting a voltage (which > seems like a terrible idea for something where the voltage could vary) > then it would end up at the minimum voltage. Or if something else has already set a voltage... though shared voltage varying regulators aren't a superb idea they do occasionally happen. > >> I was asking for specific examples. Do you have any? > > I was able to track down an example that requires initialization at a > > non-minimum voltage: PM8998 LDO 13 on SDM845 MTP. This regulator supplies > > the microSD card with a voltage in the range 1.8 V to 2.96 V. The boot > > loader leaves this regulator enabled at 2.96 V. It is only guaranteed to > > be safe to reduce the voltage to 1.8 V on UHS type cards and only after > > following the proper SD identification and command sequence. > Ironically, this is also a perfect example of why we _shouldn't_ have > an "initial-voltage" specified in the device tree. It is certainly > plausible to imagine a bootloader that might enable UHS speeds on an > SD card and leave the rail on at 1.8V. Having an initial-voltage > specified in the device tree would be a bad idea here because it's > even worse to transition to 2.96V when the card was expecting 1.8V. Right, this sort of situation is why the regulator API has a policy of leaving things untouched unless it was specifically told to do something. > I suppose this is a theoretical example since (as far as I know) no > bootloaders run the micro SD card at UHS speeds, but it is still kexec is the most obvious example I can think of here. You could probably arrange for something to patch the device tree that's provided to the kexeced kernel to tell it about the current state but we don't currently do anything there. > OK, so how's this for a proposal then: > 1. For RPMh-regulator whenever we see a "set voltage" but Linux hasn't > specified that the regulator is enabled then we don't send the > voltage, we just cache it. > 2. When we see the first enable then we first send the cached voltage > and then do the enable. > 3. We don't need an "initial voltage" because any rails that are > expected to be variable voltage the client should be choosing a > voltage. That seems relatively safe. > You can even come up with a less contrived use case here. One could > argue that the SD card framework really ought to be ensuring VMMC and > VQMMC are off before it starts tweaking with them just in case the > bootloader left them on. Thus, it should do: > A) Turn off VMMC and VQMMC > B) Program VMMC and VQMMC to defaults > C) Turn on VMMC and VQMMC > ...right now we bootup and pretend to Linux that VMMC and VQMMC start > off, so step A) will be no-op. Sigh. > Do we need to have ".is_enabled" return -ENOTRECOVERABLE to help the > regulator framework understand that we don't know the state? I think Yes, we should be doing that. Then subsystems where it's an issue can explicitly turn off the supply. > that might require a pile of patches to the regulator framework, but > it can't be helped unless we can somehow get RPMh to give us back the > status of how the bootloader left us (if we had that, we could return > 0 for anything the bootloader didn't touch and that would be correct > from the point of view of the AP). I think it's fine from a framework point of view, just provide an is_enabled() operation which returns the error. The required fiddling in the core should be fairly minor. --OZkY3AIuv2LYvjdk Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAlsES4kACgkQJNaLcl1U h9AzUwf9FzNerHoeUPdczcZoyOO51AFp/II2N3caAmCEgxX2DnmGrq9yelc4T/ze O02VEOavGMsmcd/TvPbAATCoee1z+pfJzvnqh3ISgB5mEeQ9xM9614P0Oz9dPAv0 lM9DGJlsVy3ZvuUywKQqsk5iru3QNTDbipLazNaFfzP3/ciHSex8LdlilSu2praM pffRmgHpO6M+qgmDap9+z5tbtJIgP5gmOdKLZQSWXQMchHeZieITAUkyTyHgT56Q NRwAkPOHA7p5MgCh785jrxjDrU0JIk9Nb87wpmi05aw+m7bcjUV8OQAFDhuuNflt tTuRbh+mp2QEOZXQVGrXhtBm1wgIPg== =SKz+ -----END PGP SIGNATURE----- --OZkY3AIuv2LYvjdk--