Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2286846imm; Thu, 27 Sep 2018 10:15:38 -0700 (PDT) X-Google-Smtp-Source: ACcGV60laAgAx9jhdlthhAHS+CMNn70zXzp0+Ypnla4ZaelVYDiQjK8HHZUPwlv9cBuwDuFA3G9r X-Received: by 2002:a63:fe49:: with SMTP id x9-v6mr11245909pgj.152.1538068538869; Thu, 27 Sep 2018 10:15:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538068538; cv=none; d=google.com; s=arc-20160816; b=KlPooltiz2HGwX3AX0ibRC7PoL5kuNMYDI+Llb8vQKE/LgujD11FipiailUaAOpdwn ZXydqR9nW1HVQ5+jdshS761vLFyKiFuvo+8uH7G1woV89KH6S2wpUXNFN1ZhkvDy0gwB sqIx0KNiXfpkJ/i85SBfyOX8vXAiNN2jqv1/SUGRZAKczsrvnZqWZBGSp7JiOceg7xWF g4P+M7JTlw/ZPS/9+zQZ0q3SafbPwADzIZGnOH69NyvDHrcJ515oQ3WvRfIQetKYeBi/ WJxffLNVy8xK2ULIOCXAnFQTPx4BCdin/3wh2t1sAoaMeeBmo/E6TiSUQnkF9D73HnWI CssQ== 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:references:cc:to:subject:from:dkim-signature; bh=IjMA6Cfpm1WUZXSZ/ybhtDKPc5p55N50Lsw4VjOuF7E=; b=fNrwCpiKlU1+Obrz03E8Ei6ylj1fNG8dXfcg6pYkr+htNPvyBPEeb53pDVAswiG+k0 mHCw5O/l2U54PlukUXbaP6ynFsqjApmI9Za07SYB0wZswJZQeXnyxal0nbiyhCR0lLeE 2m+zCsxUJKbkz6ngHDAQnN1oZdXtFW/Ck9dfVshDjWjT0uYTpA+AeGdNt1JXarRK5Grl WTBRIX3Iuyd13ZCpdjXIvJYkZju/D+PrTzCcwwaocS6FWfrk5F245R2XOgDjf3GJwALn mrgtm9MPwMHfTy6P54+QD3KO4C8fs3vjDWSmRY1PW+smv94yDj6rPYtG1zWYeA4ZN2Qb SYzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=N++5gZrQ; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m24-v6si2564330pfk.56.2018.09.27.10.15.22; Thu, 27 Sep 2018 10:15:38 -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=@gmail.com header.s=20161025 header.b=N++5gZrQ; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728412AbeI0Xe1 (ORCPT + 99 others); Thu, 27 Sep 2018 19:34:27 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:37514 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727588AbeI0Xe1 (ORCPT ); Thu, 27 Sep 2018 19:34:27 -0400 Received: by mail-pf1-f196.google.com with SMTP id x26-v6so2368831pfn.4; Thu, 27 Sep 2018 10:15:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=IjMA6Cfpm1WUZXSZ/ybhtDKPc5p55N50Lsw4VjOuF7E=; b=N++5gZrQbZPk/QNsOYjwkhHs9TgJIaXqHqBZeuFS03GLFp/Jy5zF23lZhXhoMgSYXd AxC9cQWtFmGKuiTI59UeouM5fUzHwKSq90BO6Y2ZABsO9PNToDt9P+xgIkBpzt4idkrn iQ8KgeZqY10hpGxyD1Hx6pDliftSGD5ysbAvLf7olSaWdPNPDvqYpg4Yd5n7+FMWus4M /SIMEaNzpAcESGoEFVXoRBI2Tw510DhCmBcdkI1/eqHpamj3AwvdmG60UpIvmoDqW+fP 1bSKDf8fmIOcoegnpIQXhG26KIgm1VNK/JHC5T26jUy+swAxlAK16vj5s5LP7Z5BQpOR 9pfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=IjMA6Cfpm1WUZXSZ/ybhtDKPc5p55N50Lsw4VjOuF7E=; b=RYEkMwZUdlimBtbpTktB/pLSVRqoUctpzI6mgJuOKHITWNaEHBKzsFogDEaP7RjzwY S/ojEl+geYLsjPydzktg3LIgD4N6tvAw5RoRA/Jyt8KWz8WVe4xsT0x3opMcwnYXTNIL uv9rKNkuYxbdRS263JcYvd0omgt/fSgzqbv9YgTIbaxTg97SmHJSPhtNv8X7pcVvEc3x MNSwTOvFwfaYzFFI4Ozm5qt4abn3wO276r5xDuVhSAbIpydDHPOglbz6rKnLyiRqCL+L r9DGOPc4yrvfsgG1fx3ErAqzaVwSwBw+qwQz/Z3tIV2iq1U/LJnXqN5HPDKdURV5KRHG qY3Q== X-Gm-Message-State: ABuFfoi8o7Ed2gM9Cir7eM6d4YfyurNVIMZ8lJ1Z6MXQkNPbSsWtYEpE FhXOmBWm9wSyCvvlrcCnwXwGgIEz X-Received: by 2002:a63:f5a:: with SMTP id 26-v6mr2792530pgp.100.1538068510764; Thu, 27 Sep 2018 10:15:10 -0700 (PDT) Received: from [192.168.2.145] (109-252-91-213.nat.spd-mgts.ru. [109.252.91.213]) by smtp.googlemail.com with ESMTPSA id m124-v6sm3445682pfm.164.2018.09.27.10.15.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Sep 2018 10:15:10 -0700 (PDT) From: Dmitry Osipenko Subject: Re: [PATCH v7 0/6] Add coupled regulators mechanism To: Maciej Purski , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Mark Brown Cc: Fabio Estevam , Tony Lindgren , Liam Girdwood , Rob Herring , Mark Rutland , Marek Szyprowski , Doug Anderson , Bartlomiej Zolnierkiewicz , "linux-tegra@vger.kernel.org" References: <1524494022-22260-1-git-send-email-m.purski@samsung.com> Message-ID: Date: Thu, 27 Sep 2018 20:14:59 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <1524494022-22260-1-git-send-email-m.purski@samsung.com> 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 4/23/18 5:33 PM, Maciej Purski wrote: > Hi all, > > this patchset adds a new mechanism to the framework - regulators' coupling. > > On Odroid XU3/4 and other Exynos5422 based boards there is a case, that > different devices on the board are supplied by different regulators > with non-fixed voltages. If one of these devices temporarily requires > higher voltage, there might occur a situation that the spread between > devices' voltages is so high, that there is a risk of changing > 'high' and 'low' states on the interconnection between devices powered > by those regulators. > > Algorithmicaly the problem was solved by: > Inderpal Singh > Doug Anderson > > The discussion on that subject can be found here: > https://lkml.org/lkml/2014/4/29/28 > > Therefore this patchset is an attempt to apply the idea to regulators core > as concluded in the discussion by Mark Brown and Doug Anderson. > > This feature is required to enable support for generic CPUfreq > and devfreq drivers for the mentioned boards. > > The current assumption is that an uncoupled regulator is a special case > of a coupled one, so they should share a common voltage setting path. Hello Maciej, I'm working on the CPUFreq driver for NVIDIA Tegra20/30 and now looking at adding support for DVFS to the driver. The "coupled regulators mechanism" is just what is needed for Tegra. I'm now using and relying on the "coupled regulators" patches, here are my findings and thoughts on the patchset: 1. There is a technical problem with resolving of coupled regulators. I'm running into a NULL dereference on a regulator_set_voltage() because one of two coupled regulators doesn't resolve the couple. Solution is to return EPROBE_DEFER on regulator requesting until the coupled pair is fully resolved and re-try the resolving for each of regulators after the regulators registration. Here is the patch: diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 282511508698..baa8ef91bc30 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1747,6 +1747,12 @@ struct regulator *_regulator_get(struct device *dev, const char *id, return regulator; } + if (rdev->coupling_desc.n_resolved != rdev->coupling_desc.n_coupled) { + regulator = ERR_PTR(-EPROBE_DEFER); + put_device(&rdev->dev); + return regulator; + } + ret = regulator_resolve_supply(rdev); if (ret < 0) { regulator = ERR_PTR(ret); @@ -4433,6 +4439,9 @@ static int regulator_register_fill_coupling_array(struct device *dev, if (!IS_ENABLED(CONFIG_OF)) return 0; + if (rdev == data) + return 0; + if (regulator_fill_coupling_array(rdev)) rdev_dbg(rdev, "unable to resolve coupling\n"); @@ -4663,6 +4672,11 @@ regulator_register(const struct regulator_desc *regulator_desc, /* try to resolve regulators supply since a new one was registered */ class_for_each_device(®ulator_class, NULL, NULL, regulator_register_resolve_supply); + + /* try to resolve regulators coupling since a new one was registered */ + class_for_each_device(®ulator_class, NULL, rdev, + regulator_register_fill_coupling_array); + kfree(config); return rdev; 2. It looks to me that definition of the max-spread property per groups of regulators isn't future-proof and makes it uneasy to extend the coupling properties later. Much better should be to define the max-spread property per regulators pair, like in this example: regA: regulatorA { regulator-coupled-with = <®B ®C>; regulator-coupled-max-spread = <100000 200000; }; regB: regulatorB { regulator-coupled-with = <®A ®C>; regulator-coupled-max-spread = <100000 300000>; }; regC: regulatorC { regulator-coupled-with = <®A ®B>; regulator-coupled-max-spread = <200000 300000>; }; Right now we can just change the binding, requiring max-spread values to be set per-pair and not allowing spread values to differ in the code, hence only simple cases of coupling will be supported for the starter. 3. The patches were reverted in upstream because they caused regression on some board, at least on Tegra I haven't noticed any problems with the locking. Are you planing to get back to working on the patches anytime soon?