linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] PM: domains: Improve runtime PM performance state handling
@ 2021-08-23 20:24 Dmitry Osipenko
  2021-08-24  7:49 ` Ulf Hansson
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Osipenko @ 2021-08-23 20:24 UTC (permalink / raw)
  To: Thierry Reding, Jonathan Hunter, Ulf Hansson, Rafael J. Wysocki,
	Kevin Hilman, Viresh Kumar, Stephen Boyd, Nishanth Menon
  Cc: linux-kernel, linux-tegra, linux-pm

GENPD core doesn't support handling performance state changes while
consumer device is runtime-suspended or when runtime PM is disabled.
GENPD core may override performance state that was configured by device
driver while RPM of the device was disabled or device was RPM-suspended.
Let's close that gap by allowing drivers to control performance state
while RPM of a consumer device is disabled and to set up performance
state of RPM-suspended device that will be applied by GENPD core on
RPM-resume of the device.

Fixes: 5937c3ce2122 ("PM: domains: Drop/restore performance state votes for devices at runtime PM")
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/base/power/domain.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index e1c8994ae225..3a13a942d012 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -435,7 +435,7 @@ static void genpd_restore_performance_state(struct device *dev,
 int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state)
 {
 	struct generic_pm_domain *genpd;
-	int ret;
+	int ret = 0;
 
 	genpd = dev_to_genpd_safe(dev);
 	if (!genpd)
@@ -446,7 +446,13 @@ int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state)
 		return -EINVAL;
 
 	genpd_lock(genpd);
-	ret = genpd_set_performance_state(dev, state);
+	if (pm_runtime_suspended(dev)) {
+		dev_gpd_data(dev)->rpm_pstate = state;
+	} else {
+		ret = genpd_set_performance_state(dev, state);
+		if (!ret)
+			dev_gpd_data(dev)->rpm_pstate = 0;
+	}
 	genpd_unlock(genpd);
 
 	return ret;
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] PM: domains: Improve runtime PM performance state handling
  2021-08-23 20:24 [PATCH v1] PM: domains: Improve runtime PM performance state handling Dmitry Osipenko
@ 2021-08-24  7:49 ` Ulf Hansson
  2021-08-25 18:17   ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Ulf Hansson @ 2021-08-24  7:49 UTC (permalink / raw)
  To: Dmitry Osipenko, Rafael J. Wysocki
  Cc: Thierry Reding, Jonathan Hunter, Kevin Hilman, Viresh Kumar,
	Stephen Boyd, Nishanth Menon, Linux Kernel Mailing List,
	linux-tegra, Linux PM

On Mon, 23 Aug 2021 at 22:25, Dmitry Osipenko <digetx@gmail.com> wrote:
>
> GENPD core doesn't support handling performance state changes while
> consumer device is runtime-suspended or when runtime PM is disabled.
> GENPD core may override performance state that was configured by device
> driver while RPM of the device was disabled or device was RPM-suspended.
> Let's close that gap by allowing drivers to control performance state
> while RPM of a consumer device is disabled and to set up performance
> state of RPM-suspended device that will be applied by GENPD core on
> RPM-resume of the device.
>
> Fixes: 5937c3ce2122 ("PM: domains: Drop/restore performance state votes for devices at runtime PM")
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>

Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>

Rafael, if not too late, can you please queue this as a fix for v5.14?
I haven't heard about any regression, but the error is there.

Kind regards
Uffe

> ---
>  drivers/base/power/domain.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> index e1c8994ae225..3a13a942d012 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -435,7 +435,7 @@ static void genpd_restore_performance_state(struct device *dev,
>  int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state)
>  {
>         struct generic_pm_domain *genpd;
> -       int ret;
> +       int ret = 0;
>
>         genpd = dev_to_genpd_safe(dev);
>         if (!genpd)
> @@ -446,7 +446,13 @@ int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state)
>                 return -EINVAL;
>
>         genpd_lock(genpd);
> -       ret = genpd_set_performance_state(dev, state);
> +       if (pm_runtime_suspended(dev)) {
> +               dev_gpd_data(dev)->rpm_pstate = state;
> +       } else {
> +               ret = genpd_set_performance_state(dev, state);
> +               if (!ret)
> +                       dev_gpd_data(dev)->rpm_pstate = 0;
> +       }
>         genpd_unlock(genpd);
>
>         return ret;
> --
> 2.32.0
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] PM: domains: Improve runtime PM performance state handling
  2021-08-24  7:49 ` Ulf Hansson
@ 2021-08-25 18:17   ` Rafael J. Wysocki
  0 siblings, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2021-08-25 18:17 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Dmitry Osipenko, Rafael J. Wysocki, Thierry Reding,
	Jonathan Hunter, Kevin Hilman, Viresh Kumar, Stephen Boyd,
	Nishanth Menon, Linux Kernel Mailing List, linux-tegra, Linux PM

On Tue, Aug 24, 2021 at 9:51 AM Ulf Hansson <ulf.hansson@linaro.org> wrote:
>
> On Mon, 23 Aug 2021 at 22:25, Dmitry Osipenko <digetx@gmail.com> wrote:
> >
> > GENPD core doesn't support handling performance state changes while
> > consumer device is runtime-suspended or when runtime PM is disabled.
> > GENPD core may override performance state that was configured by device
> > driver while RPM of the device was disabled or device was RPM-suspended.
> > Let's close that gap by allowing drivers to control performance state
> > while RPM of a consumer device is disabled and to set up performance
> > state of RPM-suspended device that will be applied by GENPD core on
> > RPM-resume of the device.
> >
> > Fixes: 5937c3ce2122 ("PM: domains: Drop/restore performance state votes for devices at runtime PM")
> > Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
>
> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
>
> Rafael, if not too late, can you please queue this as a fix for v5.14?
> I haven't heard about any regression, but the error is there.

Done, thanks!


> > ---
> >  drivers/base/power/domain.c | 10 ++++++++--
> >  1 file changed, 8 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> > index e1c8994ae225..3a13a942d012 100644
> > --- a/drivers/base/power/domain.c
> > +++ b/drivers/base/power/domain.c
> > @@ -435,7 +435,7 @@ static void genpd_restore_performance_state(struct device *dev,
> >  int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state)
> >  {
> >         struct generic_pm_domain *genpd;
> > -       int ret;
> > +       int ret = 0;
> >
> >         genpd = dev_to_genpd_safe(dev);
> >         if (!genpd)
> > @@ -446,7 +446,13 @@ int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state)
> >                 return -EINVAL;
> >
> >         genpd_lock(genpd);
> > -       ret = genpd_set_performance_state(dev, state);
> > +       if (pm_runtime_suspended(dev)) {
> > +               dev_gpd_data(dev)->rpm_pstate = state;
> > +       } else {
> > +               ret = genpd_set_performance_state(dev, state);
> > +               if (!ret)
> > +                       dev_gpd_data(dev)->rpm_pstate = 0;
> > +       }
> >         genpd_unlock(genpd);
> >
> >         return ret;
> > --
> > 2.32.0
> >

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-08-25 18:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-23 20:24 [PATCH v1] PM: domains: Improve runtime PM performance state handling Dmitry Osipenko
2021-08-24  7:49 ` Ulf Hansson
2021-08-25 18:17   ` Rafael J. Wysocki

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