* [PATCH] pmdomain: arm: scmi_pm_domain: Remove redundant state verification
@ 2025-03-14 9:58 Sudeep Holla
2025-03-14 10:29 ` Peng Fan
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Sudeep Holla @ 2025-03-14 9:58 UTC (permalink / raw)
To: linux-pm, arm-scmi
Cc: Sudeep Holla, linux-arm-kernel, Peng Fan, Ulf Hansson,
Cristian Marussi, Ranjani Vaidyanathan
Currently, scmi_pd_power() explicitly verifies whether the requested
power state was applied by calling state_get(). While this check could
detect failures where the state was not properly updated, ensuring
correctness is the responsibility of the SCMI firmware.
Removing this redundant state_get() call eliminates an unnecessary
round-trip to the firmware, improving efficiency. Any mismatches
between the requested and actual states should be handled by the SCMI
firmware, which must return a failure if state_set() is unsuccessful.
Additionally, in some cases, checking the state after powering off a
domain may be unreliable or unsafe, depending on the firmware
implementation.
This patch removes the redundant verification, simplifying the function
without compromising correctness.
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Cristian Marussi <cristian.marussi@arm.com>
Reported-and-tested-by: Ranjani Vaidyanathan <ranjani.vaidyanathan@nxp.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/pmdomain/arm/scmi_pm_domain.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/drivers/pmdomain/arm/scmi_pm_domain.c b/drivers/pmdomain/arm/scmi_pm_domain.c
index 86b531e15b85..2a213c218126 100644
--- a/drivers/pmdomain/arm/scmi_pm_domain.c
+++ b/drivers/pmdomain/arm/scmi_pm_domain.c
@@ -24,8 +24,7 @@ struct scmi_pm_domain {
static int scmi_pd_power(struct generic_pm_domain *domain, bool power_on)
{
- int ret;
- u32 state, ret_state;
+ u32 state;
struct scmi_pm_domain *pd = to_scmi_pd(domain);
if (power_on)
@@ -33,13 +32,7 @@ static int scmi_pd_power(struct generic_pm_domain *domain, bool power_on)
else
state = SCMI_POWER_STATE_GENERIC_OFF;
- ret = power_ops->state_set(pd->ph, pd->domain, state);
- if (!ret)
- ret = power_ops->state_get(pd->ph, pd->domain, &ret_state);
- if (!ret && state != ret_state)
- return -EIO;
-
- return ret;
+ return power_ops->state_set(pd->ph, pd->domain, state);
}
static int scmi_pd_power_on(struct generic_pm_domain *domain)
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* RE: [PATCH] pmdomain: arm: scmi_pm_domain: Remove redundant state verification
2025-03-14 9:58 [PATCH] pmdomain: arm: scmi_pm_domain: Remove redundant state verification Sudeep Holla
@ 2025-03-14 10:29 ` Peng Fan
2025-03-14 12:03 ` Cristian Marussi
2025-03-17 10:50 ` Ulf Hansson
2 siblings, 0 replies; 4+ messages in thread
From: Peng Fan @ 2025-03-14 10:29 UTC (permalink / raw)
To: Sudeep Holla, linux-pm@vger.kernel.org, arm-scmi@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org, Ulf Hansson,
Cristian Marussi, Ranjani Vaidyanathan
> Subject: [PATCH] pmdomain: arm: scmi_pm_domain: Remove
> redundant state verification
>
> Currently, scmi_pd_power() explicitly verifies whether the requested
> power state was applied by calling state_get(). While this check could
> detect failures where the state was not properly updated, ensuring
> correctness is the responsibility of the SCMI firmware.
>
> Removing this redundant state_get() call eliminates an unnecessary
> round-trip to the firmware, improving efficiency. Any mismatches
> between the requested and actual states should be handled by the
> SCMI firmware, which must return a failure if state_set() is unsuccessful.
>
> Additionally, in some cases, checking the state after powering off a
> domain may be unreliable or unsafe, depending on the firmware
> implementation.
>
> This patch removes the redundant verification, simplifying the function
> without compromising correctness.
>
> Cc: Peng Fan <peng.fan@nxp.com>
> Cc: Ulf Hansson <ulf.hansson@linaro.org>
> Cc: Cristian Marussi <cristian.marussi@arm.com>
> Reported-and-tested-by: Ranjani Vaidyanathan
> <ranjani.vaidyanathan@nxp.com>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
Reviewed-by: Peng Fan <peng.fan@nxp.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] pmdomain: arm: scmi_pm_domain: Remove redundant state verification
2025-03-14 9:58 [PATCH] pmdomain: arm: scmi_pm_domain: Remove redundant state verification Sudeep Holla
2025-03-14 10:29 ` Peng Fan
@ 2025-03-14 12:03 ` Cristian Marussi
2025-03-17 10:50 ` Ulf Hansson
2 siblings, 0 replies; 4+ messages in thread
From: Cristian Marussi @ 2025-03-14 12:03 UTC (permalink / raw)
To: Sudeep Holla
Cc: linux-pm, arm-scmi, linux-arm-kernel, Peng Fan, Ulf Hansson,
Cristian Marussi, Ranjani Vaidyanathan
On Fri, Mar 14, 2025 at 09:58:51AM +0000, Sudeep Holla wrote:
> Currently, scmi_pd_power() explicitly verifies whether the requested
> power state was applied by calling state_get(). While this check could
> detect failures where the state was not properly updated, ensuring
> correctness is the responsibility of the SCMI firmware.
>
> Removing this redundant state_get() call eliminates an unnecessary
> round-trip to the firmware, improving efficiency. Any mismatches
> between the requested and actual states should be handled by the SCMI
> firmware, which must return a failure if state_set() is unsuccessful.
>
> Additionally, in some cases, checking the state after powering off a
> domain may be unreliable or unsafe, depending on the firmware
> implementation.
>
> This patch removes the redundant verification, simplifying the function
> without compromising correctness.
>
> Cc: Peng Fan <peng.fan@nxp.com>
> Cc: Ulf Hansson <ulf.hansson@linaro.org>
> Cc: Cristian Marussi <cristian.marussi@arm.com>
> Reported-and-tested-by: Ranjani Vaidyanathan <ranjani.vaidyanathan@nxp.com>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
> drivers/pmdomain/arm/scmi_pm_domain.c | 11 ++---------
> 1 file changed, 2 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/pmdomain/arm/scmi_pm_domain.c b/drivers/pmdomain/arm/scmi_pm_domain.c
> index 86b531e15b85..2a213c218126 100644
> --- a/drivers/pmdomain/arm/scmi_pm_domain.c
> +++ b/drivers/pmdomain/arm/scmi_pm_domain.c
> @@ -24,8 +24,7 @@ struct scmi_pm_domain {
>
> static int scmi_pd_power(struct generic_pm_domain *domain, bool power_on)
> {
> - int ret;
> - u32 state, ret_state;
> + u32 state;
> struct scmi_pm_domain *pd = to_scmi_pd(domain);
>
> if (power_on)
> @@ -33,13 +32,7 @@ static int scmi_pd_power(struct generic_pm_domain *domain, bool power_on)
> else
> state = SCMI_POWER_STATE_GENERIC_OFF;
>
> - ret = power_ops->state_set(pd->ph, pd->domain, state);
> - if (!ret)
> - ret = power_ops->state_get(pd->ph, pd->domain, &ret_state);
> - if (!ret && state != ret_state)
> - return -EIO;
> -
> - return ret;
> + return power_ops->state_set(pd->ph, pd->domain, state);
> }
...not sure about the history of this but it would have also definitely
failed consistently on any systen where the SCMI Server exposes resources
physical states (an IMPDEF behaviour), so that after a successfull set_OFF
on a shared resource a subsequent get() could return that the resource is
still physically ON if it was still needed by the other agennts sharing it...
LGTM.
Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>
Thanks,
Cristian
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] pmdomain: arm: scmi_pm_domain: Remove redundant state verification
2025-03-14 9:58 [PATCH] pmdomain: arm: scmi_pm_domain: Remove redundant state verification Sudeep Holla
2025-03-14 10:29 ` Peng Fan
2025-03-14 12:03 ` Cristian Marussi
@ 2025-03-17 10:50 ` Ulf Hansson
2 siblings, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2025-03-17 10:50 UTC (permalink / raw)
To: Sudeep Holla
Cc: linux-pm, arm-scmi, linux-arm-kernel, Peng Fan, Cristian Marussi,
Ranjani Vaidyanathan
On Fri, 14 Mar 2025 at 10:58, Sudeep Holla <sudeep.holla@arm.com> wrote:
>
> Currently, scmi_pd_power() explicitly verifies whether the requested
> power state was applied by calling state_get(). While this check could
> detect failures where the state was not properly updated, ensuring
> correctness is the responsibility of the SCMI firmware.
>
> Removing this redundant state_get() call eliminates an unnecessary
> round-trip to the firmware, improving efficiency. Any mismatches
> between the requested and actual states should be handled by the SCMI
> firmware, which must return a failure if state_set() is unsuccessful.
>
> Additionally, in some cases, checking the state after powering off a
> domain may be unreliable or unsafe, depending on the firmware
> implementation.
>
> This patch removes the redundant verification, simplifying the function
> without compromising correctness.
>
> Cc: Peng Fan <peng.fan@nxp.com>
> Cc: Ulf Hansson <ulf.hansson@linaro.org>
> Cc: Cristian Marussi <cristian.marussi@arm.com>
> Reported-and-tested-by: Ranjani Vaidyanathan <ranjani.vaidyanathan@nxp.com>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Applied for next, thanks!
Kind regards
Uffe
> ---
> drivers/pmdomain/arm/scmi_pm_domain.c | 11 ++---------
> 1 file changed, 2 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/pmdomain/arm/scmi_pm_domain.c b/drivers/pmdomain/arm/scmi_pm_domain.c
> index 86b531e15b85..2a213c218126 100644
> --- a/drivers/pmdomain/arm/scmi_pm_domain.c
> +++ b/drivers/pmdomain/arm/scmi_pm_domain.c
> @@ -24,8 +24,7 @@ struct scmi_pm_domain {
>
> static int scmi_pd_power(struct generic_pm_domain *domain, bool power_on)
> {
> - int ret;
> - u32 state, ret_state;
> + u32 state;
> struct scmi_pm_domain *pd = to_scmi_pd(domain);
>
> if (power_on)
> @@ -33,13 +32,7 @@ static int scmi_pd_power(struct generic_pm_domain *domain, bool power_on)
> else
> state = SCMI_POWER_STATE_GENERIC_OFF;
>
> - ret = power_ops->state_set(pd->ph, pd->domain, state);
> - if (!ret)
> - ret = power_ops->state_get(pd->ph, pd->domain, &ret_state);
> - if (!ret && state != ret_state)
> - return -EIO;
> -
> - return ret;
> + return power_ops->state_set(pd->ph, pd->domain, state);
> }
>
> static int scmi_pd_power_on(struct generic_pm_domain *domain)
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-03-17 10:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-14 9:58 [PATCH] pmdomain: arm: scmi_pm_domain: Remove redundant state verification Sudeep Holla
2025-03-14 10:29 ` Peng Fan
2025-03-14 12:03 ` Cristian Marussi
2025-03-17 10:50 ` 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).