Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp146715imm; Tue, 22 May 2018 15:47:21 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq2oA6eJF4gHumgoCqcCUSKyDXW86FQ4Sj5DM5JqPptibxGf7ZfPMpUe4pvBb6M5hygpM3t X-Received: by 2002:a63:7986:: with SMTP id u128-v6mr271453pgc.127.1527029241199; Tue, 22 May 2018 15:47:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527029241; cv=none; d=google.com; s=arc-20160816; b=jTiumjMAsdKj26ID2dQdgyxS0ShPGoXi+gB/lnF42xncAwS6oYXeYuVOyMarBEe7mI kEqwYrVZtDYsAxnd2EMaFrLWVqJjEynYykkwJxZLJEV3+GZaG4weHQMzshjBEDJZwRSK LZ1Pa8X7o/Uvoa45HVh59FT9Pp5Bce0vZKbDZgRqCFoSh5IjBnryDLJRN4oOK5QjuZnG jICEXxSb12ceSy6CsBh+UOwr8Yh/rtBC3iiMzx7hUjKODc2EYWllURAA30VNuQYY1fLt 48xAERyUvv+6TkA5YDLpyoVbo0NljVdMPrDD/UoLpycEkBUQfb6wVNZ7XEYvUBd364qk RBfw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dmarc-filter :dkim-signature:dkim-signature:arc-authentication-results; bh=NG9N9DZbzh2pMIYzfxkQlhbet3ZkmR1Cz6dT6Jgv/mw=; b=O1wHCzV4WDPxoz/8bH0R/Af6SviW568YwrHW3tGgAsFpf7MoQ7E3A1SBNlIUgpAByg xPcogG2oCKtKFeUEqq55isIFpgNABkJjLFFF7BNAihN8SF6aHkwXeYtVlP3AwJUwNXTE tFDsaq2E3jCqoC0EN7yvUc8REbH1K6UJkGZYwTmIBtnbUm2k9wNAwFublywap8dKTTCx 3LNEmEPrcTAz7uHa+QC1yauRRXBo+eVLABZpXq0CO+kgFtsjOXtMO9zCDuOPnYM9KOSV iar9VxykQrH1lzGDWsa5P9X6grVmEpgL5FpfrvzEJR128sxbaHo9Bdc/FTSqigHccHb9 GvTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=hK6Eysyo; dkim=pass header.i=@codeaurora.org header.s=default header.b=KUt/uRLv; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x2-v6si16800643plv.388.2018.05.22.15.47.06; Tue, 22 May 2018 15:47:21 -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=@codeaurora.org header.s=default header.b=hK6Eysyo; dkim=pass header.i=@codeaurora.org header.s=default header.b=KUt/uRLv; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753406AbeEVWqN (ORCPT + 99 others); Tue, 22 May 2018 18:46:13 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:37676 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753139AbeEVWqJ (ORCPT ); Tue, 22 May 2018 18:46:09 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 62CDF60767; Tue, 22 May 2018 22:46:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527029169; bh=yxzgHog9mv1G7LCdZaX6LU/WW6Vzem/3txU7M6sJFQU=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=hK6EysyonuJBCfRIjeFBFm/npcLa+zGvY8mYlPzh5PLeh81kQ7AvcDjqh1iWOsUf9 l7a6E8iWo7ANmBd+in6BmBaPZgJc3080GFlnhc7ekxJz3Oy+hkmUaHlc4nu6K7Ojxq X1yNnx0Cqh50HPlzfQx+A916JpPbw2RsaUJn7+N4= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from [10.46.160.165] (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: collinsd@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id E7D85601D7; Tue, 22 May 2018 22:46:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527029168; bh=yxzgHog9mv1G7LCdZaX6LU/WW6Vzem/3txU7M6sJFQU=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=KUt/uRLv5v7WkugVblm4R2LtfD2gJsTF5mC78ZfgEMllx+pdc3IzgSUgX5Vm6etoo ht7bdk/nUmI2z08uKH5Zb7+20DK3OJBXZx+Lw8ibXgfv2KBHdjwPEzkX3gk3mK4HRw ONK/y15PspxWTrsYZ5GtSgtcAFBcnCzNBvbUKrNc= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org E7D85601D7 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=collinsd@codeaurora.org Subject: Re: [PATCH v3 1/2] regulator: dt-bindings: add QCOM RPMh regulator bindings To: Doug Anderson Cc: Mark Brown , Liam Girdwood , Rob Herring , Mark Rutland , linux-arm-msm@vger.kernel.org, Linux ARM , devicetree@vger.kernel.org, LKML , Rajendra Nayak , Stephen Boyd References: <41d5df73ddac772551d2966e0752bb0c357b1ded.1526088081.git.collinsd@codeaurora.org> <869aad59-1cc5-28ef-1fb5-4ef846696c40@codeaurora.org> From: David Collins Message-ID: Date: Tue, 22 May 2018 15:46:07 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/22/2018 09:43 AM, 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. I wasn't proposing the voltage caching feature to be used in the upstream qcom-rpmh-regulator. I was explaining exactly how the downstream rpmh-regulator driver works. However, if the voltage caching feature is acceptable for upstream usage, then I could add it. With that in place, I see less of a need for the qcom,regulator-initial-microvolt property and would be ok with removing it for now. >>> BTW: have I already said how terrible of a design it is that you can't >>> read back the voltages that the BIOS set? If we could just read back >>> what the BIOS set then everything would work great and we could stop >>> talking about this. >> >> Even if such reading were feasible, it would not help the situation >> substantially. Very few requests are made via the AP RSC before Linux >> kernel boot, so 0 V values would still be read back for most regulators. > > Sure, but all the regulators we're talking about are ones where this > would help. Said another way: are there any rails that are not > touched by the bootloader where it's bad to set the minimum voltage? I'm not sure about this. > 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. > > > ...taking the SD card case as an example: if the regulator framework > says "set to the minimum: 1.8V" we'll cache this but not apply it yet > because the rail is off as far as Linux is concerned. Then when the > SD card framework starts up it will set the voltage to 3.3V which will > overwrite the cache. Then the SD card framework will enable the > regulator and RPMh will set the voltage to 3.3V and enable. I am ok with implementing this feature. However, should the voltage be cached instead of sent immediately any time that Linux has not explicitly requested the regulator to be enabled, or only before the first time that an enable request is sent? 1. regulator_set_voltage(reg, 2960000, 2960000) --> cache voltage=2960 mV 2. regulator_enable(reg) --> Send voltage=2960 then enable=1 3. regulator_disable(reg) --> Send enable=0 4. regulator_set_voltage(reg, 1800000, 2960000) --> A. Send voltage=1800 OR B. cache voltage=1800? Option A is used on the downstream rpmh-regulator driver in order to avoid cases where AP votes to disable a regulator that is kept enabled by another subsystem but then does not lower the voltage requested thanks to regulator_set_voltage() being called after regulator_disable(). I plan to go with option A for qcom-rpmh-regulator unless there are objections. > This whole thing makes me worry about another problem, though. You > say that the bootloader left the SD card rail on, right? ...but as > far as Linux is concerned the SD card rail is off (argh, it can't read > the state that the bootloader left the rail in!) > > ...now imagine any of the following: > > * The user boots up a kernel where the SD card driver is disabled. > > * The user ejects the SD card right after the bootloader used it but > before the kernel driver started. > > When the kernel comes up it will believe that the SD card rail is > disabled so it won't try to disable it. So the voltage will be left > on. We have not encountered issues with regulators getting left on indefinitely because Linux devices failed to take control of them during boot. I don't think that this hypothetical issue needs to be addressed in the first qcom-rpmh-regulator driver patch if at all. > 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. Step A) would not work because the regulator's use_count would be 0 and regulator_disable() can only be called successfully if use_count > 0. The call would have no impact and it would return an error. I don't think that this is an avenue that we want to pursue. Consumers should not be expected to call regulator_disable() before regulator_enable(). > Do we need to have ".is_enabled" return -ENOTRECOVERABLE to help the > regulator framework understand that we don't know the state? I think > 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'm not following what the regulator framework would do as a result of is_enabled() returning -ENOTRECOVERABLE. If it saw this while processing a regulator_enable() call then it would continue to enable the regulator. This value could not be seen while handling a regulator_disable() call since the is_enabled() callback is not invoked in the disable call-path. This also seems like an optimization for a problem that we are not encountering now (or likely to ever encounter). Therefore, I would suggest that we not try to work this into the initial qcom-rpmh-regulator patch. Thanks, David -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project