linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] soc: qcom: rpmhpd: Make power_on actually enable the domain
@ 2021-10-05  3:37 Bjorn Andersson
  2021-10-15 22:17 ` Stephen Boyd
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Bjorn Andersson @ 2021-10-05  3:37 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Ulf Hansson, Stephen Boyd, Rajendra Nayak
  Cc: linux-arm-msm, linux-kernel

The general expectation is that powering on a power-domain should make
the power domain deliver some power, and if a specific performance state
is needed further requests has to be made.

But in contrast with other power-domain implementations (e.g. rpmpd) the
RPMh does not have an interface to enable the power, so the driver has
to vote for a particular corner (performance level) in rpmh_power_on().

But the corner is never initialized, so a typical request to simply
enable the power domain would not actually turn on the hardware. Further
more, when no more clients vote for a performance state (i.e. the
aggregated vote is 0) the power domain would be turned off.

Fix both of these issues by always voting for a corner with non-zero
value, when the power domain is enabled.

The tracking of the lowest non-zero corner is performed to handle the
corner case if there's ever a domain with a non-zero lowest corner, in
which case both rpmh_power_on() and rpmh_rpmhpd_set_performance_state()
would be allowed to use this lowest corner.

Fixes: 279b7e8a62cc ("soc: qcom: rpmhpd: Add RPMh power domain driver")
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---

Changes since v2:
- Fixed two spelling mistakes in the commit message
- Changed the last hunk to search for first non-zero level, rather than the
  first non-zero index (i.e. 1)

 drivers/soc/qcom/rpmhpd.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/soc/qcom/rpmhpd.c b/drivers/soc/qcom/rpmhpd.c
index e280a8194725..0ca77ed22c6c 100644
--- a/drivers/soc/qcom/rpmhpd.c
+++ b/drivers/soc/qcom/rpmhpd.c
@@ -30,6 +30,7 @@
  * @active_only:	True if it represents an Active only peer
  * @corner:		current corner
  * @active_corner:	current active corner
+ * @enable_corner:	lowest non-zero corner
  * @level:		An array of level (vlvl) to corner (hlvl) mappings
  *			derived from cmd-db
  * @level_count:	Number of levels supported by the power domain. max
@@ -47,6 +48,7 @@ struct rpmhpd {
 	const bool	active_only;
 	unsigned int	corner;
 	unsigned int	active_corner;
+	unsigned int	enable_corner;
 	u32		level[RPMH_ARC_MAX_LEVELS];
 	size_t		level_count;
 	bool		enabled;
@@ -401,13 +403,13 @@ static int rpmhpd_aggregate_corner(struct rpmhpd *pd, unsigned int corner)
 static int rpmhpd_power_on(struct generic_pm_domain *domain)
 {
 	struct rpmhpd *pd = domain_to_rpmhpd(domain);
-	int ret = 0;
+	unsigned int corner;
+	int ret;
 
 	mutex_lock(&rpmhpd_lock);
 
-	if (pd->corner)
-		ret = rpmhpd_aggregate_corner(pd, pd->corner);
-
+	corner = max(pd->corner, pd->enable_corner);
+	ret = rpmhpd_aggregate_corner(pd, corner);
 	if (!ret)
 		pd->enabled = true;
 
@@ -452,6 +454,10 @@ static int rpmhpd_set_performance_state(struct generic_pm_domain *domain,
 		i--;
 
 	if (pd->enabled) {
+		/* Ensure that the domain isn't turn off */
+		if (i < pd->enable_corner)
+			i = pd->enable_corner;
+
 		ret = rpmhpd_aggregate_corner(pd, i);
 		if (ret)
 			goto out;
@@ -488,6 +494,10 @@ static int rpmhpd_update_level_mapping(struct rpmhpd *rpmhpd)
 	for (i = 0; i < rpmhpd->level_count; i++) {
 		rpmhpd->level[i] = buf[i];
 
+		/* Remember the first corner with non-zero level */
+		if (!rpmhpd->level[rpmhpd->enable_corner] && rpmhpd->level[i])
+			rpmhpd->enable_corner = i;
+
 		/*
 		 * The AUX data may be zero padded.  These 0 valued entries at
 		 * the end of the map must be ignored.
-- 
2.29.2


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

* Re: [PATCH v3] soc: qcom: rpmhpd: Make power_on actually enable the domain
  2021-10-05  3:37 [PATCH v3] soc: qcom: rpmhpd: Make power_on actually enable the domain Bjorn Andersson
@ 2021-10-15 22:17 ` Stephen Boyd
  2021-10-16  4:40 ` patchwork-bot+linux-arm-msm
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Stephen Boyd @ 2021-10-15 22:17 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Rajendra Nayak, Ulf Hansson
  Cc: linux-arm-msm, linux-kernel

Quoting Bjorn Andersson (2021-10-04 20:37:32)
> The general expectation is that powering on a power-domain should make
> the power domain deliver some power, and if a specific performance state
> is needed further requests has to be made.
>
> But in contrast with other power-domain implementations (e.g. rpmpd) the
> RPMh does not have an interface to enable the power, so the driver has
> to vote for a particular corner (performance level) in rpmh_power_on().
>
> But the corner is never initialized, so a typical request to simply
> enable the power domain would not actually turn on the hardware. Further
> more, when no more clients vote for a performance state (i.e. the
> aggregated vote is 0) the power domain would be turned off.
>
> Fix both of these issues by always voting for a corner with non-zero
> value, when the power domain is enabled.
>
> The tracking of the lowest non-zero corner is performed to handle the
> corner case if there's ever a domain with a non-zero lowest corner, in
> which case both rpmh_power_on() and rpmh_rpmhpd_set_performance_state()
> would be allowed to use this lowest corner.
>
> Fixes: 279b7e8a62cc ("soc: qcom: rpmhpd: Add RPMh power domain driver")
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---

Looks ok to me.

Reviewed-by: Stephen Boyd <swboyd@chromium.org>

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

* Re: [PATCH v3] soc: qcom: rpmhpd: Make power_on actually enable the domain
  2021-10-05  3:37 [PATCH v3] soc: qcom: rpmhpd: Make power_on actually enable the domain Bjorn Andersson
  2021-10-15 22:17 ` Stephen Boyd
@ 2021-10-16  4:40 ` patchwork-bot+linux-arm-msm
  2021-10-17 15:31 ` (subset) " Bjorn Andersson
  2021-10-19 14:06 ` Ulf Hansson
  3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+linux-arm-msm @ 2021-10-16  4:40 UTC (permalink / raw)
  To: Bjorn Andersson; +Cc: linux-arm-msm

Hello:

This patch was applied to qcom/linux.git (for-next)
by Bjorn Andersson <bjorn.andersson@linaro.org>:

On Mon,  4 Oct 2021 20:37:32 -0700 you wrote:
> The general expectation is that powering on a power-domain should make
> the power domain deliver some power, and if a specific performance state
> is needed further requests has to be made.
> 
> But in contrast with other power-domain implementations (e.g. rpmpd) the
> RPMh does not have an interface to enable the power, so the driver has
> to vote for a particular corner (performance level) in rpmh_power_on().
> 
> [...]

Here is the summary with links:
  - [v3] soc: qcom: rpmhpd: Make power_on actually enable the domain
    https://git.kernel.org/qcom/c/e3e56c050ab6

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

* Re: (subset) [PATCH v3] soc: qcom: rpmhpd: Make power_on actually enable the domain
  2021-10-05  3:37 [PATCH v3] soc: qcom: rpmhpd: Make power_on actually enable the domain Bjorn Andersson
  2021-10-15 22:17 ` Stephen Boyd
  2021-10-16  4:40 ` patchwork-bot+linux-arm-msm
@ 2021-10-17 15:31 ` Bjorn Andersson
  2021-10-19 14:06 ` Ulf Hansson
  3 siblings, 0 replies; 5+ messages in thread
From: Bjorn Andersson @ 2021-10-17 15:31 UTC (permalink / raw)
  To: Andy Gross, Ulf Hansson, Stephen Boyd, Rajendra Nayak, Bjorn Andersson
  Cc: linux-kernel, linux-arm-msm

On Mon, 4 Oct 2021 20:37:32 -0700, Bjorn Andersson wrote:
> The general expectation is that powering on a power-domain should make
> the power domain deliver some power, and if a specific performance state
> is needed further requests has to be made.
> 
> But in contrast with other power-domain implementations (e.g. rpmpd) the
> RPMh does not have an interface to enable the power, so the driver has
> to vote for a particular corner (performance level) in rpmh_power_on().
> 
> [...]

Applied, thanks!

[1/1] soc: qcom: rpmhpd: Make power_on actually enable the domain
      commit: e3e56c050ab6e3f1bd811f0787f50709017543e4

Best regards,
-- 
Bjorn Andersson <bjorn.andersson@linaro.org>

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

* Re: [PATCH v3] soc: qcom: rpmhpd: Make power_on actually enable the domain
  2021-10-05  3:37 [PATCH v3] soc: qcom: rpmhpd: Make power_on actually enable the domain Bjorn Andersson
                   ` (2 preceding siblings ...)
  2021-10-17 15:31 ` (subset) " Bjorn Andersson
@ 2021-10-19 14:06 ` Ulf Hansson
  3 siblings, 0 replies; 5+ messages in thread
From: Ulf Hansson @ 2021-10-19 14:06 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Andy Gross, Stephen Boyd, Rajendra Nayak, linux-arm-msm,
	Linux Kernel Mailing List

On Tue, 5 Oct 2021 at 05:35, Bjorn Andersson <bjorn.andersson@linaro.org> wrote:
>
> The general expectation is that powering on a power-domain should make
> the power domain deliver some power, and if a specific performance state
> is needed further requests has to be made.
>
> But in contrast with other power-domain implementations (e.g. rpmpd) the
> RPMh does not have an interface to enable the power, so the driver has
> to vote for a particular corner (performance level) in rpmh_power_on().
>
> But the corner is never initialized, so a typical request to simply
> enable the power domain would not actually turn on the hardware. Further
> more, when no more clients vote for a performance state (i.e. the
> aggregated vote is 0) the power domain would be turned off.
>
> Fix both of these issues by always voting for a corner with non-zero
> value, when the power domain is enabled.
>
> The tracking of the lowest non-zero corner is performed to handle the
> corner case if there's ever a domain with a non-zero lowest corner, in
> which case both rpmh_power_on() and rpmh_rpmhpd_set_performance_state()
> would be allowed to use this lowest corner.
>
> Fixes: 279b7e8a62cc ("soc: qcom: rpmhpd: Add RPMh power domain driver")
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>

Looks reasonable to me!

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

Kind regards
Uffe

> ---
>
> Changes since v2:
> - Fixed two spelling mistakes in the commit message
> - Changed the last hunk to search for first non-zero level, rather than the
>   first non-zero index (i.e. 1)
>
>  drivers/soc/qcom/rpmhpd.c | 18 ++++++++++++++----
>  1 file changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/soc/qcom/rpmhpd.c b/drivers/soc/qcom/rpmhpd.c
> index e280a8194725..0ca77ed22c6c 100644
> --- a/drivers/soc/qcom/rpmhpd.c
> +++ b/drivers/soc/qcom/rpmhpd.c
> @@ -30,6 +30,7 @@
>   * @active_only:       True if it represents an Active only peer
>   * @corner:            current corner
>   * @active_corner:     current active corner
> + * @enable_corner:     lowest non-zero corner
>   * @level:             An array of level (vlvl) to corner (hlvl) mappings
>   *                     derived from cmd-db
>   * @level_count:       Number of levels supported by the power domain. max
> @@ -47,6 +48,7 @@ struct rpmhpd {
>         const bool      active_only;
>         unsigned int    corner;
>         unsigned int    active_corner;
> +       unsigned int    enable_corner;
>         u32             level[RPMH_ARC_MAX_LEVELS];
>         size_t          level_count;
>         bool            enabled;
> @@ -401,13 +403,13 @@ static int rpmhpd_aggregate_corner(struct rpmhpd *pd, unsigned int corner)
>  static int rpmhpd_power_on(struct generic_pm_domain *domain)
>  {
>         struct rpmhpd *pd = domain_to_rpmhpd(domain);
> -       int ret = 0;
> +       unsigned int corner;
> +       int ret;
>
>         mutex_lock(&rpmhpd_lock);
>
> -       if (pd->corner)
> -               ret = rpmhpd_aggregate_corner(pd, pd->corner);
> -
> +       corner = max(pd->corner, pd->enable_corner);
> +       ret = rpmhpd_aggregate_corner(pd, corner);
>         if (!ret)
>                 pd->enabled = true;
>
> @@ -452,6 +454,10 @@ static int rpmhpd_set_performance_state(struct generic_pm_domain *domain,
>                 i--;
>
>         if (pd->enabled) {
> +               /* Ensure that the domain isn't turn off */
> +               if (i < pd->enable_corner)
> +                       i = pd->enable_corner;
> +
>                 ret = rpmhpd_aggregate_corner(pd, i);
>                 if (ret)
>                         goto out;
> @@ -488,6 +494,10 @@ static int rpmhpd_update_level_mapping(struct rpmhpd *rpmhpd)
>         for (i = 0; i < rpmhpd->level_count; i++) {
>                 rpmhpd->level[i] = buf[i];
>
> +               /* Remember the first corner with non-zero level */
> +               if (!rpmhpd->level[rpmhpd->enable_corner] && rpmhpd->level[i])
> +                       rpmhpd->enable_corner = i;
> +
>                 /*
>                  * The AUX data may be zero padded.  These 0 valued entries at
>                  * the end of the map must be ignored.
> --
> 2.29.2
>

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

end of thread, other threads:[~2021-10-19 14:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-05  3:37 [PATCH v3] soc: qcom: rpmhpd: Make power_on actually enable the domain Bjorn Andersson
2021-10-15 22:17 ` Stephen Boyd
2021-10-16  4:40 ` patchwork-bot+linux-arm-msm
2021-10-17 15:31 ` (subset) " Bjorn Andersson
2021-10-19 14:06 ` Ulf Hansson

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