Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754133AbcDYJ02 (ORCPT ); Mon, 25 Apr 2016 05:26:28 -0400 Received: from mx0b-001ae601.pphosted.com ([67.231.152.168]:51547 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753843AbcDYJ00 (ORCPT ); Mon, 25 Apr 2016 05:26:26 -0400 Authentication-Results: ppops.net; spf=none smtp.mail=rf@opensource.wolfsonmicro.com Message-ID: <571DE2BB.9000903@opensource.wolfsonmicro.com> Date: Mon, 25 Apr 2016 10:26:19 +0100 From: Richard Fitzgerald User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.8.0 MIME-Version: 1.0 To: Mark Brown CC: , , Subject: Re: [PATCH] regulator: arizona-ldo1: Only enable status change if we have LDOENA References: <1461332608-14760-1-git-send-email-rf@opensource.wolfsonmicro.com> <20160422150446.GF3217@sirena.org.uk> <571A536A.9000509@opensource.wolfsonmicro.com> <20160424232305.GK3217@sirena.org.uk> In-Reply-To: <20160424232305.GK3217@sirena.org.uk> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1603290000 definitions=main-1604250153 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3916 Lines: 66 On 25/04/16 00:23, Mark Brown wrote: > On Fri, Apr 22, 2016 at 05:38:02PM +0100, Richard Fitzgerald wrote: > > Please fix your mailer to leave blank lines between paragraphs (and not > delete them in quotes), it makes your mails harder to read. > >> On 22/04/16 16:04, Mark Brown wrote: >>> On Fri, Apr 22, 2016 at 02:43:28PM +0100, Richard Fitzgerald wrote: >>> What's the difference between this and the previous version of the patch >>> and what problem is this aiming to solve? If we want to disable the >>> regulator why would we not be happy to do that by removing the supply? >> The background to all this is that runtime suspend and resume needs to know >> whether the DCVDD turned off. If it definitely turned off a regmap cache >> sync is safe - if not or I can't be sure then I need the overhead of a >> forced reset to restore register defaults before the sync. > This is what regulator status change notifiers are for, register and > then you'll get a callback when the power is actually pulled (there's a > few other CODEC drivers that use them). > Maybe what they were supposed to be for but the _DISABLE notifier doesn't appear to do this. It seems to get sent if regulator_disable() was called, regardless of whether that regulator was disabled, and not sent if a parent supply was turned off. >> What I'm trying to achieve here is to stop the regulator core sending false >> notifications that LDO1 has been turned off. The way that the regulator core > If you've found a problem with spurious notifications then fix the > spurious notifications, don't pile bodges into consumer drivers! Every > single other driver that relies on these notifications is going to want > the same hack for the same reason though most of them aren't their own > supply so won't be able to do it. The advantage of being able to change > the source code for the entire kernel is that we don't need to have > workarounds for the core in drivers, we can make the core do the right > thing. It didn't look to me like a problem with spurious notifications, it looked like the LDO1 regulator not reporting its capabilities correctly (leading to the core thinking it can turn it off when it can't). But now I've looked several times at the regulator core I see that REGULATOR_CHANGE_STATUS means the same as always_on ("must not turn off"), rather than as ambiguously documented "can turn off". Given my misunderstanding my patch was ok no a bodge, but as the flag doesn't do what I thought the patch is definitely wrong. >> code handles the disable notifier has no dependency on what happens to the >> parent supply. The REGULATOR_CHANGE_STATUS flag is used to indicate whether >> the status of _this_ regulator can be changed (it doesn't affect whether the >> parent is disabled). > If the child can't change status then the disable can't propagate up the > tree and the child regulator needs to hold the parent enabled. > >> I think it's a bug that LDO1 claimed to be able to turn off when it couldn't, >> and fixing that prevents bogus disable notifications. > How does the driver know it couldn't turn off the parent, it knows > nothing about the supply for LDO1? If that's switchable you've just > removed the ability to switch it off since the rail will now never power > down. > > Regulators with no enable control of their own need to not do their own > notifications but instead get notifications based on parent status > changes. It seems the real problem is an assumption that REGULATOR_EVENT_DISABLE means the supply was actually turned off. It's unclear from the description in the header ("Regulator was disabled.") what the intention of this notification was. The existing users of this call all seem to think it means actually turned off, so they all have a problem in the case where the supply was actually pulled by disabling a parent supply (which doesn't currently send a notifier).