linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 1/1] PM / OPP: Fix get sharing cpus when hotplug is used
@ 2017-07-26 12:11 Waldemar Rymarkiewicz
  2017-07-26 12:11 ` [PATCH v4 0/1] " Waldemar Rymarkiewicz
                   ` (3 more replies)
  0 siblings, 4 replies; 19+ messages in thread
From: Waldemar Rymarkiewicz @ 2017-07-26 12:11 UTC (permalink / raw)
  To: linux-pm
  Cc: waldemar.rymarkiewicz, Waldemar Rymarkiewicz, Viresh Kumar,
	Nishanth Menon, Stephen Boyd, Rafael J. Wysocki

We fail dev_pm_opp_of_get_sharing_cpus() when possible cpu device does not
exist. This can happen on platforms where not all possible CPUs are
available at start up ie. hotplugged out. Cpu device is not registered in
the system so we are not able to check struct device to set the sharing
CPUs bitmask properly.

Example (real use case):
2 physical MIPS cores, 4 VPE, cpu0/2 run Linux and cpu1/3 are not available
for Linux at boot up. cpufreq-dt driver + opp v2 fail to register opp_table
due to the fact there is no struct device for cpu1 (remains offline at
bootup).

To solve the bug, stop using device struct to check device_node. Instead
get cpu device_node directly from device tree with of_get_cpu_node().

Signed-off-by: Waldemar Rymarkiewicz <waldemarx.rymarkiewicz@intel.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
---
 drivers/base/power/opp/of.c | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/drivers/base/power/opp/of.c b/drivers/base/power/opp/of.c
index 57eec1c..e83bc15 100644
--- a/drivers/base/power/opp/of.c
+++ b/drivers/base/power/opp/of.c
@@ -248,15 +248,22 @@ void dev_pm_opp_of_remove_table(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(dev_pm_opp_of_remove_table);
 
-/* Returns opp descriptor node for a device, caller must do of_node_put() */
-struct device_node *dev_pm_opp_of_get_opp_desc_node(struct device *dev)
+/* Returns opp descriptor node for a device node, caller must
+ * do of_node_put() */
+static struct device_node *_opp_of_get_opp_desc_node(struct device_node *np)
 {
 	/*
 	 * There should be only ONE phandle present in "operating-points-v2"
 	 * property.
 	 */
 
-	return of_parse_phandle(dev->of_node, "operating-points-v2", 0);
+	return of_parse_phandle(np, "operating-points-v2", 0);
+}
+
+/* Returns opp descriptor node for a device, caller must do of_node_put() */
+struct device_node *dev_pm_opp_of_get_opp_desc_node(struct device *dev)
+{
+	return _opp_of_get_opp_desc_node(dev->of_node);
 }
 EXPORT_SYMBOL_GPL(dev_pm_opp_of_get_opp_desc_node);
 
@@ -572,8 +579,7 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_of_cpumask_add_table);
 int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev,
 				   struct cpumask *cpumask)
 {
-	struct device_node *np, *tmp_np;
-	struct device *tcpu_dev;
+	struct device_node *np, *tmp_np, *cpu_np;
 	int cpu, ret = 0;
 
 	/* Get OPP descriptor node */
@@ -593,19 +599,18 @@ int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev,
 		if (cpu == cpu_dev->id)
 			continue;
 
-		tcpu_dev = get_cpu_device(cpu);
-		if (!tcpu_dev) {
-			dev_err(cpu_dev, "%s: failed to get cpu%d device\n",
+		cpu_np = of_get_cpu_node(cpu, NULL);
+		if (!cpu_np) {
+			dev_err(cpu_dev, "%s: failed to get cpu%d node\n",
 				__func__, cpu);
-			ret = -ENODEV;
+			ret = -ENOENT;
 			goto put_cpu_node;
 		}
 
 		/* Get OPP descriptor node */
-		tmp_np = dev_pm_opp_of_get_opp_desc_node(tcpu_dev);
+		tmp_np = _opp_of_get_opp_desc_node(cpu_np);
 		if (!tmp_np) {
-			dev_err(tcpu_dev, "%s: Couldn't find opp node.\n",
-				__func__);
+			pr_err("%pOF: Couldn't find opp node\n", cpu_node);
 			ret = -ENOENT;
 			goto put_cpu_node;
 		}
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2017-08-03  1:51 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-26 12:11 [PATCH v4 1/1] PM / OPP: Fix get sharing cpus when hotplug is used Waldemar Rymarkiewicz
2017-07-26 12:11 ` [PATCH v4 0/1] " Waldemar Rymarkiewicz
2017-07-26 13:10 ` [PATCH v4 1/1] PM / OPP: " Sudeep Holla
2017-07-26 13:54   ` Waldemar Rymarkiewicz
2017-07-26 14:08     ` Sudeep Holla
2017-07-26 14:41       ` Waldemar Rymarkiewicz
2017-07-26 15:20         ` Sudeep Holla
2017-07-27  3:43       ` Viresh Kumar
2017-07-27  0:03 ` Rafael J. Wysocki
2017-07-27  7:25   ` Waldemar Rymarkiewicz
2017-07-27  7:31     ` Viresh Kumar
2017-07-27 10:01   ` Waldemar Rymarkiewicz
2017-07-30 14:54 ` kbuild test robot
2017-07-31 11:14   ` Rafael J. Wysocki
2017-07-31 15:12     ` Waldemar Rymarkiewicz
2017-07-31 18:50       ` Rafael J. Wysocki
2017-08-01  4:37         ` Viresh Kumar
2017-08-01 11:53           ` Rafael J. Wysocki
2017-08-03  1:50           ` [kbuild-all] " Fengguang Wu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).