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; From patchwork Tue Aug 14 17:06:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 10565897 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 8F3131057 for ; Tue, 14 Aug 2018 17:06:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7675F2A478 for ; Tue, 14 Aug 2018 17:06:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A74B2A4C4; Tue, 14 Aug 2018 17:06:58 +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 104802A478 for ; Tue, 14 Aug 2018 17:06:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387624AbeHNTy4 (ORCPT ); Tue, 14 Aug 2018 15:54:56 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:44309 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387621AbeHNTy4 (ORCPT ); Tue, 14 Aug 2018 15:54:56 -0400 Received: by mail-pl0-f66.google.com with SMTP id ba4-v6so8557652plb.11 for ; Tue, 14 Aug 2018 10:06:55 -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=0IryqUHHn803R0vItVfBlrN0avv0GNYFsdGQ+ij7oqE=; b=ZeNjSzz5HLbhfuNJQcituRS361qr5a2daqWMHzECXaRpDGJcRXC60eouLteyl9fz4V KWPpR40choIe2dSpDgi+pQ+Hxxxv1VoKbzOjNGFZRXZRmrd8GeMbkZI83V7w28imhiHp dtyeDugjHMhp3RT3mq1Olmymyaq5bVW7WHKWw= 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=0IryqUHHn803R0vItVfBlrN0avv0GNYFsdGQ+ij7oqE=; b=oy2JCMzPcu8OZwZl186h30OYp8DYYcc0iXvfq0xCReMtYGGjVWb7Tr/pMVlKaN1XVu mH6+4wxtFu8NKn9l5mxdlwws3J/nehGtc1w9WA/Obx/SL0xsHBKVfDIF8STw4rKVrdG9 Gt9RkvYdz6EVuFrmwr9yAlAocgVUKUl5kqMQDstwKgChEL45z/oR9mt3VwoaZ386DkUk WDb7N5QgmqfsG0wC3w5aH5I+legxcNqdRGJ0InEgSaamPHLY2jK3KNNP7/wZio1oup4E w7vYpBxJTa0b5Iaocuuobh9NDqaVGsYVAop9+qxtTQI63EDxiL3A/d32BVuwFzjN3eyz QDyg== X-Gm-Message-State: AOUpUlGGUdxKyne2zw98kEuMbNC5SyKXNxPgH1m8j5cVO7l4bpmDNSQC SmjoPAqfTT8Az/8jH78UjG11h04/rAc= X-Google-Smtp-Source: AA+uWPyQrwjmOQuqmBW8AnCV+/Mz0X0CtsBBURdzMZmqqFH5AB+24KWSqB98yK8eGYfQzr3lqMH75A== X-Received: by 2002:a17:902:622:: with SMTP id 31-v6mr21189586plg.153.1534266415190; Tue, 14 Aug 2018 10:06:55 -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.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Aug 2018 10:06:54 -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 2/4] regulator: core: Add the opmode to regulator_summary Date: Tue, 14 Aug 2018 10:06:15 -0700 Message-Id: <20180814170617.100087-3-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 It's handy to know what opmode a regulator has been configured to in the summary. Add it. Signed-off-by: Douglas Anderson --- drivers/regulator/core.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index a4da68775b49..b8b8048efbdd 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -426,19 +426,24 @@ static ssize_t name_show(struct device *dev, struct device_attribute *attr, } static DEVICE_ATTR_RO(name); -static ssize_t regulator_print_opmode(char *buf, int mode) +static const char *regulator_opmode_to_str(int mode) { switch (mode) { case REGULATOR_MODE_FAST: - return sprintf(buf, "fast\n"); + return "fast"; case REGULATOR_MODE_NORMAL: - return sprintf(buf, "normal\n"); + return "normal"; case REGULATOR_MODE_IDLE: - return sprintf(buf, "idle\n"); + return "idle"; case REGULATOR_MODE_STANDBY: - return sprintf(buf, "standby\n"); + return "standby"; } - return sprintf(buf, "unknown\n"); + return "unknown"; +} + +static ssize_t regulator_print_opmode(char *buf, int mode) +{ + return sprintf(buf, "%s\n", regulator_opmode_to_str(mode)); } static ssize_t regulator_opmode_show(struct device *dev, @@ -4668,10 +4673,11 @@ static void regulator_summary_show_subtree(struct seq_file *s, if (!rdev) return; - seq_printf(s, "%*s%-*s %3d %4d %6d ", + seq_printf(s, "%*s%-*s %3d %4d %6d %7s ", level * 3 + 1, "", 30 - level * 3, rdev_get_name(rdev), - rdev->use_count, rdev->open_count, rdev->bypass_count); + rdev->use_count, rdev->open_count, rdev->bypass_count, + regulator_opmode_to_str(_regulator_get_mode(rdev))); seq_printf(s, "%5dmV ", _regulator_get_voltage(rdev) / 1000); seq_printf(s, "%5dmA ", _regulator_get_current_limit(rdev) / 1000); @@ -4703,7 +4709,7 @@ static void regulator_summary_show_subtree(struct seq_file *s, switch (rdev->desc->type) { case REGULATOR_VOLTAGE: - seq_printf(s, "%37dmV %5dmV", + seq_printf(s, "%45dmV %5dmV", consumer->voltage[PM_SUSPEND_ON].min_uV / 1000, consumer->voltage[PM_SUSPEND_ON].max_uV / 1000); break; @@ -4735,8 +4741,8 @@ static int regulator_summary_show_roots(struct device *dev, void *data) static int regulator_summary_show(struct seq_file *s, void *data) { - seq_puts(s, " regulator use open bypass voltage current min max\n"); - seq_puts(s, "-------------------------------------------------------------------------------\n"); + seq_puts(s, " regulator use open bypass opmode voltage current min max\n"); + seq_puts(s, "---------------------------------------------------------------------------------------\n"); class_for_each_device(®ulator_class, NULL, s, regulator_summary_show_roots); From patchwork Tue Aug 14 17:06:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 10565901 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 CE9D0157B for ; Tue, 14 Aug 2018 17:07:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B56552A478 for ; Tue, 14 Aug 2018 17:07:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A9ED52A4C4; Tue, 14 Aug 2018 17:07:10 +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 5BBB62A478 for ; Tue, 14 Aug 2018 17:07:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387653AbeHNTy5 (ORCPT ); Tue, 14 Aug 2018 15:54:57 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:37360 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387652AbeHNTy4 (ORCPT ); Tue, 14 Aug 2018 15:54:56 -0400 Received: by mail-pl0-f68.google.com with SMTP id d5-v6so8570641pll.4 for ; Tue, 14 Aug 2018 10:06:56 -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=sGksIB8cizHaKApnUuX97vs90VO3iPXhSR8JaN7x2IY=; b=jVNUuhuLaWAUk3mi7QZkJiZY6h5l7ESWMHbmr57casDI1YZPMFj/AhbQ9IUXs4rAfF z5txz22DhcqC3J/D+h566gKxXRo+kgsz58HycewKR1jwrBWWUEVvyuZm8l7KwHno/75P 5n76nx20yMVukneKSO2SeJAVkXU5f1W9E4M9c= 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=sGksIB8cizHaKApnUuX97vs90VO3iPXhSR8JaN7x2IY=; b=Sp1yguci7KwbmCn+ty/9CqU0pvEPJkP8qRjfoJulAvF0w4T9znz9+s20wBbW9ekWgS iV/LWfcegjOpJEwCgeIPLY2MOQkyy3S10N69ZgGnZE/O6CCTSWLwj6tcM3SCbpyOYPhe I9XmudgCdiFozGWu3A9iTlHbOE5Lhv++wEykJV/eIzyry59nDzKdc2RKwfQE3B8hzT8p bdFW22a39b2Jt1H2+fvlr7rzAImemzRJdBngvtEc1Pz3uPtE2W7ZK620TG75N1SD9bqx A7+7ow/WItOW3cYhJUeSSTgg4mo5SEXu/FX+oCAaPkv916TPyNo1D80nQYNl3xzyY5JM RG2w== X-Gm-Message-State: AOUpUlHmUk7l0fR5ZJ9Qudcs0beYNten1Z21JuINAExfifCLGjJoK2If hrTR99p129E5q5MXDzY2EXXxrQ== X-Google-Smtp-Source: AA+uWPxYNurYc+HnkMKAZMixu8wqvH0Cc03EYWd/cEzk5rSegr6Ch+ARZQ9ph7GiX/qz8SkIpEdo1A== X-Received: by 2002:a17:902:8f8c:: with SMTP id z12-v6mr20890675plo.4.1534266416567; Tue, 14 Aug 2018 10:06:56 -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.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Aug 2018 10:06:55 -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 3/4] regulator: core: Add consumer-requested load in regulator_summary Date: Tue, 14 Aug 2018 10:06:16 -0700 Message-Id: <20180814170617.100087-4-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 It's handy to see the load requested by a regulator consumer in the regulator_summary. Add it. Since this patch comes after the patch ("regulator: core: If consumers don't call regulator_set_load() assume max") we'll also differentiate between the case where a consumer hasn't called regulator_set_load() and the case where a consumer called it but the load is currently 0 mA. Signed-off-by: Douglas Anderson --- drivers/regulator/core.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index b8b8048efbdd..23f64faa6961 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -4709,9 +4709,16 @@ static void regulator_summary_show_subtree(struct seq_file *s, switch (rdev->desc->type) { case REGULATOR_VOLTAGE: - seq_printf(s, "%45dmV %5dmV", - consumer->voltage[PM_SUSPEND_ON].min_uV / 1000, - consumer->voltage[PM_SUSPEND_ON].max_uV / 1000); + if (consumer->uA_load_set) { + seq_printf(s, "%37dmA %5dmV %5dmV", + consumer->uA_load / 1000, + consumer->voltage[PM_SUSPEND_ON].min_uV / 1000, + consumer->voltage[PM_SUSPEND_ON].max_uV / 1000); + } else { + seq_printf(s, "%45dmV %5dmV", + consumer->voltage[PM_SUSPEND_ON].min_uV / 1000, + consumer->voltage[PM_SUSPEND_ON].max_uV / 1000); + } break; case REGULATOR_CURRENT: break; From patchwork Tue Aug 14 17:06:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 10565899 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 07421157B for ; Tue, 14 Aug 2018 17:07:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E12782A478 for ; Tue, 14 Aug 2018 17:07:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D4F502A4C4; Tue, 14 Aug 2018 17:07:06 +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 74E282A478 for ; Tue, 14 Aug 2018 17:07:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387670AbeHNTy6 (ORCPT ); Tue, 14 Aug 2018 15:54:58 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:46321 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387621AbeHNTy6 (ORCPT ); Tue, 14 Aug 2018 15:54:58 -0400 Received: by mail-pl0-f65.google.com with SMTP id t17-v6so8551055ply.13 for ; Tue, 14 Aug 2018 10:06:58 -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=sxQDdG2Di+2iO3ayrNjTUf45BVaOyDbXM7D3wCE/SSA=; b=dAcdROHgkaV2icsrCS6q3rz3ETVNxvPEhT8B2BXyEXqwXWHqgF+HxzsBkY4VrFdnKK YyzJPiLM3sikpfnj1HQ3xIu5030ZZyKAleUvhrRh/bmuLddzO/2/GbpLGHRCEniw/zWx KDbUIpOJTUHcuC5+8jB3ByHS3jwf6j9R5peNg= 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=sxQDdG2Di+2iO3ayrNjTUf45BVaOyDbXM7D3wCE/SSA=; b=rpxaKLMOSt5oGATG54hCWbuaitOwNJ+S33x/o3sZn4zyv/v+3kbhFG1snHlSQZc0gm nNGsG/Ig03caxhgwKhLexJRWufGvpQkSAM8iaVGZoKrazjhrj74wuNFEaJu0sGEsiXja BdcgnvXzEQwtyzzUdLGWQg3Mp8dYL5giWwMnIL8r13NDvN1JwPf8IZnYsfhSTxap/4gB wxu+EEUcPuGhNYknxHeGbEC3uZiiPqArmf8nXlDdiFd+pVspfTedmEXcyGuw5eXl5t7r 67bw8akxJuWqIw3ZW8PVCm4tcBribV24JwB8t2/DzggoRuECBTZe8RXSnt4lGiOOYh+W UlZg== X-Gm-Message-State: AOUpUlEGwyKnFRQZG4AeEEG1mI4nQM37TXOhE1RmSwcE0KlvO1wKSdYg V0025NH4KaSUHaISYo3iv+vaFA== X-Google-Smtp-Source: AA+uWPybS1fQbbjpDp1vc+1JzkIB4Dv6hz1nHBVfT/+NWjrSR3Mk10v1OkytMzxz5njJ0/xLIfGttw== X-Received: by 2002:a17:902:8e86:: with SMTP id bg6-v6mr21097403plb.108.1534266417906; Tue, 14 Aug 2018 10:06:57 -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.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Aug 2018 10:06:57 -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 4/4] regulator: core: Add locking to debugfs regulator_summary Date: Tue, 14 Aug 2018 10:06:17 -0700 Message-Id: <20180814170617.100087-5-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 Most functions that access the rdev lock the rdev mutex before looking at data. ...but not the code that implements the debugfs regulator_summary. It probably should though, so let's do it. Signed-off-by: Douglas Anderson --- drivers/regulator/core.c | 51 ++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 23f64faa6961..5950b44c10d5 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -3468,21 +3468,23 @@ int regulator_set_current_limit(struct regulator *regulator, } EXPORT_SYMBOL_GPL(regulator_set_current_limit); +static int _regulator_get_current_limit_unlocked(struct regulator_dev *rdev) +{ + /* sanity check */ + if (!rdev->desc->ops->get_current_limit) + return -EINVAL; + + return rdev->desc->ops->get_current_limit(rdev); +} + static int _regulator_get_current_limit(struct regulator_dev *rdev) { int ret; regulator_lock(rdev); - - /* sanity check */ - if (!rdev->desc->ops->get_current_limit) { - ret = -EINVAL; - goto out; - } - - ret = rdev->desc->ops->get_current_limit(rdev); -out: + ret = _regulator_get_current_limit_unlocked(rdev); regulator_unlock(rdev); + return ret; } @@ -3547,21 +3549,23 @@ int regulator_set_mode(struct regulator *regulator, unsigned int mode) } EXPORT_SYMBOL_GPL(regulator_set_mode); +static unsigned int _regulator_get_mode_unlocked(struct regulator_dev *rdev) +{ + /* sanity check */ + if (!rdev->desc->ops->get_mode) + return -EINVAL; + + return rdev->desc->ops->get_mode(rdev); +} + static unsigned int _regulator_get_mode(struct regulator_dev *rdev) { int ret; regulator_lock(rdev); - - /* sanity check */ - if (!rdev->desc->ops->get_mode) { - ret = -EINVAL; - goto out; - } - - ret = rdev->desc->ops->get_mode(rdev); -out: + ret = _regulator_get_mode_unlocked(rdev); regulator_unlock(rdev); + return ret; } @@ -4669,18 +4673,23 @@ static void regulator_summary_show_subtree(struct seq_file *s, struct regulation_constraints *c; struct regulator *consumer; struct summary_data summary_data; + unsigned int opmode; if (!rdev) return; + regulator_lock_nested(rdev, level); + + opmode = _regulator_get_mode_unlocked(rdev); seq_printf(s, "%*s%-*s %3d %4d %6d %7s ", level * 3 + 1, "", 30 - level * 3, rdev_get_name(rdev), rdev->use_count, rdev->open_count, rdev->bypass_count, - regulator_opmode_to_str(_regulator_get_mode(rdev))); + regulator_opmode_to_str(opmode)); seq_printf(s, "%5dmV ", _regulator_get_voltage(rdev) / 1000); - seq_printf(s, "%5dmA ", _regulator_get_current_limit(rdev) / 1000); + seq_printf(s, "%5dmA ", + _regulator_get_current_limit_unlocked(rdev) / 1000); c = rdev->constraints; if (c) { @@ -4733,6 +4742,8 @@ static void regulator_summary_show_subtree(struct seq_file *s, class_for_each_device(®ulator_class, NULL, &summary_data, regulator_summary_show_children); + + regulator_unlock(rdev); } static int regulator_summary_show_roots(struct device *dev, void *data)