public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] PM / Domains: Initial improvements of system PM code in genpd
@ 2016-04-26  6:47 Ulf Hansson
  2016-04-26  6:47 ` [PATCH v2 1/2] PM / Domains: Remove redundant pm_runtime_get|put*() in pm_genpd_prepare() Ulf Hansson
  2016-04-26  6:47 ` [PATCH v2 2/2] PM / Domains: Drop unnecessary wakeup code from pm_genpd_prepare() Ulf Hansson
  0 siblings, 2 replies; 9+ messages in thread
From: Ulf Hansson @ 2016-04-26  6:47 UTC (permalink / raw)
  To: Rafael J. Wysocki, Kevin Hilman, Ulf Hansson, linux-pm
  Cc: Len Brown, Pavel Machek, Geert Uytterhoeven, Lina Iyer,
	Axel Haslam, Marek Szyprowski, Jon Hunter, Andy Gross,
	Laurent Pinchart

The system PM code in genpd needs a round of modernization and clean-up. This is
only the first initial part.

I intend to in step by step improve the code, so in a later point enable to do
optimizations. Such as, avoid waking up devices unless it's really needed.

Ulf Hansson (2):
  PM / Domains: Remove redundant pm_runtime_get|put*() in
    pm_genpd_prepare()
  PM / Domains: Drop unnecessary wakeup code from pm_genpd_prepare()

 drivers/base/power/domain.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

-- 
1.9.1


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

* [PATCH v2 1/2] PM / Domains: Remove redundant pm_runtime_get|put*() in pm_genpd_prepare()
  2016-04-26  6:47 [PATCH v2 0/2] PM / Domains: Initial improvements of system PM code in genpd Ulf Hansson
@ 2016-04-26  6:47 ` Ulf Hansson
  2016-04-26  7:08   ` Ulf Hansson
                     ` (2 more replies)
  2016-04-26  6:47 ` [PATCH v2 2/2] PM / Domains: Drop unnecessary wakeup code from pm_genpd_prepare() Ulf Hansson
  1 sibling, 3 replies; 9+ messages in thread
From: Ulf Hansson @ 2016-04-26  6:47 UTC (permalink / raw)
  To: Rafael J. Wysocki, Kevin Hilman, Ulf Hansson, linux-pm
  Cc: Len Brown, Pavel Machek, Geert Uytterhoeven, Lina Iyer,
	Axel Haslam, Marek Szyprowski, Jon Hunter, Andy Gross,
	Laurent Pinchart

The PM core increases and decreases the runtime PM usage count in the
system PM prepare phase. This makes some of the pm_runtime_get|put*()
calls in pm_gendp_prepare() redundant, so let's remove them.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Kevin Hilman <khilman@baylibre.com>
---

Changes in v2:
	Updated changlog and added Kevin's reviewed by.

---
 drivers/base/power/domain.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 4ce4ce0..60a3573 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -730,14 +730,11 @@ static int pm_genpd_prepare(struct device *dev)
 	 * at this point and a system wakeup event should be reported if it's
 	 * set up to wake up the system from sleep states.
 	 */
-	pm_runtime_get_noresume(dev);
 	if (pm_runtime_barrier(dev) && device_may_wakeup(dev))
 		pm_wakeup_event(dev, 0);
 
-	if (pm_wakeup_pending()) {
-		pm_runtime_put(dev);
+	if (pm_wakeup_pending())
 		return -EBUSY;
-	}
 
 	if (resume_needed(dev, genpd))
 		pm_runtime_resume(dev);
@@ -751,10 +748,8 @@ static int pm_genpd_prepare(struct device *dev)
 
 	mutex_unlock(&genpd->lock);
 
-	if (genpd->suspend_power_off) {
-		pm_runtime_put_noidle(dev);
+	if (genpd->suspend_power_off)
 		return 0;
-	}
 
 	/*
 	 * The PM domain must be in the GPD_STATE_ACTIVE state at this point,
@@ -776,7 +771,6 @@ static int pm_genpd_prepare(struct device *dev)
 		pm_runtime_enable(dev);
 	}
 
-	pm_runtime_put(dev);
 	return ret;
 }
 
-- 
1.9.1


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

* [PATCH v2 2/2] PM / Domains: Drop unnecessary wakeup code from pm_genpd_prepare()
  2016-04-26  6:47 [PATCH v2 0/2] PM / Domains: Initial improvements of system PM code in genpd Ulf Hansson
  2016-04-26  6:47 ` [PATCH v2 1/2] PM / Domains: Remove redundant pm_runtime_get|put*() in pm_genpd_prepare() Ulf Hansson
@ 2016-04-26  6:47 ` Ulf Hansson
  2016-04-26  7:31   ` Laurent Pinchart
  1 sibling, 1 reply; 9+ messages in thread
From: Ulf Hansson @ 2016-04-26  6:47 UTC (permalink / raw)
  To: Rafael J. Wysocki, Kevin Hilman, Ulf Hansson, linux-pm
  Cc: Len Brown, Pavel Machek, Geert Uytterhoeven, Lina Iyer,
	Axel Haslam, Marek Szyprowski, Jon Hunter, Andy Gross,
	Laurent Pinchart

As the PM core already have wakeup management during the system PM phase,
it seems reasonable that genpd and its users should be able to rely on
that. Therefore let's remove this from pm_genpd_prepare().

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

Changes in v2:
	None.

---
 drivers/base/power/domain.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 60a3573..de23b64 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -730,12 +730,6 @@ static int pm_genpd_prepare(struct device *dev)
 	 * at this point and a system wakeup event should be reported if it's
 	 * set up to wake up the system from sleep states.
 	 */
-	if (pm_runtime_barrier(dev) && device_may_wakeup(dev))
-		pm_wakeup_event(dev, 0);
-
-	if (pm_wakeup_pending())
-		return -EBUSY;
-
 	if (resume_needed(dev, genpd))
 		pm_runtime_resume(dev);
 
-- 
1.9.1


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

* Re: [PATCH v2 1/2] PM / Domains: Remove redundant pm_runtime_get|put*() in pm_genpd_prepare()
  2016-04-26  6:47 ` [PATCH v2 1/2] PM / Domains: Remove redundant pm_runtime_get|put*() in pm_genpd_prepare() Ulf Hansson
@ 2016-04-26  7:08   ` Ulf Hansson
  2016-04-27 21:28     ` Rafael J. Wysocki
  2016-04-26  7:27   ` Laurent Pinchart
  2016-04-26  7:27   ` Laurent Pinchart
  2 siblings, 1 reply; 9+ messages in thread
From: Ulf Hansson @ 2016-04-26  7:08 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Len Brown, Pavel Machek, linux-pm@vger.kernel.org, Ulf Hansson,
	Kevin Hilman, Geert Uytterhoeven, Lina Iyer, Axel Haslam,
	Marek Szyprowski, Jon Hunter, Andy Gross, Laurent Pinchart

On 26 April 2016 at 08:47, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> The PM core increases and decreases the runtime PM usage count in the
> system PM prepare phase. This makes some of the pm_runtime_get|put*()
> calls in pm_gendp_prepare() redundant, so let's remove them.

Huh, I noticed I missed to update pm_gendp_prepare() to pm_genpd_prepare().

Rafael, can you amend the patch or you want me to send a v3?

Kind regards
Uffe

>
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> Reviewed-by: Kevin Hilman <khilman@baylibre.com>
> ---
>
> Changes in v2:
>         Updated changlog and added Kevin's reviewed by.
>
> ---
>  drivers/base/power/domain.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> index 4ce4ce0..60a3573 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -730,14 +730,11 @@ static int pm_genpd_prepare(struct device *dev)
>          * at this point and a system wakeup event should be reported if it's
>          * set up to wake up the system from sleep states.
>          */
> -       pm_runtime_get_noresume(dev);
>         if (pm_runtime_barrier(dev) && device_may_wakeup(dev))
>                 pm_wakeup_event(dev, 0);
>
> -       if (pm_wakeup_pending()) {
> -               pm_runtime_put(dev);
> +       if (pm_wakeup_pending())
>                 return -EBUSY;
> -       }
>
>         if (resume_needed(dev, genpd))
>                 pm_runtime_resume(dev);
> @@ -751,10 +748,8 @@ static int pm_genpd_prepare(struct device *dev)
>
>         mutex_unlock(&genpd->lock);
>
> -       if (genpd->suspend_power_off) {
> -               pm_runtime_put_noidle(dev);
> +       if (genpd->suspend_power_off)
>                 return 0;
> -       }
>
>         /*
>          * The PM domain must be in the GPD_STATE_ACTIVE state at this point,
> @@ -776,7 +771,6 @@ static int pm_genpd_prepare(struct device *dev)
>                 pm_runtime_enable(dev);
>         }
>
> -       pm_runtime_put(dev);
>         return ret;
>  }
>
> --
> 1.9.1
>

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

* Re: [PATCH v2 1/2] PM / Domains: Remove redundant pm_runtime_get|put*() in pm_genpd_prepare()
  2016-04-26  6:47 ` [PATCH v2 1/2] PM / Domains: Remove redundant pm_runtime_get|put*() in pm_genpd_prepare() Ulf Hansson
  2016-04-26  7:08   ` Ulf Hansson
@ 2016-04-26  7:27   ` Laurent Pinchart
  2016-04-26  7:27   ` Laurent Pinchart
  2 siblings, 0 replies; 9+ messages in thread
From: Laurent Pinchart @ 2016-04-26  7:27 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Rafael J. Wysocki, Kevin Hilman, linux-pm, Len Brown,
	Pavel Machek, Geert Uytterhoeven, Lina Iyer, Axel Haslam,
	Marek Szyprowski, Jon Hunter, Andy Gross

Hi Ulrich,

Thank you for the patch.

On Tuesday 26 Apr 2016 08:47:17 Ulf Hansson wrote:
> The PM core increases and decreases the runtime PM usage count in the
> system PM prepare phase. This makes some of the pm_runtime_get|put*()
> calls in pm_gendp_prepare() redundant, so let's remove them.
> 
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> Reviewed-by: Kevin Hilman <khilman@baylibre.com>

Apart from the gendp typo,

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
> 
> Changes in v2:
> 	Updated changlog and added Kevin's reviewed by.
> 
> ---
>  drivers/base/power/domain.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> index 4ce4ce0..60a3573 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -730,14 +730,11 @@ static int pm_genpd_prepare(struct device *dev)
>  	 * at this point and a system wakeup event should be reported if it's
>  	 * set up to wake up the system from sleep states.
>  	 */
> -	pm_runtime_get_noresume(dev);
>  	if (pm_runtime_barrier(dev) && device_may_wakeup(dev))
>  		pm_wakeup_event(dev, 0);
> 
> -	if (pm_wakeup_pending()) {
> -		pm_runtime_put(dev);
> +	if (pm_wakeup_pending())
>  		return -EBUSY;
> -	}
> 
>  	if (resume_needed(dev, genpd))
>  		pm_runtime_resume(dev);
> @@ -751,10 +748,8 @@ static int pm_genpd_prepare(struct device *dev)
> 
>  	mutex_unlock(&genpd->lock);
> 
> -	if (genpd->suspend_power_off) {
> -		pm_runtime_put_noidle(dev);
> +	if (genpd->suspend_power_off)
>  		return 0;
> -	}
> 
>  	/*
>  	 * The PM domain must be in the GPD_STATE_ACTIVE state at this point,
> @@ -776,7 +771,6 @@ static int pm_genpd_prepare(struct device *dev)
>  		pm_runtime_enable(dev);
>  	}
> 
> -	pm_runtime_put(dev);
>  	return ret;
>  }

-- 
Regards,

Laurent Pinchart


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

* Re: [PATCH v2 1/2] PM / Domains: Remove redundant pm_runtime_get|put*() in pm_genpd_prepare()
  2016-04-26  6:47 ` [PATCH v2 1/2] PM / Domains: Remove redundant pm_runtime_get|put*() in pm_genpd_prepare() Ulf Hansson
  2016-04-26  7:08   ` Ulf Hansson
  2016-04-26  7:27   ` Laurent Pinchart
@ 2016-04-26  7:27   ` Laurent Pinchart
  2 siblings, 0 replies; 9+ messages in thread
From: Laurent Pinchart @ 2016-04-26  7:27 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Rafael J. Wysocki, Kevin Hilman, linux-pm, Len Brown,
	Pavel Machek, Geert Uytterhoeven, Lina Iyer, Axel Haslam,
	Marek Szyprowski, Jon Hunter, Andy Gross

Hi Ulf,

Thank you for the patch.

On Tuesday 26 Apr 2016 08:47:17 Ulf Hansson wrote:
> The PM core increases and decreases the runtime PM usage count in the
> system PM prepare phase. This makes some of the pm_runtime_get|put*()
> calls in pm_gendp_prepare() redundant, so let's remove them.
> 
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> Reviewed-by: Kevin Hilman <khilman@baylibre.com>

Apart from the gendp typo,

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
> 
> Changes in v2:
> 	Updated changlog and added Kevin's reviewed by.
> 
> ---
>  drivers/base/power/domain.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> index 4ce4ce0..60a3573 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -730,14 +730,11 @@ static int pm_genpd_prepare(struct device *dev)
>  	 * at this point and a system wakeup event should be reported if it's
>  	 * set up to wake up the system from sleep states.
>  	 */
> -	pm_runtime_get_noresume(dev);
>  	if (pm_runtime_barrier(dev) && device_may_wakeup(dev))
>  		pm_wakeup_event(dev, 0);
> 
> -	if (pm_wakeup_pending()) {
> -		pm_runtime_put(dev);
> +	if (pm_wakeup_pending())
>  		return -EBUSY;
> -	}
> 
>  	if (resume_needed(dev, genpd))
>  		pm_runtime_resume(dev);
> @@ -751,10 +748,8 @@ static int pm_genpd_prepare(struct device *dev)
> 
>  	mutex_unlock(&genpd->lock);
> 
> -	if (genpd->suspend_power_off) {
> -		pm_runtime_put_noidle(dev);
> +	if (genpd->suspend_power_off)
>  		return 0;
> -	}
> 
>  	/*
>  	 * The PM domain must be in the GPD_STATE_ACTIVE state at this point,
> @@ -776,7 +771,6 @@ static int pm_genpd_prepare(struct device *dev)
>  		pm_runtime_enable(dev);
>  	}
> 
> -	pm_runtime_put(dev);
>  	return ret;
>  }

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCH v2 2/2] PM / Domains: Drop unnecessary wakeup code from pm_genpd_prepare()
  2016-04-26  6:47 ` [PATCH v2 2/2] PM / Domains: Drop unnecessary wakeup code from pm_genpd_prepare() Ulf Hansson
@ 2016-04-26  7:31   ` Laurent Pinchart
  2016-04-26 11:51     ` Ulf Hansson
  0 siblings, 1 reply; 9+ messages in thread
From: Laurent Pinchart @ 2016-04-26  7:31 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Rafael J. Wysocki, Kevin Hilman, linux-pm, Len Brown,
	Pavel Machek, Geert Uytterhoeven, Lina Iyer, Axel Haslam,
	Marek Szyprowski, Jon Hunter, Andy Gross

Hi Ulf,

Thank you for the patch.

On Tuesday 26 Apr 2016 08:47:18 Ulf Hansson wrote:
> As the PM core already have wakeup management during the system PM phase,
> it seems reasonable that genpd and its users should be able to rely on
> that. Therefore let's remove this from pm_genpd_prepare().

It's probably because I'm not familiar enough with the PM implementation, but 
I haven't been able to locate the wakeup management code in the PM core.

> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> ---
> 
> Changes in v2:
> 	None.
> 
> ---
>  drivers/base/power/domain.c | 6 ------
>  1 file changed, 6 deletions(-)
> 
> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> index 60a3573..de23b64 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -730,12 +730,6 @@ static int pm_genpd_prepare(struct device *dev)
>  	 * at this point and a system wakeup event should be reported if it's
>  	 * set up to wake up the system from sleep states.
>  	 */
> -	if (pm_runtime_barrier(dev) && device_may_wakeup(dev))
> -		pm_wakeup_event(dev, 0);
> -
> -	if (pm_wakeup_pending())
> -		return -EBUSY;
> -
>  	if (resume_needed(dev, genpd))
>  		pm_runtime_resume(dev);

-- 
Regards,

Laurent Pinchart


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

* Re: [PATCH v2 2/2] PM / Domains: Drop unnecessary wakeup code from pm_genpd_prepare()
  2016-04-26  7:31   ` Laurent Pinchart
@ 2016-04-26 11:51     ` Ulf Hansson
  0 siblings, 0 replies; 9+ messages in thread
From: Ulf Hansson @ 2016-04-26 11:51 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Rafael J. Wysocki, Kevin Hilman, linux-pm@vger.kernel.org,
	Len Brown, Pavel Machek, Geert Uytterhoeven, Lina Iyer,
	Axel Haslam, Marek Szyprowski, Jon Hunter, Andy Gross

On 26 April 2016 at 09:31, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
> Hi Ulf,
>
> Thank you for the patch.
>
> On Tuesday 26 Apr 2016 08:47:18 Ulf Hansson wrote:
>> As the PM core already have wakeup management during the system PM phase,
>> it seems reasonable that genpd and its users should be able to rely on
>> that. Therefore let's remove this from pm_genpd_prepare().
>
> It's probably because I'm not familiar enough with the PM implementation, but
> I haven't been able to locate the wakeup management code in the PM core.

It's done in __device_suspend() (drivers/base/power/main.c).

So it means it will be moved from the system PM prepare phase (as
currently in genpd) to the system PM suspend phase. I think this
should be okay for genpd users.

Kind regards
Uffe

>
>> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
>> ---
>>
>> Changes in v2:
>>       None.
>>
>> ---
>>  drivers/base/power/domain.c | 6 ------
>>  1 file changed, 6 deletions(-)
>>
>> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
>> index 60a3573..de23b64 100644
>> --- a/drivers/base/power/domain.c
>> +++ b/drivers/base/power/domain.c
>> @@ -730,12 +730,6 @@ static int pm_genpd_prepare(struct device *dev)
>>        * at this point and a system wakeup event should be reported if it's
>>        * set up to wake up the system from sleep states.
>>        */
>> -     if (pm_runtime_barrier(dev) && device_may_wakeup(dev))
>> -             pm_wakeup_event(dev, 0);
>> -
>> -     if (pm_wakeup_pending())
>> -             return -EBUSY;
>> -
>>       if (resume_needed(dev, genpd))
>>               pm_runtime_resume(dev);
>
> --
> Regards,
>
> Laurent Pinchart
>

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

* Re: [PATCH v2 1/2] PM / Domains: Remove redundant pm_runtime_get|put*() in pm_genpd_prepare()
  2016-04-26  7:08   ` Ulf Hansson
@ 2016-04-27 21:28     ` Rafael J. Wysocki
  0 siblings, 0 replies; 9+ messages in thread
From: Rafael J. Wysocki @ 2016-04-27 21:28 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Len Brown, Pavel Machek, linux-pm@vger.kernel.org, Kevin Hilman,
	Geert Uytterhoeven, Lina Iyer, Axel Haslam, Marek Szyprowski,
	Jon Hunter, Andy Gross, Laurent Pinchart

On Tuesday, April 26, 2016 09:08:22 AM Ulf Hansson wrote:
> On 26 April 2016 at 08:47, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > The PM core increases and decreases the runtime PM usage count in the
> > system PM prepare phase. This makes some of the pm_runtime_get|put*()
> > calls in pm_gendp_prepare() redundant, so let's remove them.
> 
> Huh, I noticed I missed to update pm_gendp_prepare() to pm_genpd_prepare().
> 
> Rafael, can you amend the patch or you want me to send a v3?

No worries, I've fixed it up.

This one and the [2/2] applied, thanks!


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

end of thread, other threads:[~2016-04-27 21:25 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-26  6:47 [PATCH v2 0/2] PM / Domains: Initial improvements of system PM code in genpd Ulf Hansson
2016-04-26  6:47 ` [PATCH v2 1/2] PM / Domains: Remove redundant pm_runtime_get|put*() in pm_genpd_prepare() Ulf Hansson
2016-04-26  7:08   ` Ulf Hansson
2016-04-27 21:28     ` Rafael J. Wysocki
2016-04-26  7:27   ` Laurent Pinchart
2016-04-26  7:27   ` Laurent Pinchart
2016-04-26  6:47 ` [PATCH v2 2/2] PM / Domains: Drop unnecessary wakeup code from pm_genpd_prepare() Ulf Hansson
2016-04-26  7:31   ` Laurent Pinchart
2016-04-26 11:51     ` Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox