All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] soc: renesas: rmobile-sysc: Set GENPD_FLAG_ALWAYS_ON for always-on domain
@ 2019-08-16 12:41 Geert Uytterhoeven
  2019-08-16 13:25 ` Simon Horman
  2019-08-22 14:10 ` Ulf Hansson
  0 siblings, 2 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2019-08-16 12:41 UTC (permalink / raw)
  To: Simon Horman, Magnus Damm
  Cc: Rafael J . Wysocki, Kevin Hilman, Ulf Hansson, linux-renesas-soc,
	linux-pm, Geert Uytterhoeven

Currently the R-Mobile "always-on" PM Domain is implemented by returning
-EBUSY from the generic_pm_domain.power_off() callback, and doing
nothing in the generic_pm_domain.power_on() callback.  However, this
means the PM Domain core code is not aware of the semantics of this
special domain, leading to boot warnings like the following on
SH/R-Mobile SoCs:

    sh_cmt e6130000.timer: PM domain c5 will not be powered off

Fix this by making the always-on nature of the domain explicit instead,
by setting the GENPD_FLAG_ALWAYS_ON flag.  This removes the need for the
domain to provide power control callbacks.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
To be queued in renesas-devel for v5.4.

 drivers/soc/renesas/rmobile-sysc.c | 31 +++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/soc/renesas/rmobile-sysc.c b/drivers/soc/renesas/rmobile-sysc.c
index 444c97f84ea5a76e..caecc24d5d68739c 100644
--- a/drivers/soc/renesas/rmobile-sysc.c
+++ b/drivers/soc/renesas/rmobile-sysc.c
@@ -48,12 +48,8 @@ struct rmobile_pm_domain *to_rmobile_pd(struct generic_pm_domain *d)
 static int rmobile_pd_power_down(struct generic_pm_domain *genpd)
 {
 	struct rmobile_pm_domain *rmobile_pd = to_rmobile_pd(genpd);
-	unsigned int mask;
+	unsigned int mask = BIT(rmobile_pd->bit_shift);
 
-	if (rmobile_pd->bit_shift == ~0)
-		return -EBUSY;
-
-	mask = BIT(rmobile_pd->bit_shift);
 	if (rmobile_pd->suspend) {
 		int ret = rmobile_pd->suspend();
 
@@ -80,14 +76,10 @@ static int rmobile_pd_power_down(struct generic_pm_domain *genpd)
 
 static int __rmobile_pd_power_up(struct rmobile_pm_domain *rmobile_pd)
 {
-	unsigned int mask;
+	unsigned int mask = BIT(rmobile_pd->bit_shift);
 	unsigned int retry_count;
 	int ret = 0;
 
-	if (rmobile_pd->bit_shift == ~0)
-		return 0;
-
-	mask = BIT(rmobile_pd->bit_shift);
 	if (__raw_readl(rmobile_pd->base + PSTR) & mask)
 		return ret;
 
@@ -122,11 +114,15 @@ static void rmobile_init_pm_domain(struct rmobile_pm_domain *rmobile_pd)
 	struct dev_power_governor *gov = rmobile_pd->gov;
 
 	genpd->flags |= GENPD_FLAG_PM_CLK | GENPD_FLAG_ACTIVE_WAKEUP;
-	genpd->power_off		= rmobile_pd_power_down;
-	genpd->power_on			= rmobile_pd_power_up;
-	genpd->attach_dev		= cpg_mstp_attach_dev;
-	genpd->detach_dev		= cpg_mstp_detach_dev;
-	__rmobile_pd_power_up(rmobile_pd);
+	genpd->attach_dev = cpg_mstp_attach_dev;
+	genpd->detach_dev = cpg_mstp_detach_dev;
+
+	if (!(genpd->flags & GENPD_FLAG_ALWAYS_ON)) {
+		genpd->power_off = rmobile_pd_power_down;
+		genpd->power_on = rmobile_pd_power_up;
+		__rmobile_pd_power_up(rmobile_pd);
+	}
+
 	pm_genpd_init(genpd, gov ? : &simple_qos_governor, false);
 }
 
@@ -270,6 +266,11 @@ static void __init rmobile_setup_pm_domain(struct device_node *np,
 		break;
 
 	case PD_NORMAL:
+		if (pd->bit_shift == ~0) {
+			/* Top-level always-on domain */
+			pr_debug("PM domain %s is always-on domain\n", name);
+			pd->genpd.flags |= GENPD_FLAG_ALWAYS_ON;
+		}
 		break;
 	}
 
-- 
2.17.1


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

* Re: [PATCH] soc: renesas: rmobile-sysc: Set GENPD_FLAG_ALWAYS_ON for always-on domain
  2019-08-16 12:41 [PATCH] soc: renesas: rmobile-sysc: Set GENPD_FLAG_ALWAYS_ON for always-on domain Geert Uytterhoeven
@ 2019-08-16 13:25 ` Simon Horman
  2019-08-22 14:10 ` Ulf Hansson
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2019-08-16 13:25 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Magnus Damm, Rafael J . Wysocki, Kevin Hilman, Ulf Hansson,
	linux-renesas-soc, linux-pm

On Fri, Aug 16, 2019 at 02:41:06PM +0200, Geert Uytterhoeven wrote:
> Currently the R-Mobile "always-on" PM Domain is implemented by returning
> -EBUSY from the generic_pm_domain.power_off() callback, and doing
> nothing in the generic_pm_domain.power_on() callback.  However, this
> means the PM Domain core code is not aware of the semantics of this
> special domain, leading to boot warnings like the following on
> SH/R-Mobile SoCs:
> 
>     sh_cmt e6130000.timer: PM domain c5 will not be powered off
> 
> Fix this by making the always-on nature of the domain explicit instead,
> by setting the GENPD_FLAG_ALWAYS_ON flag.  This removes the need for the
> domain to provide power control callbacks.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Reviewed-by: Simon Horman <horms+renesas@verge.net.au>

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

* Re: [PATCH] soc: renesas: rmobile-sysc: Set GENPD_FLAG_ALWAYS_ON for always-on domain
  2019-08-16 12:41 [PATCH] soc: renesas: rmobile-sysc: Set GENPD_FLAG_ALWAYS_ON for always-on domain Geert Uytterhoeven
  2019-08-16 13:25 ` Simon Horman
@ 2019-08-22 14:10 ` Ulf Hansson
  1 sibling, 0 replies; 3+ messages in thread
From: Ulf Hansson @ 2019-08-22 14:10 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Simon Horman, Magnus Damm, Rafael J . Wysocki, Kevin Hilman,
	Linux-Renesas, Linux PM

On Fri, 16 Aug 2019 at 14:41, Geert Uytterhoeven
<geert+renesas@glider.be> wrote:
>
> Currently the R-Mobile "always-on" PM Domain is implemented by returning
> -EBUSY from the generic_pm_domain.power_off() callback, and doing
> nothing in the generic_pm_domain.power_on() callback.  However, this
> means the PM Domain core code is not aware of the semantics of this
> special domain, leading to boot warnings like the following on
> SH/R-Mobile SoCs:
>
>     sh_cmt e6130000.timer: PM domain c5 will not be powered off
>
> Fix this by making the always-on nature of the domain explicit instead,
> by setting the GENPD_FLAG_ALWAYS_ON flag.  This removes the need for the
> domain to provide power control callbacks.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

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

Kind regards
Uffe

> ---
> To be queued in renesas-devel for v5.4.
>
>  drivers/soc/renesas/rmobile-sysc.c | 31 +++++++++++++++---------------
>  1 file changed, 16 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/soc/renesas/rmobile-sysc.c b/drivers/soc/renesas/rmobile-sysc.c
> index 444c97f84ea5a76e..caecc24d5d68739c 100644
> --- a/drivers/soc/renesas/rmobile-sysc.c
> +++ b/drivers/soc/renesas/rmobile-sysc.c
> @@ -48,12 +48,8 @@ struct rmobile_pm_domain *to_rmobile_pd(struct generic_pm_domain *d)
>  static int rmobile_pd_power_down(struct generic_pm_domain *genpd)
>  {
>         struct rmobile_pm_domain *rmobile_pd = to_rmobile_pd(genpd);
> -       unsigned int mask;
> +       unsigned int mask = BIT(rmobile_pd->bit_shift);
>
> -       if (rmobile_pd->bit_shift == ~0)
> -               return -EBUSY;
> -
> -       mask = BIT(rmobile_pd->bit_shift);
>         if (rmobile_pd->suspend) {
>                 int ret = rmobile_pd->suspend();
>
> @@ -80,14 +76,10 @@ static int rmobile_pd_power_down(struct generic_pm_domain *genpd)
>
>  static int __rmobile_pd_power_up(struct rmobile_pm_domain *rmobile_pd)
>  {
> -       unsigned int mask;
> +       unsigned int mask = BIT(rmobile_pd->bit_shift);
>         unsigned int retry_count;
>         int ret = 0;
>
> -       if (rmobile_pd->bit_shift == ~0)
> -               return 0;
> -
> -       mask = BIT(rmobile_pd->bit_shift);
>         if (__raw_readl(rmobile_pd->base + PSTR) & mask)
>                 return ret;
>
> @@ -122,11 +114,15 @@ static void rmobile_init_pm_domain(struct rmobile_pm_domain *rmobile_pd)
>         struct dev_power_governor *gov = rmobile_pd->gov;
>
>         genpd->flags |= GENPD_FLAG_PM_CLK | GENPD_FLAG_ACTIVE_WAKEUP;
> -       genpd->power_off                = rmobile_pd_power_down;
> -       genpd->power_on                 = rmobile_pd_power_up;
> -       genpd->attach_dev               = cpg_mstp_attach_dev;
> -       genpd->detach_dev               = cpg_mstp_detach_dev;
> -       __rmobile_pd_power_up(rmobile_pd);
> +       genpd->attach_dev = cpg_mstp_attach_dev;
> +       genpd->detach_dev = cpg_mstp_detach_dev;
> +
> +       if (!(genpd->flags & GENPD_FLAG_ALWAYS_ON)) {
> +               genpd->power_off = rmobile_pd_power_down;
> +               genpd->power_on = rmobile_pd_power_up;
> +               __rmobile_pd_power_up(rmobile_pd);
> +       }
> +
>         pm_genpd_init(genpd, gov ? : &simple_qos_governor, false);
>  }
>
> @@ -270,6 +266,11 @@ static void __init rmobile_setup_pm_domain(struct device_node *np,
>                 break;
>
>         case PD_NORMAL:
> +               if (pd->bit_shift == ~0) {
> +                       /* Top-level always-on domain */
> +                       pr_debug("PM domain %s is always-on domain\n", name);
> +                       pd->genpd.flags |= GENPD_FLAG_ALWAYS_ON;
> +               }
>                 break;
>         }
>
> --
> 2.17.1
>

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

end of thread, other threads:[~2019-08-22 14:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-16 12:41 [PATCH] soc: renesas: rmobile-sysc: Set GENPD_FLAG_ALWAYS_ON for always-on domain Geert Uytterhoeven
2019-08-16 13:25 ` Simon Horman
2019-08-22 14:10 ` Ulf Hansson

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.