Re: [PATCH v8 5/8] arm64: Use of_cpu_node_to_id helper for CPU topology parsing
From: Suzuki K Poulose <hidden>
Date: 2017-10-17 16:43:04
Also in:
linux-arm-kernel, lkml
On 17/10/17 17:20, Suzuki K Poulose wrote:
On 17/10/17 17:11, Will Deacon wrote:quoted
On Tue, Oct 17, 2017 at 04:24:23PM +0100, Mark Rutland wrote:quoted
On Tue, Oct 10, 2017 at 11:33:00AM +0100, Suzuki K Poulose wrote:quoted
Make use of the new generic helper to convert an of_node of a CPU to the logical CPU id in parsing the topology. Cc: Catalin Marinas <redacted> Cc: Leo Yan <redacted> Cc: Will Deacon <redacted> Cc: Mark Rutland <redacted> Signed-off-by: Suzuki K Poulose <redacted>This looks sane to me, but it will need an ack from Will or Catalin. FWIW: Acked-by: Mark Rutland <redacted> Thanks, Mark.quoted
--- arch/arm64/kernel/topology.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c index 8d48b233e6ce..21868530018e 100644 --- a/arch/arm64/kernel/topology.c +++ b/arch/arm64/kernel/topology.c@@ -37,18 +37,14 @@ static int __init get_cpu_for_node(struct device_node *node)if (!cpu_node) return -1; - for_each_possible_cpu(cpu) { - if (of_get_cpu_node(cpu, NULL) == cpu_node) { - topology_parse_cpu_capacity(cpu_node, cpu); - of_node_put(cpu_node); - return cpu; - } - } - - pr_crit("Unable to find CPU node for %pOF\n", cpu_node); + cpu = of_cpu_node_to_id(cpu_node); + if (cpu >= 0) + topology_parse_cpu_capacity(cpu_node, cpu); + else + pr_crit("Unable to find CPU node for %pOF\n", cpu_node); of_node_put(cpu_node);This of_node_put is confusing me. Since of_cpu_node_to_id appears to be balanced with its use of the node refcount, is this one intended to pair with the earlier call to of_parse_phandle?Yes. If so, does that mainline isquoted
currently broken here because it doesn't drop the refcount twice for the matching node?No. This of_node_put is for the failure case where we couldn't match a CPU. In the success case, it is dropped just before we return the result within the loop.
As we discussed offline, there is indeed a missing of_node_put() for all the nodes we loop through to match. But with this change, we have fixed that. And I don't think it is worth sending to stable. Cheers Suzuki -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html