[PATCH] pmdomain: arm: scmi_pm_domain: Initialize state as off

Peng Fan (OSS) posted 1 patch 1 year ago
drivers/pmdomain/arm/scmi_pm_domain.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
[PATCH] pmdomain: arm: scmi_pm_domain: Initialize state as off
Posted by Peng Fan (OSS) 1 year ago
From: Peng Fan <peng.fan@nxp.com>

Per ARM SCMI Spec DEN0056E, page 16, "The platform may disable a resource
if no agent has requested to use that resource."

Linux Kernel should not rely on a state that it has not requested, so
make state as off during initialization.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pmdomain/arm/scmi_pm_domain.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/pmdomain/arm/scmi_pm_domain.c b/drivers/pmdomain/arm/scmi_pm_domain.c
index a7784a8bb5db..eadfc032867f 100644
--- a/drivers/pmdomain/arm/scmi_pm_domain.c
+++ b/drivers/pmdomain/arm/scmi_pm_domain.c
@@ -89,13 +89,6 @@ static int scmi_pm_domain_probe(struct scmi_device *sdev)
 		return -ENOMEM;
 
 	for (i = 0; i < num_domains; i++, scmi_pd++) {
-		u32 state;
-
-		if (power_ops->state_get(ph, i, &state)) {
-			dev_warn(dev, "failed to get state for domain %d\n", i);
-			continue;
-		}
-
 		scmi_pd->domain = i;
 		scmi_pd->ph = ph;
 		scmi_pd->name = power_ops->name_get(ph, i);
@@ -104,8 +97,7 @@ static int scmi_pm_domain_probe(struct scmi_device *sdev)
 		scmi_pd->genpd.power_on = scmi_pd_power_on;
 		scmi_pd->genpd.flags = GENPD_FLAG_ACTIVE_WAKEUP;
 
-		pm_genpd_init(&scmi_pd->genpd, NULL,
-			      state == SCMI_POWER_STATE_GENERIC_OFF);
+		pm_genpd_init(&scmi_pd->genpd, NULL, true);
 
 		domains[i] = &scmi_pd->genpd;
 	}
-- 
2.37.1
Re: [PATCH] pmdomain: arm: scmi_pm_domain: Initialize state as off
Posted by Sudeep Holla 1 year ago
On Fri, Jan 10, 2025 at 02:13:46PM +0800, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> Per ARM SCMI Spec DEN0056E, page 16, "The platform may disable a resource
> if no agent has requested to use that resource."
>

True, but ...

> Linux Kernel should not rely on a state that it has not requested, so
> make state as off during initialization.
>

IIUC, this was done to avoid any transitions if the bootloader like U-Boot
has turned on the resource and OS can just rely on that stay. Anyways if
the resource is not used by any driver/device in the kernel, won't it be
turned off anyways ? What am I missing ?

I need to dig details, but I remember doing what this patch does and
reverting to what we have based on the feedback IIRC.

--
Regards,
Sudeep