pm_genpd_init() can fail while allocating generic power-domain state.
The SCMI driver ignores that error and stores the partially initialized
domain in the onecell array. Provider registration then fails because that
domain was never added to the global genpd list.
Preserve support for partially available SCMI power domains. Log the
failure and leave the corresponding onecell entry NULL so the other
initialized domains remain available. Explicitly skip empty slots when
unwinding provider registration failures.
Fixes: 898216c97ed2 ("firmware: arm_scmi: add device power domain support using genpd")
Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
---
drivers/pmdomain/arm/scmi_pm_domain.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/drivers/pmdomain/arm/scmi_pm_domain.c b/drivers/pmdomain/arm/scmi_pm_domain.c
index 3d73aef21d2f..00192472f325 100644
--- a/drivers/pmdomain/arm/scmi_pm_domain.c
+++ b/drivers/pmdomain/arm/scmi_pm_domain.c
@@ -99,8 +99,13 @@ 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);
+ ret = pm_genpd_init(&scmi_pd->genpd, NULL,
+ state == SCMI_POWER_STATE_GENERIC_OFF);
+ if (ret) {
+ dev_warn(dev, "failed to initialize domain %d: %d\n",
+ i, ret);
+ continue;
+ }
domains[i] = &scmi_pd->genpd;
}@@ -126,8 +131,11 @@ static int scmi_pm_domain_probe(struct scmi_device *sdev)
return 0;
err_rm_genpds:
- for (i = num_domains - 1; i >= 0; i--)
+ for (i = num_domains - 1; i >= 0; i--) {
+ if (!domains[i])
+ continue;
pm_genpd_remove(domains[i]);
+ }
return ret;
}--
2.43.0