linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: "Rafael J . Wysocki" <rjw@rjwysocki.net>,
	linux-pm@vger.kernel.org, Len Brown <len.brown@intel.com>,
	Pavel Machek <pavel@ucw.cz>, Kevin Hilman <khilman@kernel.org>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Lina Iyer <lina.iyer@linaro.org>,
	Jon Hunter <jonathanh@nvidia.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>
Subject: Re: [PATCH 2/4] PM / Domains: Enable users of genpd to specify always on PM domains
Date: Mon, 20 Mar 2017 16:41:23 +0530	[thread overview]
Message-ID: <20170320111123.GI25659@vireshk-i7> (raw)
In-Reply-To: <1490005163-28633-3-git-send-email-ulf.hansson@linaro.org>

On 20-03-17, 11:19, Ulf Hansson wrote:
> The current way to implement an always on PM domain consists of returning
> -EBUSY from the ->power_off() callback. This is a bit different compared to
> using the always on genpd governor, which prevents the PM domain from being
> powered off via runtime suspend, but not via system suspend.
> 
> The approach to return -EBUSY from the ->power_off() callback to support
> always on PM domains in genpd is suboptimal. That is because it requires
> genpd to follow the regular execution path of the power off sequence, which
> ends by invoking the ->power_off() callback.
> 
> To enable genpd to early abort the power off sequence for always on PM
> domains, it needs static information about these configurations. Therefore
> let's add a new genpd configuration flag, GENPD_FLAG_ALWAYS_ON.
> 
> Users of the new GENPD_FLAG_ALWAYS_ON flag, are by genpd required to make
> sure the PM domain is powered on before calling pm_genpd_init(). Moreover,
> users don't need to implement the ->power_off() callback, as genpd doesn't
> ever invoke it.
> 
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> ---
>  drivers/base/power/domain.c | 14 ++++++++++++--
>  include/linux/pm_domain.h   |  1 +
>  2 files changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> index 7a8e70d..e63712d 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -123,6 +123,7 @@ static const struct genpd_lock_ops genpd_spin_ops = {
>  
>  #define genpd_status_on(genpd)		(genpd->status == GPD_STATE_ACTIVE)
>  #define genpd_is_irq_safe(genpd)	(genpd->flags & GENPD_FLAG_IRQ_SAFE)
> +#define genpd_is_always_on(genpd)	(genpd->flags & GENPD_FLAG_ALWAYS_ON)
>  
>  static inline bool irq_safe_dev_in_no_sleep_domain(struct device *dev,
>  		struct generic_pm_domain *genpd)
> @@ -300,7 +301,12 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on,
>  	if (!genpd_status_on(genpd) || genpd->prepared_count > 0)
>  		return 0;
>  
> -	if (atomic_read(&genpd->sd_count) > 0)
> +	/*
> +	 * Abort power off for the PM domain in the following situations:
> +	 * (1) The domain is configured as always on.
> +	 * (2) When the domain has a subdomain being powered on.
> +	 */
> +	if (genpd_is_always_on(genpd) || atomic_read(&genpd->sd_count) > 0)
>  		return -EBUSY;
>  
>  	list_for_each_entry(pdd, &genpd->dev_list, list_node) {
> @@ -752,7 +758,7 @@ static void genpd_sync_power_off(struct generic_pm_domain *genpd, bool use_lock,
>  {
>  	struct gpd_link *link;
>  
> -	if (!genpd_status_on(genpd))
> +	if (!genpd_status_on(genpd) || genpd_is_always_on(genpd))

If we want to have similar code in all the places then maybe we can
write this as:

	if (genpd_is_always_on(genpd) || !genpd_status_on(genpd))

>  		return;
>  
>  	if (genpd->suspended_count != genpd->device_count
> @@ -1491,6 +1497,10 @@ int pm_genpd_init(struct generic_pm_domain *genpd,
>  		genpd->dev_ops.start = pm_clk_resume;
>  	}
>  
> +	/* Always-on domains must be powered on at initialization. */
> +	if (genpd_is_always_on(genpd) && !genpd_status_on(genpd))
> +		return -EINVAL;
> +
>  	/* Use only one "off" state if there were no states declared */
>  	if (genpd->state_count == 0) {
>  		ret = genpd_set_default_power_state(genpd);
> diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
> index 5339ed5..9b6abe6 100644
> --- a/include/linux/pm_domain.h
> +++ b/include/linux/pm_domain.h
> @@ -20,6 +20,7 @@
>  /* Defines used for the flags field in the struct generic_pm_domain */
>  #define GENPD_FLAG_PM_CLK	(1U << 0) /* PM domain uses PM clk */
>  #define GENPD_FLAG_IRQ_SAFE	(1U << 1) /* PM domain operates in atomic */
> +#define GENPD_FLAG_ALWAYS_ON	(1U << 2) /* PM domain is always powered on */
>  
>  enum gpd_status {
>  	GPD_STATE_ACTIVE = 0,	/* PM domain is active */

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

  reply	other threads:[~2017-03-20 11:21 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-20 10:19 [PATCH 0/4] PM / Domains: Add support for always on PM domains in genpd Ulf Hansson
2017-03-20 10:19 ` [PATCH 1/4] PM / Domains: Clean up code validating genpd's status Ulf Hansson
2017-03-20 11:07   ` Viresh Kumar
2017-03-20 11:49   ` Geert Uytterhoeven
     [not found]   ` <CGME20170320171040epcas1p3ed2179e98b8dbeead3cb81571dd8fbf3@epcas1p3.samsung.com>
2017-03-20 17:10     ` Bartlomiej Zolnierkiewicz
2017-03-20 10:19 ` [PATCH 2/4] PM / Domains: Enable users of genpd to specify always on PM domains Ulf Hansson
2017-03-20 11:11   ` Viresh Kumar [this message]
2017-03-20 11:54   ` Geert Uytterhoeven
     [not found]   ` <CGME20170320171057epcas1p2b7c3a9d663e86df6e29e7e6ceb582a70@epcas1p2.samsung.com>
2017-03-20 17:10     ` Bartlomiej Zolnierkiewicz
2017-03-20 10:19 ` [PATCH 3/4] PM / Domains: Respect errors from genpd's ->power_off() callback Ulf Hansson
2017-03-20 11:11   ` Viresh Kumar
2017-03-20 11:58   ` Geert Uytterhoeven
     [not found]   ` <CGME20170320171402epcas5p4f3e78dbbc7056aceda93501ae8af4a8c@epcas5p4.samsung.com>
2017-03-20 17:14     ` Bartlomiej Zolnierkiewicz
2017-03-20 10:19 ` [PATCH 4/4] PM / Domains: Don't warn about IRQ safe device for an always on PM domain Ulf Hansson
2017-03-20 11:12   ` Viresh Kumar
2017-03-20 11:59   ` Geert Uytterhoeven
     [not found]   ` <CGME20170320171420epcas1p2f4598561c0bb9b81f8182a2566a4d93d@epcas1p2.samsung.com>
2017-03-20 17:14     ` Bartlomiej Zolnierkiewicz
2017-04-23 22:12 ` [PATCH 0/4] PM / Domains: Add support for always on PM domains in genpd Kevin Hilman

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=20170320111123.GI25659@vireshk-i7 \
    --to=viresh.kumar@linaro.org \
    --cc=geert@linux-m68k.org \
    --cc=jonathanh@nvidia.com \
    --cc=khilman@kernel.org \
    --cc=len.brown@intel.com \
    --cc=lina.iyer@linaro.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=pavel@ucw.cz \
    --cc=rjw@rjwysocki.net \
    --cc=ulf.hansson@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 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).