Skip to contentSkip to conversation

PM / OPP: Fix get sharing cpus when hotplug is used

PATCH Stephen Boyd 3 participants 4 messages Jul 26, 2017 1 message not in the archive

lore
Share & tools
lore

Stephen Boyd

author Reviewed-by
#1 lore raw
In reply to a message not in the archive
Quoted 12 lines · Waldemar Rymarkiewicz

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).

Quoted 6 lines

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().

---

One minor nit, but it's fine to change later as well.

Quoted 12 lines
(quoted diff) +3 -4
@@ -593,18 +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;

Review int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, · line 613

Quoted 10 lines
(quoted diff) +3 -2
+			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",
+			dev_err(cpu_dev, "%s: Couldn't find opp node.\n",

I would remove the full-stop. And also use %pOF with cpu_np and pr_err() instead of dev_err() here so that we print out the node that's missing the OPP node pointer.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#3 lore raw
In reply to a message not in the archive

+Rafael,

Quoted 12 lines · Waldemar Rymarkiewicz

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).

Quoted 8 lines

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().

---
 drivers/base/power/opp/of.c | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

@Waldemar: I don't see this series on patchwork [1]. Are you subscribed for that list ?

Signature · 3 lines
viresh

[1] https://patchwork.kernel.org/project/linux-pm/list/
#2 lore raw
In reply to Stephen Boyd
Quoted 22 lines · Stephen Boyd

On 07/24/2017 09:03 AM, Waldemar Rymarkiewicz wrote:

One minor nit, but it's fine to change later as well.

Quoted 16 lines
(quoted diff) +4 -4
@@ -593,18 +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;
              }
 
Quoted 10 lines

Review int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, · line 613

Quoted 6 lines
(quoted diff) +2 -2
              /* 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",
+                     dev_err(cpu_dev, "%s: Couldn't find opp node.\n",

I would remove the full-stop. And also use %pOF with cpu_np and pr_err() instead of dev_err() here so that we print out the node that's missing the OPP node pointer.

Makes sense. I will send v4 anyway so can include this too.

/Waldek

#4 lore raw
In reply to Viresh Kumar
Quoted 18 lines · Viresh Kumar

+Rafael,

Quoted 15 lines · Waldemar Rymarkiewicz

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().

Quoted 8 lines
Quoted 5 lines
---
 drivers/base/power/opp/of.c | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

@Waldemar: I don't see this series on patchwork [1]. Are you subscribed for that list ?

Well, I am indeed but with my gmail. I have all my mailboxes attached to my patchwork account but didn't know that patchwork checks for the subscription before it picks up a patch. Will subscribe with my @intel.com and send v4 including Stephen comment and Reviewed-by.

/Waldek