diff mbox series

[v3,1/3] cpuidle: dt_idle_genpd: Add helper function to remove genpd topology

Message ID 20230414055502.23920-2-quic_mkshah@quicinc.com (mailing list archive)
State Changes Requested, archived
Headers show
Series Use PSCI OS initiated mode for sc7280 | expand

Commit Message

Maulik Shah April 14, 2023, 5:55 a.m. UTC
Genpd parent and child domain topology created using dt_idle_pd_init_topology()
needs to be removed during error cases.

Add new helper function dt_idle_pd_remove_topology() for same.
---
 drivers/cpuidle/dt_idle_genpd.c | 24 ++++++++++++++++++++++++
 drivers/cpuidle/dt_idle_genpd.h |  7 +++++++
 2 files changed, 31 insertions(+)

Comments

Ulf Hansson April 18, 2023, 8:14 a.m. UTC | #1
On Fri, 14 Apr 2023 at 07:55, Maulik Shah <quic_mkshah@quicinc.com> wrote:
>
> Genpd parent and child domain topology created using dt_idle_pd_init_topology()
> needs to be removed during error cases.
>
> Add new helper function dt_idle_pd_remove_topology() for same.

Except for the missing s-o-b line, this looks good to me.

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

Kind regards
Uffe

> ---
>  drivers/cpuidle/dt_idle_genpd.c | 24 ++++++++++++++++++++++++
>  drivers/cpuidle/dt_idle_genpd.h |  7 +++++++
>  2 files changed, 31 insertions(+)
>
> diff --git a/drivers/cpuidle/dt_idle_genpd.c b/drivers/cpuidle/dt_idle_genpd.c
> index b37165514d4e..1af63c189039 100644
> --- a/drivers/cpuidle/dt_idle_genpd.c
> +++ b/drivers/cpuidle/dt_idle_genpd.c
> @@ -152,6 +152,30 @@ int dt_idle_pd_init_topology(struct device_node *np)
>         return 0;
>  }
>
> +int dt_idle_pd_remove_topology(struct device_node *np)
> +{
> +       struct device_node *node;
> +       struct of_phandle_args child, parent;
> +       int ret;
> +
> +       for_each_child_of_node(np, node) {
> +               if (of_parse_phandle_with_args(node, "power-domains",
> +                                       "#power-domain-cells", 0, &parent))
> +                       continue;
> +
> +               child.np = node;
> +               child.args_count = 0;
> +               ret = of_genpd_remove_subdomain(&parent, &child);
> +               of_node_put(parent.np);
> +               if (ret) {
> +                       of_node_put(node);
> +                       return ret;
> +               }
> +       }
> +
> +       return 0;
> +}
> +
>  struct device *dt_idle_attach_cpu(int cpu, const char *name)
>  {
>         struct device *dev;
> diff --git a/drivers/cpuidle/dt_idle_genpd.h b/drivers/cpuidle/dt_idle_genpd.h
> index a95483d08a02..3be1f70f55b5 100644
> --- a/drivers/cpuidle/dt_idle_genpd.h
> +++ b/drivers/cpuidle/dt_idle_genpd.h
> @@ -14,6 +14,8 @@ struct generic_pm_domain *dt_idle_pd_alloc(struct device_node *np,
>
>  int dt_idle_pd_init_topology(struct device_node *np);
>
> +int dt_idle_pd_remove_topology(struct device_node *np);
> +
>  struct device *dt_idle_attach_cpu(int cpu, const char *name);
>
>  void dt_idle_detach_cpu(struct device *dev);
> @@ -36,6 +38,11 @@ static inline int dt_idle_pd_init_topology(struct device_node *np)
>         return 0;
>  }
>
> +static inline int dt_idle_pd_remove_topology(struct device_node *np)
> +{
> +       return 0;
> +}
> +
>  static inline struct device *dt_idle_attach_cpu(int cpu, const char *name)
>  {
>         return NULL;
> --
> 2.17.1
>
diff mbox series

Patch

diff --git a/drivers/cpuidle/dt_idle_genpd.c b/drivers/cpuidle/dt_idle_genpd.c
index b37165514d4e..1af63c189039 100644
--- a/drivers/cpuidle/dt_idle_genpd.c
+++ b/drivers/cpuidle/dt_idle_genpd.c
@@ -152,6 +152,30 @@  int dt_idle_pd_init_topology(struct device_node *np)
 	return 0;
 }
 
+int dt_idle_pd_remove_topology(struct device_node *np)
+{
+	struct device_node *node;
+	struct of_phandle_args child, parent;
+	int ret;
+
+	for_each_child_of_node(np, node) {
+		if (of_parse_phandle_with_args(node, "power-domains",
+					"#power-domain-cells", 0, &parent))
+			continue;
+
+		child.np = node;
+		child.args_count = 0;
+		ret = of_genpd_remove_subdomain(&parent, &child);
+		of_node_put(parent.np);
+		if (ret) {
+			of_node_put(node);
+			return ret;
+		}
+	}
+
+	return 0;
+}
+
 struct device *dt_idle_attach_cpu(int cpu, const char *name)
 {
 	struct device *dev;
diff --git a/drivers/cpuidle/dt_idle_genpd.h b/drivers/cpuidle/dt_idle_genpd.h
index a95483d08a02..3be1f70f55b5 100644
--- a/drivers/cpuidle/dt_idle_genpd.h
+++ b/drivers/cpuidle/dt_idle_genpd.h
@@ -14,6 +14,8 @@  struct generic_pm_domain *dt_idle_pd_alloc(struct device_node *np,
 
 int dt_idle_pd_init_topology(struct device_node *np);
 
+int dt_idle_pd_remove_topology(struct device_node *np);
+
 struct device *dt_idle_attach_cpu(int cpu, const char *name);
 
 void dt_idle_detach_cpu(struct device *dev);
@@ -36,6 +38,11 @@  static inline int dt_idle_pd_init_topology(struct device_node *np)
 	return 0;
 }
 
+static inline int dt_idle_pd_remove_topology(struct device_node *np)
+{
+	return 0;
+}
+
 static inline struct device *dt_idle_attach_cpu(int cpu, const char *name)
 {
 	return NULL;