From patchwork Tue Aug 14 17:06:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 10565903 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A3416157B for ; Tue, 14 Aug 2018 17:07:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 896EE2A4C4 for ; Tue, 14 Aug 2018 17:07:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7DA2C2A4C3; Tue, 14 Aug 2018 17:07:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1EEA82A4C3 for ; Tue, 14 Aug 2018 17:07:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387605AbeHNTyz (ORCPT ); Tue, 14 Aug 2018 15:54:55 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:34176 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733141AbeHNTyx (ORCPT ); Tue, 14 Aug 2018 15:54:53 -0400 Received: by mail-pg1-f195.google.com with SMTP id y5-v6so9388788pgv.1 for ; Tue, 14 Aug 2018 10:06:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tB73vw/ScZXdbL/f9MHIOWSOWp2ygs06ypWa1EFsTMk=; b=Z1jMPBFIXp+ppeVk+QMOLJIo9j+BUWBkaiibpPH4MYpO8wLc9TJ8LvS3qthY9TXYOx KAAL8FfKPK3Dnt499CByBtdfdGXWmqGMG6cxhEEma5zfWcenfEF+yinwkn06ZZtcIAbl qEckzQo2D57hCcRxjtWaKYhBZO72OD6sSaR8M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tB73vw/ScZXdbL/f9MHIOWSOWp2ygs06ypWa1EFsTMk=; b=iv8ZEcgyCR7H7eAxLD5MMs1cckBIbElvB8o6oz19O5GJTWmAQGn/S3SSgFNyMiHJpY ATeowQBGa3GgWvIGU3Af96/JT1XFDqW5OjzJxJ3AUMZ02j9RnX+LQRsol8GQigTOEtOQ e3MhweJ9/1EG7EHTplGRZxnU7JxAVn6gEjqyTAGJAsihGzM/3ftj+2E6IBUmfb5CHHI7 QVv6FoeJ/lVBaHKLP1R7SkQXWnU5wHTpnNzFWqd+yoAsvKOCQfUfuUCXUYnQy9BcnBJP GJ72SJXME/HlXZuVN8HAzM0wJdknOe7NuOicXy3vp5co1xy6jMVHo2KF/m6z1DTKqhJF ruKg== X-Gm-Message-State: AOUpUlGPXz0K44cJK6r1L5kSXjd4poVJlo4HTWVvB9sNGR3cRpuSZbUc +8rRw7STSiHjnSTUHC8bGU88yQ== X-Google-Smtp-Source: AA+uWPx1YHGj3Dm7CpSTZx0YPe9jR5Z8CGVmY8wiuWyfhn/0Rdf2/Hax7hc0z6l2CZkANbSRipuaVw== X-Received: by 2002:a65:5c83:: with SMTP id a3-v6mr21965781pgt.164.1534266413860; Tue, 14 Aug 2018 10:06:53 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:c8e0:70d7:4be7:a36]) by smtp.gmail.com with ESMTPSA id d19-v6sm67940763pfe.42.2018.08.14.10.06.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Aug 2018 10:06:53 -0700 (PDT) From: Douglas Anderson To: broonie@kernel.org Cc: linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, collinsd@codeaurora.org, swboyd@chromium.org, Douglas Anderson , Liam Girdwood , 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 Message-Id: <20180814170617.100087-2-dianders@chromium.org> X-Mailer: git-send-email 2.18.0.865.gffc8e1a3cd6-goog In-Reply-To: <20180814170617.100087-1-dianders@chromium.org> References: <20180814170617.100087-1-dianders@chromium.org> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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;