From: Douglas Anderson <dianders@chromium.org>
To: broonie@kernel.org
Cc: linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org,
collinsd@codeaurora.org, swboyd@chromium.org,
Douglas Anderson <dianders@chromium.org>,
Liam Girdwood <lgirdwood@gmail.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH 1/4] regulator: core: If consumers don't call regulator_set_load() assume max
Date: Tue, 14 Aug 2018 10:06:14 -0700 [thread overview]
Message-ID: <20180814170617.100087-2-dianders@chromium.org> (raw)
In-Reply-To: <20180814170617.100087-1-dianders@chromium.org>
Not all regulator consumers call regulator_set_load(). On some
regulators (like on RPMh-regulator) this could be bad since the
regulator framework will treat this as if consumer needs no load.
It's much better to assume that a dumb client needs the maximum
possible load so we get correctness first.
Signed-off-by: Douglas Anderson <dianders@chromium.org>
---
drivers/regulator/core.c | 10 +++++++++-
drivers/regulator/internal.h | 1 +
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 6ed568b96c0e..a4da68775b49 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -732,6 +732,7 @@ static int drms_uA_update(struct regulator_dev *rdev)
struct regulator *sibling;
int current_uA = 0, output_uV, input_uV, err;
unsigned int mode;
+ bool any_unset = false;
lockdep_assert_held_once(&rdev->mutex);
@@ -751,11 +752,17 @@ static int drms_uA_update(struct regulator_dev *rdev)
return -EINVAL;
/* calc total requested load */
- list_for_each_entry(sibling, &rdev->consumer_list, list)
+ list_for_each_entry(sibling, &rdev->consumer_list, list) {
current_uA += sibling->uA_load;
+ if (!sibling->uA_load_set)
+ any_unset = true;
+ }
current_uA += rdev->constraints->system_load;
+ if (any_unset)
+ current_uA = INT_MAX;
+
if (rdev->desc->ops->set_load) {
/* set the optimum mode for our new total regulator load */
err = rdev->desc->ops->set_load(rdev, current_uA);
@@ -3631,6 +3638,7 @@ int regulator_set_load(struct regulator *regulator, int uA_load)
regulator_lock(rdev);
regulator->uA_load = uA_load;
+ regulator->uA_load_set = true;
ret = drms_uA_update(rdev);
regulator_unlock(rdev);
diff --git a/drivers/regulator/internal.h b/drivers/regulator/internal.h
index 943926a156f2..f05c75c59ef4 100644
--- a/drivers/regulator/internal.h
+++ b/drivers/regulator/internal.h
@@ -41,6 +41,7 @@ struct regulator {
struct list_head list;
unsigned int always_on:1;
unsigned int bypass:1;
+ bool uA_load_set;
int uA_load;
struct regulator_voltage voltage[REGULATOR_STATES_NUM];
const char *supply_name;
--
2.18.0.865.gffc8e1a3cd6-goog
next prev parent reply other threads:[~2018-08-14 17:07 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-14 17:06 [PATCH 0/4] regulator: core: A few useful patches for regulators that need load set Douglas Anderson
2018-08-14 17:06 ` Douglas Anderson [this message]
2018-08-14 18:30 ` [PATCH 1/4] regulator: core: If consumers don't call regulator_set_load() assume max David Collins
2018-08-14 20:03 ` Doug Anderson
2018-08-14 21:59 ` David Collins
2018-08-14 23:56 ` Doug Anderson
2018-08-15 1:32 ` David Collins
2018-08-15 11:13 ` Mark Brown
2018-08-16 20:07 ` Doug Anderson
2018-08-16 20:58 ` David Collins
2018-08-16 21:03 ` Doug Anderson
2018-08-15 11:06 ` Mark Brown
2018-08-15 10:57 ` Mark Brown
2018-08-17 21:36 ` Bjorn Andersson
2018-08-20 17:18 ` Mark Brown
2018-08-14 17:06 ` [PATCH 2/4] regulator: core: Add the opmode to regulator_summary Douglas Anderson
2018-08-14 17:06 ` [PATCH 3/4] regulator: core: Add consumer-requested load in regulator_summary Douglas Anderson
2018-08-14 17:06 ` [PATCH 4/4] regulator: core: Add locking to debugfs regulator_summary Douglas Anderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180814170617.100087-2-dianders@chromium.org \
--to=dianders@chromium.org \
--cc=bjorn.andersson@linaro.org \
--cc=broonie@kernel.org \
--cc=collinsd@codeaurora.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=swboyd@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).