LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Ulf Hansson <ulf.hansson@linaro.org>
To: "Rafael J . Wysocki" <rjw@rjwysocki.net>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	Dmitry Osipenko <digetx@gmail.com>,
	linux-pm@vger.kernel.org
Cc: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Thierry Reding <thierry.reding@gmail.com>,
	Rajendra Nayak <rnayak@codeaurora.org>,
	Stephan Gerhold <stephan@gerhold.net>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	Ulf Hansson <ulf.hansson@linaro.org>
Subject: [PATCH 1/3] PM: domains: Drop the performance state vote for a device at detach
Date: Thu,  2 Sep 2021 12:16:32 +0200	[thread overview]
Message-ID: <20210902101634.827187-2-ulf.hansson@linaro.org> (raw)
In-Reply-To: <20210902101634.827187-1-ulf.hansson@linaro.org>

When a device is detached from its genpd, genpd loses track of the device,
including its performance state vote that may have been requested for it.

Rather than relying on the consumer driver to drop the performance state
vote for its device, let's do it internally in genpd when the device is
getting detached. In this way, we makes sure that the aggregation of the
votes in genpd becomes correct.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/base/power/domain.c | 9 ++-------
 include/linux/pm_domain.h   | 1 -
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 5db704f02e71..278e040f607f 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -1665,6 +1665,8 @@ static int genpd_remove_device(struct generic_pm_domain *genpd,
 		goto out;
 	}
 
+	genpd_set_performance_state(dev, 0);
+
 	genpd->device_count--;
 	genpd->max_off_time_changed = true;
 
@@ -2604,12 +2606,6 @@ static void genpd_dev_pm_detach(struct device *dev, bool power_off)
 
 	dev_dbg(dev, "removing from PM domain %s\n", pd->name);
 
-	/* Drop the default performance state */
-	if (dev_gpd_data(dev)->default_pstate) {
-		dev_pm_genpd_set_performance_state(dev, 0);
-		dev_gpd_data(dev)->default_pstate = 0;
-	}
-
 	for (i = 1; i < GENPD_RETRY_MAX_MS; i <<= 1) {
 		ret = genpd_remove_device(pd, dev);
 		if (ret != -EAGAIN)
@@ -2702,7 +2698,6 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev,
 		ret = dev_pm_genpd_set_performance_state(dev, pstate);
 		if (ret)
 			goto err;
-		dev_gpd_data(dev)->default_pstate = pstate;
 	}
 	return 1;
 
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index 67017c9390c8..21a0577305ef 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -198,7 +198,6 @@ struct generic_pm_domain_data {
 	struct notifier_block *power_nb;
 	int cpu;
 	unsigned int performance_state;
-	unsigned int default_pstate;
 	unsigned int rpm_pstate;
 	ktime_t	next_wakeup;
 	void *data;
-- 
2.25.1


  reply	other threads:[~2021-09-02 10:16 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-02 10:16 [PATCH 0/3] PM: domains: Improvements for performance states in genpd Ulf Hansson
2021-09-02 10:16 ` Ulf Hansson [this message]
2021-09-03  6:01   ` [PATCH 1/3] PM: domains: Drop the performance state vote for a device at detach Dmitry Osipenko
2021-09-03  8:22     ` Ulf Hansson
2021-09-03  9:58       ` Dmitry Osipenko
2021-09-03 14:03         ` Ulf Hansson
2021-09-05  8:26           ` Dmitry Osipenko
2021-09-06 10:24             ` Ulf Hansson
2021-09-06 14:11               ` Dmitry Osipenko
2021-09-06 17:34                 ` Ulf Hansson
2021-09-06 19:33                   ` Dmitry Osipenko
2021-09-07 10:16                     ` Ulf Hansson
2021-09-09 13:48                       ` Dmitry Osipenko
2021-09-09 14:45                         ` Ulf Hansson
2021-09-02 10:16 ` [PATCH 2/3] PM: domains: Restructure some code in __genpd_dev_pm_attach() Ulf Hansson
2021-09-02 10:16 ` [PATCH 3/3] PM: domains: Add a ->dev_get_performance_state() callback to genpd Ulf Hansson
2021-09-03  6:00   ` Dmitry Osipenko
2021-09-03  8:55     ` Ulf Hansson
2021-09-03 10:06       ` Dmitry Osipenko
2021-09-03 14:09         ` Ulf Hansson
2021-09-05  9:11           ` Dmitry Osipenko
2021-09-06 10:53             ` Ulf Hansson
2021-09-06 14:35               ` Dmitry Osipenko
2021-09-07  3:40                 ` Viresh Kumar
2021-09-07  8:10                   ` Dmitry Osipenko
2021-09-07  9:57                 ` Ulf Hansson
2021-09-09 13:48                   ` Dmitry Osipenko
2021-09-09 14:39                     ` Ulf Hansson
2021-09-10 11:24                       ` Dmitry Osipenko

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=20210902101634.827187-2-ulf.hansson@linaro.org \
    --to=ulf.hansson@linaro.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=digetx@gmail.com \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=jonathanh@nvidia.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=rnayak@codeaurora.org \
    --cc=stephan@gerhold.net \
    --cc=thierry.reding@gmail.com \
    --cc=viresh.kumar@linaro.org \
    --subject='Re: [PATCH 1/3] PM: domains: Drop the performance state vote for a device at detach' \
    /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

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).