diff mbox series

[v2] PM / OPP: add missing of_node_put() for of_get_cpu_node()

Message ID 1507716661-27146-1-git-send-email-sudeep.holla@arm.com
State New
Headers show
Series [v2] PM / OPP: add missing of_node_put() for of_get_cpu_node() | expand

Commit Message

Sudeep Holla Oct. 11, 2017, 10:11 a.m. UTC
Commit 762792913f8c ("PM / OPP: Fix get sharing CPUs when hotplug is used")
moved away from using cpu_dev->of_node because of some limitations.
However commit 7467c9d95989 ("of: return of_get_cpu_node from
of_cpu_device_node_get if CPUs are not registered") added support to
falls back to of_get_cpu_node if called if CPUs are not registered yet.

It adds the missing of_node_put for the CPU device nodes. This patch also
moves back to use of_cpu_device_node_get in dev_pm_opp_of_get_sharing_cpus
to avoid scanning the device tree again.

Cc: Viresh Kumar <vireshk@kernel.org>
Cc: Nishanth Menon <nm@ti.com>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Fixes: 762792913f8c ("PM / OPP: Fix get sharing CPUs when hotplug is used")
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

---
 drivers/opp/of.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

v1->v2:
	- Moved of_node_put after using cpu_np
	- Renamed the $subject as fixing refcount is key part of the part
	  and correctly relates to "Fixes" tag
	- Also added include change which was accidentally missed

--
2.7.4

Comments

Viresh Kumar Oct. 11, 2017, 10:21 a.m. UTC | #1
On 11-10-17, 11:11, Sudeep Holla wrote:
> Commit 762792913f8c ("PM / OPP: Fix get sharing CPUs when hotplug is used")

> moved away from using cpu_dev->of_node because of some limitations.

> However commit 7467c9d95989 ("of: return of_get_cpu_node from

> of_cpu_device_node_get if CPUs are not registered") added support to

> falls back to of_get_cpu_node if called if CPUs are not registered yet.

> 

> It adds the missing of_node_put for the CPU device nodes. This patch also

> moves back to use of_cpu_device_node_get in dev_pm_opp_of_get_sharing_cpus

> to avoid scanning the device tree again.

> 

> Cc: Viresh Kumar <vireshk@kernel.org>

> Cc: Nishanth Menon <nm@ti.com>

> Cc: Stephen Boyd <sboyd@codeaurora.org>

> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>

> Fixes: 762792913f8c ("PM / OPP: Fix get sharing CPUs when hotplug is used")

> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>


Cc: 4.14+ <stable@vger.kernel.org> # 4.14+

> ---

>  drivers/opp/of.c | 6 ++++--

>  1 file changed, 4 insertions(+), 2 deletions(-)

> 

> v1->v2:

> 	- Moved of_node_put after using cpu_np

> 	- Renamed the $subject as fixing refcount is key part of the part

> 	  and correctly relates to "Fixes" tag

> 	- Also added include change which was accidentally missed


Acked-by: Viresh Kumar <viresh.kumar@linaro.org>


-- 
viresh
Sudeep Holla Oct. 11, 2017, 10:35 a.m. UTC | #2
On 11/10/17 11:21, Viresh Kumar wrote:
> On 11-10-17, 11:11, Sudeep Holla wrote:

>> Commit 762792913f8c ("PM / OPP: Fix get sharing CPUs when hotplug is used")

>> moved away from using cpu_dev->of_node because of some limitations.

>> However commit 7467c9d95989 ("of: return of_get_cpu_node from

>> of_cpu_device_node_get if CPUs are not registered") added support to

>> falls back to of_get_cpu_node if called if CPUs are not registered yet.

>>

>> It adds the missing of_node_put for the CPU device nodes. This patch also

>> moves back to use of_cpu_device_node_get in dev_pm_opp_of_get_sharing_cpus

>> to avoid scanning the device tree again.

>>

>> Cc: Viresh Kumar <vireshk@kernel.org>

>> Cc: Nishanth Menon <nm@ti.com>

>> Cc: Stephen Boyd <sboyd@codeaurora.org>

>> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>

>> Fixes: 762792913f8c ("PM / OPP: Fix get sharing CPUs when hotplug is used")

>> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

> 

> Cc: 4.14+ <stable@vger.kernel.org> # 4.14+

> 


Generally Greg pulls them based on fixes tags, so I didn't bother
to specify that explicitly :)

>> ---

>>  drivers/opp/of.c | 6 ++++--

>>  1 file changed, 4 insertions(+), 2 deletions(-)

>>

>> v1->v2:

>> 	- Moved of_node_put after using cpu_np

>> 	- Renamed the $subject as fixing refcount is key part of the part

>> 	  and correctly relates to "Fixes" tag

>> 	- Also added include change which was accidentally missed

> 

> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

> 



Thanks.

-- 
Regards,
Sudeep
Viresh Kumar Oct. 11, 2017, 10:36 a.m. UTC | #3
On 11-10-17, 11:35, Sudeep Holla wrote:
> Generally Greg pulls them based on fixes tags, so I didn't bother

> to specify that explicitly :)


Hmm, I didn't knew that :)

-- 
viresh
Sudeep Holla Oct. 11, 2017, 11:21 a.m. UTC | #4
On 11/10/17 11:36, Viresh Kumar wrote:
> On 11-10-17, 11:35, Sudeep Holla wrote:

>> Generally Greg pulls them based on fixes tags, so I didn't bother

>> to specify that explicitly :)

> 

> Hmm, I didn't knew that :)

> 


It's more than just that. Check this thread [1]

-- 
Regards,
Sudeep

[1] https://lkml.org/lkml/2017/10/6/923
Stephen Boyd Oct. 11, 2017, 8:20 p.m. UTC | #5
On 10/11, Sudeep Holla wrote:
> @@ -603,7 +603,7 @@ int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev,

> @@ -614,10 +614,12 @@ int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev,

>  		/* Get OPP descriptor node */

>  		tmp_np = _opp_of_get_opp_desc_node(cpu_np);

>  		if (!tmp_np) {

> +			of_node_put(cpu_np);

>  			pr_err("%pOF: Couldn't find opp node\n", cpu_np);

>  			ret = -ENOENT;

>  			goto put_cpu_node;

>  		}

> +		of_node_put(cpu_np);

> 


Why not?


		tmp_np = _opp_of_get_opp_desc_node(cpu_np);
		of_node_put(cpu_np);
		if (!tmp_np) {
			pr_err("%pOF: Couldn't find opp node\n", cpu_np);
			ret = -ENOENT;
			goto put_cpu_node;
		}

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
Sudeep Holla Oct. 12, 2017, 8:50 a.m. UTC | #6
On 11/10/17 21:20, Stephen Boyd wrote:
> On 10/11, Sudeep Holla wrote:

>> @@ -603,7 +603,7 @@ int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev,

>> @@ -614,10 +614,12 @@ int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev,

>>  		/* Get OPP descriptor node */

>>  		tmp_np = _opp_of_get_opp_desc_node(cpu_np);

>>  		if (!tmp_np) {

>> +			of_node_put(cpu_np);

>>  			pr_err("%pOF: Couldn't find opp node\n", cpu_np);

>>  			ret = -ENOENT;

>>  			goto put_cpu_node;

>>  		}

>> +		of_node_put(cpu_np);

>>

> 

> Why not?

> 

> 

> 		tmp_np = _opp_of_get_opp_desc_node(cpu_np);

> 		of_node_put(cpu_np);

> 		if (!tmp_np) {

> 			pr_err("%pOF: Couldn't find opp node\n", cpu_np);

> 			ret = -ENOENT;

> 			goto put_cpu_node;

> 		}

> 


Yes that's exactly what I asked in v1 and the did it other way as I
didn't get any response. I can do this way, not a problem.

-- 
Regards,
Sudeep
diff mbox series

Patch

diff --git a/drivers/opp/of.c b/drivers/opp/of.c
index 0b718886479b..6a486ad81259 100644
--- a/drivers/opp/of.c
+++ b/drivers/opp/of.c
@@ -16,7 +16,7 @@ 
 #include <linux/cpu.h>
 #include <linux/errno.h>
 #include <linux/device.h>
-#include <linux/of.h>
+#include <linux/of_device.h>
 #include <linux/slab.h>
 #include <linux/export.h>

@@ -603,7 +603,7 @@  int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev,
 		if (cpu == cpu_dev->id)
 			continue;

-		cpu_np = of_get_cpu_node(cpu, NULL);
+		cpu_np = of_cpu_device_node_get(cpu);
 		if (!cpu_np) {
 			dev_err(cpu_dev, "%s: failed to get cpu%d node\n",
 				__func__, cpu);
@@ -614,10 +614,12 @@  int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev,
 		/* Get OPP descriptor node */
 		tmp_np = _opp_of_get_opp_desc_node(cpu_np);
 		if (!tmp_np) {
+			of_node_put(cpu_np);
 			pr_err("%pOF: Couldn't find opp node\n", cpu_np);
 			ret = -ENOENT;
 			goto put_cpu_node;
 		}
+		of_node_put(cpu_np);

 		/* CPUs are sharing opp node */
 		if (np == tmp_np)