Re: [RFC PATCH 4/9] opp: core: Don't warn if required OPP device does not exist

From: Viresh Kumar
Date: Thu Oct 14 2021 - 02:56:48 EST


On 14-10-21, 15:52, Hector Martin wrote:
> The CPU devices aren't attached to their genpd, so the required OPP
> transition fails with the same error.
>
> However, this was easier to fix than I expected. With this patch to
> cpufreq-dt, it all works properly, and I can drop the parent genpd
> from the clock node and related handling. Thoughts?
>
> commit c4f88743374c1f4678ee7f17fb6cae30ded9ed59
> Author: Hector Martin <marcan@xxxxxxxxx>
> Date: Thu Oct 14 15:47:45 2021 +0900
>
> cpufreq: dt: Attach CPU devices to power domains
> This allows the required-opps mechanism to work for CPU OPP tables,
> triggering specific OPP levels in a parent power domain.
> Signed-off-by: Hector Martin <marcan@xxxxxxxxx>
>
> diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
> index 8fcaba541539..5b22846b557d 100644
> --- a/drivers/cpufreq/cpufreq-dt.c
> +++ b/drivers/cpufreq/cpufreq-dt.c
> @@ -16,6 +16,7 @@
> #include <linux/list.h>
> #include <linux/module.h>
> #include <linux/of.h>
> +#include <linux/pm_domain.h>
> #include <linux/pm_opp.h>
> #include <linux/platform_device.h>
> #include <linux/regulator/consumer.h>
> @@ -264,6 +265,16 @@ static int dt_cpufreq_early_init(struct device *dev, int cpu)
> goto out;
> }
> + /*
> + * Attach the CPU device to its genpd domain (if any), to allow OPP
> + * dependencies to be satisfied.
> + */
> + ret = genpd_dev_pm_attach(cpu_dev);
> + if (ret <= 0) {
> + dev_err(cpu_dev, "Failed to attach CPU device to genpd\n");
> + goto out;
> + }
> +

Other platform do this from some other place I think.

Ulf, where should this code be moved ? cpu-clk driver ?

--
viresh