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@xxxxxxxxxxxx> --- 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