Skip to contentSkip to conversation

cpufreq: dt: check the -EPROBE_DEFER error returned by dev_pm_opp_of_cpumask_add_table

PATCH In review [email protected] 2 participants 2 messages Mar 25, 2021 CPU frequency scaling framework

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 cpufreq: dt: check the -EPROBE_DEFER error returned by dev_pm_opp_of_cpumask_add_table

From: Quanyang Wang <[email protected]>

The function dev_pm_opp_of_cpumask_add_table may return -EPROBE_DEFER which comes from clk_get(dev, NULL) in _update_opp_table_clk. Ignoring this error and call the next function dev_pm_opp_of_cpumask_add_table may cause dt_cpufreq_probe return -ENODEV instead of -EPROBE_DEFER. And this will result cpufreq-dt driver probe failure.

Add check condition to fix this issue.

---
 drivers/cpufreq/cpufreq-dt.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/cpufreq/cpufreq-dt.c +6 -1
index b1e1bdc63b01..25e46df92941 100644
@@ -257,7 +257,12 @@ static int dt_cpufreq_early_init(struct device *dev, int cpu)
 	 *
 	 * OPPs might be populated at runtime, don't check for error here.
 	 */
-	if (!dev_pm_opp_of_cpumask_add_table(priv->cpus))
+	ret = dev_pm_opp_of_cpumask_add_table(priv->cpus);
+	if (ret) {
+		/* Return the -EPROBE_DEFER error to trigger the deferred probe. */
+		if (ret == -EPROBE_DEFER)
+			goto out;
+	} else
 		priv->have_static_opps = true;
 
 	/*
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 1 line · On 25-03-21, 14:42, [email protected] wrote:

From: Quanyang Wang <[email protected]>

Made some changes and applied this:

Author: Quanyang Wang <[email protected]>
Date:   Thu Mar 25 14:42:08 2021 +0800

cpufreq: dt: dev_pm_opp_of_cpumask_add_table() may return -EPROBE_DEFER

The function dev_pm_opp_of_cpumask_add_table() may return -EPROBE_DEFER, which needs to be propagated to the caller to try probing the driver later on.

[ Viresh: Massage changelog/subject, improve code. ]
---
 drivers/cpufreq/cpufreq-dt.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/cpufreq/cpufreq-dt.c +7 -2
index b1e1bdc63b01..ece52863ba62 100644
@@ -255,10 +255,15 @@ static int dt_cpufreq_early_init(struct device *dev, int cpu)
         * before updating priv->cpus. Otherwise, we will end up creating
         * duplicate OPPs for the CPUs.
         *
-        * OPPs might be populated at runtime, don't check for error here.
+        * OPPs might be populated at runtime, don't fail for error here unless
+        * it is -EPROBE_DEFER.
         */
-       if (!dev_pm_opp_of_cpumask_add_table(priv->cpus))
+       ret = dev_pm_opp_of_cpumask_add_table(priv->cpus);
+       if (!ret) {
                priv->have_static_opps = true;
+       } else if (ret == -EPROBE_DEFER) {
+               goto out;
+       }
 
        /*
         * The OPP table must be initialized, statically or dynamically, by this
Signature · 1 line
viresh