All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Boyd <swboyd@chromium.org>
To: linux-kernel@vger.kernel.org
Cc: Rajendra Nayak <rnayak@codeaurora.org>,
	linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-serial@vger.kernel.org, linux-spi@vger.kernel.org,
	Ulf Hansson <ulf.hansson@linaro.org>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	Doug Anderson <dianders@chromium.org>
Subject: [RFC/PATCH 2/5] OPP: Make dev_pm_opp_set_rate() with freq=0 as valid
Date: Mon, 28 Jan 2019 17:55:44 -0800	[thread overview]
Message-ID: <20190129015547.213276-3-swboyd@chromium.org> (raw)
In-Reply-To: <20190129015547.213276-1-swboyd@chromium.org>

From: Rajendra Nayak <rnayak@codeaurora.org>

For devices with performance state, we use dev_pm_opp_set_rate()
to set the appropriate clk rate and the performance state.
We do need a way to *remove* the performance state vote when
we idle the device and turn the clocks off. Use dev_pm_opp_set_rate()
with freq=0 to achieve this.

Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
---
 drivers/opp/core.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/opp/core.c b/drivers/opp/core.c
index b6516d623c5a..ac5099c237de 100644
--- a/drivers/opp/core.c
+++ b/drivers/opp/core.c
@@ -709,18 +709,24 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
 	struct clk *clk;
 	int ret;
 
-	if (unlikely(!target_freq)) {
-		dev_err(dev, "%s: Invalid target frequency %lu\n", __func__,
-			target_freq);
-		return -EINVAL;
-	}
-
 	opp_table = _find_opp_table(dev);
 	if (IS_ERR(opp_table)) {
 		dev_err(dev, "%s: device opp doesn't exist\n", __func__);
 		return PTR_ERR(opp_table);
 	}
 
+	if (unlikely(!target_freq)) {
+		if (opp_table->required_opp_tables) {
+			/* drop the performance state vote */
+			dev_pm_genpd_set_performance_state(dev, 0);
+			return 0;
+		} else {
+			dev_err(dev, "%s: Invalid target frequency %lu\n", __func__,
+				target_freq);
+			return -EINVAL;
+		}
+	}
+
 	clk = opp_table->clk;
 	if (IS_ERR(clk)) {
 		dev_err(dev, "%s: No clock available for the device\n",
-- 
Sent by a computer through tubes

  parent reply	other threads:[~2019-01-29  1:55 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-29  1:55 [RFC/PATCH 0/5] DVFS in the OPP core Stephen Boyd
2019-01-29  1:55 ` [RFC/PATCH 1/5] OPP: Don't overwrite rounded clk rate Stephen Boyd
2019-01-29  1:55 ` Stephen Boyd [this message]
2019-01-29  1:55 ` [RFC/PATCH 3/5] tty: serial: qcom_geni_serial: Use OPP API to set clk/perf state Stephen Boyd
2019-01-29  1:55 ` [RFC/PATCH 4/5] spi: spi-geni-qcom: " Stephen Boyd
2019-01-29  1:55 ` [RFC/PATCH 5/5] arm64: dts: sdm845: Add OPP table for all qup devices Stephen Boyd
2019-01-31  9:23 ` [RFC/PATCH 0/5] DVFS in the OPP core Viresh Kumar
2019-01-31  9:58   ` Rafael J. Wysocki
2019-01-31 10:06     ` Viresh Kumar
2019-01-31 10:36       ` Rafael J. Wysocki
2019-01-31 10:41         ` Viresh Kumar
2019-02-07  7:58   ` Stephen Boyd
2019-02-07 13:37     ` Ulf Hansson
2019-02-08  7:17       ` Viresh Kumar
2019-02-08  9:45         ` Ulf Hansson
2019-02-08 10:05           ` Viresh Kumar
2019-02-08 10:31             ` Ulf Hansson
2019-02-08 10:33               ` Viresh Kumar
2019-02-08  7:14     ` Viresh Kumar
2019-02-07  6:57 ` Rajendra Nayak
2019-02-07 19:47   ` Stephen Boyd
2019-02-08  4:39     ` Rajendra Nayak

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=20190129015547.213276-3-swboyd@chromium.org \
    --to=swboyd@chromium.org \
    --cc=dianders@chromium.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=rnayak@codeaurora.org \
    --cc=ulf.hansson@linaro.org \
    --cc=viresh.kumar@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.