linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/21] DT cpu node iterator
@ 2018-09-05 19:37 Rob Herring
  2018-09-05 19:37 ` [PATCH 01/21] of: Add cpu node iterator for_each_of_cpu_node() Rob Herring
                   ` (21 more replies)
  0 siblings, 22 replies; 49+ messages in thread
From: Rob Herring @ 2018-09-05 19:37 UTC (permalink / raw)
  To: devicetree, linux-kernel
  Cc: Frank Rowand, Russell King, Albert Ou, Aurelien Jacquiot,
	Bartlomiej Zolnierkiewicz, Benjamin Herrenschmidt,
	Borislav Petkov, Catalin Marinas, dri-devel, H. Peter Anvin,
	Ingo Molnar, iommu, Joerg Roedel, Jonas Bonn, Ley Foon Tan,
	Magnus Damm, Mark Salter, Mauro Carvalho Chehab,
	Michael Ellerman, Michal Simek, nios2-dev, openrisc,
	Palmer Dabbelt, Rich Felker, Simon Horman, Stafford Horne,
	Stefan Kristiansson, Stephen Boyd, Thomas Gleixner,
	Vitaly Bordug, Will Deacon, Yoshinori Sato, linux-arm-kernel,
	linux-c6x-dev, linux-clk, linux-edac, linux-fbdev, linuxppc-dev,
	linux-renesas-soc, linux-riscv, linux-sh

This series adds an iterator for cpu nodes and converts users over to use
it or of_get_cpu_node in some cases. This allows us to remove the
dependency on device_type property for cpu nodes though removing that
from DTS files will have to wait for some time. In some cases, this makes
the DT search more strict by only looking in /cpus child nodes rather
than any node with the device_type == cpu. The iterator also honors the
status property which is often forgotten.

I've only tested on ARM under QEMU and compiled powerpc.

Rob

Rob Herring (21):
  of: Add cpu node iterator for_each_of_cpu_node()
  of: Support matching cpu nodes with no 'reg' property
  ARM: use for_each_of_cpu_node iterator
  ARM: topology: remove unneeded check for /cpus node
  ARM: shmobile: use for_each_of_cpu_node iterator
  arm64: use for_each_of_cpu_node iterator
  c6x: use for_each_of_cpu_node iterator
  microblaze: get cpu node with of_get_cpu_node
  nios2: get cpu node with of_get_cpu_node
  openrisc: use for_each_of_cpu_node iterator
  powerpc: use for_each_of_cpu_node iterator
  powerpc: 4xx: get cpu node with of_get_cpu_node
  powerpc: 8xx: get cpu node with of_get_cpu_node
  riscv: use for_each_of_cpu_node iterator
  SH: use for_each_of_cpu_node iterator
  x86: DT: use for_each_of_cpu_node iterator
  clk: mvebu: use for_each_of_cpu_node iterator
  edac: cpc925: use for_each_of_cpu_node iterator
  iommu: fsl_pamu: use for_each_of_cpu_node iterator
  of: use for_each_of_cpu_node iterator
  fbdev: fsl-diu: get cpu node with of_get_cpu_node

 arch/arm/kernel/devtree.c                 |  5 +--
 arch/arm/kernel/topology.c                |  6 ---
 arch/arm/mach-shmobile/pm-rcar-gen2.c     |  8 +---
 arch/arm/mach-shmobile/pm-rmobile.c       |  2 +-
 arch/arm/mach-shmobile/timer.c            | 10 +----
 arch/arm64/kernel/smp.c                   |  2 +-
 arch/c6x/kernel/setup.c                   | 11 ++---
 arch/microblaze/kernel/cpu/cpuinfo.c      |  4 +-
 arch/nios2/kernel/cpuinfo.c               |  4 +-
 arch/openrisc/kernel/setup.c              |  3 +-
 arch/powerpc/platforms/4xx/soc.c          |  2 +-
 arch/powerpc/platforms/8xx/m8xx_setup.c   |  5 ++-
 arch/powerpc/platforms/powermac/feature.c | 51 ++++++++---------------
 arch/powerpc/platforms/powermac/setup.c   | 15 +++----
 arch/riscv/kernel/smpboot.c               |  2 +-
 arch/sh/boards/of-generic.c               |  2 +-
 arch/x86/kernel/devicetree.c              |  2 +-
 drivers/clk/mvebu/clk-cpu.c               |  4 +-
 drivers/edac/cpc925_edac.c                | 20 +--------
 drivers/iommu/fsl_pamu.c                  |  2 +-
 drivers/of/base.c                         | 43 ++++++++++++++++++-
 drivers/of/of_numa.c                      | 15 +------
 drivers/video/fbdev/fsl-diu-fb.c          |  2 +-
 include/linux/of.h                        | 11 +++++
 24 files changed, 111 insertions(+), 120 deletions(-)

--
2.17.1

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

* [PATCH 01/21] of: Add cpu node iterator for_each_of_cpu_node()
  2018-09-05 19:37 [PATCH 00/21] DT cpu node iterator Rob Herring
@ 2018-09-05 19:37 ` Rob Herring
  2018-09-06  8:45   ` Geert Uytterhoeven
  2018-10-30 14:18   ` Michael Ellerman
  2018-09-05 19:37 ` [PATCH 02/21] of: Support matching cpu nodes with no 'reg' property Rob Herring
                   ` (20 subsequent siblings)
  21 siblings, 2 replies; 49+ messages in thread
From: Rob Herring @ 2018-09-05 19:37 UTC (permalink / raw)
  To: devicetree, linux-kernel; +Cc: Frank Rowand

Iterating thru cpu nodes is a common pattern. Create a common iterator
which can find child nodes either by node name or device_type == cpu.
Using the former will allow for eventually dropping device_type
properties which are deprecated for FDT.

Cc: Frank Rowand <frowand.list@gmail.com>
Signed-off-by: Rob Herring <robh@kernel.org>
---
 drivers/of/base.c  | 39 +++++++++++++++++++++++++++++++++++++++
 include/linux/of.h | 11 +++++++++++
 2 files changed, 50 insertions(+)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index a055cd1ef96d..4807db0a35b3 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -741,6 +741,45 @@ struct device_node *of_get_next_available_child(const struct device_node *node,
 }
 EXPORT_SYMBOL(of_get_next_available_child);

+/**
+ *	of_get_next_cpu_node - Iterate on cpu nodes
+ *	@prev:	previous child of the /cpus node, or NULL to get first
+ *
+ *	Returns a cpu node pointer with refcount incremented, use of_node_put()
+ *	on it when done. Returns NULL when prev is the last child. Decrements
+ *	the refcount of prev.
+ */
+struct device_node *of_get_next_cpu_node(struct device_node *prev)
+{
+	struct device_node *next = NULL;
+	unsigned long flags;
+	struct device_node *node;
+
+	if (!prev)
+		node = of_find_node_by_path("/cpus");
+
+	raw_spin_lock_irqsave(&devtree_lock, flags);
+	if (prev)
+		next = prev->sibling;
+	else if (node) {
+		next = node->child;
+		of_node_put(node);
+	}
+	for (; next; next = next->sibling) {
+		if (!(of_node_name_eq(next, "cpu") ||
+		      (next->type && !of_node_cmp(next->type, "cpu"))))
+			continue;
+		if (!__of_device_is_available(next))
+			continue;
+		if (of_node_get(next))
+			break;
+	}
+	of_node_put(prev);
+	raw_spin_unlock_irqrestore(&devtree_lock, flags);
+	return next;
+}
+EXPORT_SYMBOL(of_get_next_cpu_node);
+
 /**
  * of_get_compatible_child - Find compatible child node
  * @parent:	parent node
diff --git a/include/linux/of.h b/include/linux/of.h
index 99b0ebf49632..1aca0dbd35df 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -353,6 +353,8 @@ extern const void *of_get_property(const struct device_node *node,
 				const char *name,
 				int *lenp);
 extern struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
+extern struct device_node *of_get_next_cpu_node(struct device_node *prev);
+
 #define for_each_property_of_node(dn, pp) \
 	for (pp = dn->properties; pp != NULL; pp = pp->next)

@@ -754,6 +756,11 @@ static inline struct device_node *of_get_cpu_node(int cpu,
 	return NULL;
 }

+static inline struct device_node *of_get_next_cpu_node(struct device_node *prev)
+{
+	return NULL;
+}
+
 static inline int of_n_addr_cells(struct device_node *np)
 {
 	return 0;
@@ -1217,6 +1224,10 @@ static inline int of_property_read_s32(const struct device_node *np,
 	for (child = of_get_next_available_child(parent, NULL); child != NULL; \
 	     child = of_get_next_available_child(parent, child))

+#define for_each_of_cpu_node(cpu) \
+	for (cpu = of_get_next_cpu_node(NULL); cpu != NULL; \
+	     cpu = of_get_next_cpu_node(cpu))
+
 #define for_each_node_with_property(dn, prop_name) \
 	for (dn = of_find_node_with_property(NULL, prop_name); dn; \
 	     dn = of_find_node_with_property(dn, prop_name))
--
2.17.1

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

* [PATCH 02/21] of: Support matching cpu nodes with no 'reg' property
  2018-09-05 19:37 [PATCH 00/21] DT cpu node iterator Rob Herring
  2018-09-05 19:37 ` [PATCH 01/21] of: Add cpu node iterator for_each_of_cpu_node() Rob Herring
@ 2018-09-05 19:37 ` Rob Herring
  2018-09-05 19:37 ` [PATCH 03/21] ARM: use for_each_of_cpu_node iterator Rob Herring
                   ` (19 subsequent siblings)
  21 siblings, 0 replies; 49+ messages in thread
From: Rob Herring @ 2018-09-05 19:37 UTC (permalink / raw)
  To: devicetree, linux-kernel; +Cc: Frank Rowand

For some single core ARM systems, the DTs can have a single cpu node
without a reg property and #address-cells == 0. This case is valid and
should match on cpu #0.

Cc: Frank Rowand <frowand.list@gmail.com>
Signed-off-by: Rob Herring <robh@kernel.org>
---
 drivers/of/base.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 70609d5a2506..6389aeb2f48c 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -327,6 +327,8 @@ static bool __of_find_n_match_cpu_property(struct device_node *cpun,
 
 	ac = of_n_addr_cells(cpun);
 	cell = of_get_property(cpun, prop_name, &prop_len);
+	if (!cell && !ac && arch_match_cpu_phys_id(cpu, 0))
+		return true;
 	if (!cell || !ac)
 		return false;
 	prop_len /= sizeof(*cell) * ac;
-- 
2.17.1


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

* [PATCH 03/21] ARM: use for_each_of_cpu_node iterator
  2018-09-05 19:37 [PATCH 00/21] DT cpu node iterator Rob Herring
  2018-09-05 19:37 ` [PATCH 01/21] of: Add cpu node iterator for_each_of_cpu_node() Rob Herring
  2018-09-05 19:37 ` [PATCH 02/21] of: Support matching cpu nodes with no 'reg' property Rob Herring
@ 2018-09-05 19:37 ` Rob Herring
  2018-09-05 19:37 ` [PATCH 04/21] ARM: topology: remove unneeded check for /cpus node Rob Herring
                   ` (18 subsequent siblings)
  21 siblings, 0 replies; 49+ messages in thread
From: Rob Herring @ 2018-09-05 19:37 UTC (permalink / raw)
  To: devicetree, linux-kernel; +Cc: Russell King, linux-arm-kernel

Use the for_each_of_cpu_node iterator to iterate over cpu nodes. This
has the side effect of defaulting to iterating using "cpu" node names in
preference to the deprecated (for FDT) device_type == "cpu".

Cc: Russell King <linux@armlinux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Rob Herring <robh@kernel.org>
---
Please ack and I will take via the DT tree. This is dependent on the
first 2 patches.

 arch/arm/kernel/devtree.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
index ecaa68dd1af5..13bcd3b867cb 100644
--- a/arch/arm/kernel/devtree.c
+++ b/arch/arm/kernel/devtree.c
@@ -87,14 +87,11 @@ void __init arm_dt_init_cpu_maps(void)
 	if (!cpus)
 		return;

-	for_each_child_of_node(cpus, cpu) {
+	for_each_of_cpu_node(cpu) {
 		const __be32 *cell;
 		int prop_bytes;
 		u32 hwid;

-		if (of_node_cmp(cpu->type, "cpu"))
-			continue;
-
 		pr_debug(" * %pOF...\n", cpu);
 		/*
 		 * A device tree containing CPU nodes with missing "reg"
--
2.17.1

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

* [PATCH 04/21] ARM: topology: remove unneeded check for /cpus node
  2018-09-05 19:37 [PATCH 00/21] DT cpu node iterator Rob Herring
                   ` (2 preceding siblings ...)
  2018-09-05 19:37 ` [PATCH 03/21] ARM: use for_each_of_cpu_node iterator Rob Herring
@ 2018-09-05 19:37 ` Rob Herring
  2018-09-05 19:37 ` [PATCH 05/21] ARM: shmobile: use for_each_of_cpu_node iterator Rob Herring
                   ` (17 subsequent siblings)
  21 siblings, 0 replies; 49+ messages in thread
From: Rob Herring @ 2018-09-05 19:37 UTC (permalink / raw)
  To: devicetree, linux-kernel; +Cc: Russell King, linux-arm-kernel

Checking for "/cpus" node is not necessary as of_get_cpu_node() will fail
later on anyways. The call to of_find_node_by_path() also leaks a
reference. So just remove the check.

Cc: Russell King <linux@armlinux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Rob Herring <robh@kernel.org>
---
Please ack and I will take via the DT tree. This is dependent on the
first 2 patches.

 arch/arm/kernel/topology.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c
index 24ac3cab411d..60e375ce1ab2 100644
--- a/arch/arm/kernel/topology.c
+++ b/arch/arm/kernel/topology.c
@@ -94,12 +94,6 @@ static void __init parse_dt_topology(void)
 	__cpu_capacity = kcalloc(nr_cpu_ids, sizeof(*__cpu_capacity),
 				 GFP_NOWAIT);

-	cn = of_find_node_by_path("/cpus");
-	if (!cn) {
-		pr_err("No CPU information found in DT\n");
-		return;
-	}
-
 	for_each_possible_cpu(cpu) {
 		const u32 *rate;
 		int len;
--
2.17.1

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

* [PATCH 05/21] ARM: shmobile: use for_each_of_cpu_node iterator
  2018-09-05 19:37 [PATCH 00/21] DT cpu node iterator Rob Herring
                   ` (3 preceding siblings ...)
  2018-09-05 19:37 ` [PATCH 04/21] ARM: topology: remove unneeded check for /cpus node Rob Herring
@ 2018-09-05 19:37 ` Rob Herring
  2018-09-06  8:52   ` Geert Uytterhoeven
  2018-09-06  8:56   ` Simon Horman
  2018-09-05 19:37 ` [PATCH 06/21] arm64: " Rob Herring
                   ` (16 subsequent siblings)
  21 siblings, 2 replies; 49+ messages in thread
From: Rob Herring @ 2018-09-05 19:37 UTC (permalink / raw)
  To: devicetree, linux-kernel
  Cc: Simon Horman, Magnus Damm, Russell King, linux-arm-kernel,
	linux-renesas-soc

Use the for_each_of_cpu_node iterator to iterate over cpu nodes. This
has the side effect of defaulting to iterating using "cpu" node names in
preference to the deprecated (for FDT) device_type == "cpu".

Cc: Simon Horman <horms@verge.net.au>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-renesas-soc@vger.kernel.org
Signed-off-by: Rob Herring <robh@kernel.org>
---
Please ack and I will take via the DT tree. This is dependent on the
first 2 patches.

 arch/arm/mach-shmobile/pm-rcar-gen2.c |  8 ++------
 arch/arm/mach-shmobile/pm-rmobile.c   |  2 +-
 arch/arm/mach-shmobile/timer.c        | 10 ++--------
 3 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/arch/arm/mach-shmobile/pm-rcar-gen2.c b/arch/arm/mach-shmobile/pm-rcar-gen2.c
index 345af3ebcc3a..7efe95bd584f 100644
--- a/arch/arm/mach-shmobile/pm-rcar-gen2.c
+++ b/arch/arm/mach-shmobile/pm-rcar-gen2.c
@@ -50,7 +50,7 @@ void __init rcar_gen2_pm_init(void)
 	void __iomem *p;
 	u32 bar;
 	static int once;
-	struct device_node *np, *cpus;
+	struct device_node *np;
 	bool has_a7 = false;
 	bool has_a15 = false;
 	struct resource res;
@@ -59,11 +59,7 @@ void __init rcar_gen2_pm_init(void)
 	if (once++)
 		return;

-	cpus = of_find_node_by_path("/cpus");
-	if (!cpus)
-		return;
-
-	for_each_child_of_node(cpus, np) {
+	for_each_of_cpu_node(np) {
 		if (of_device_is_compatible(np, "arm,cortex-a15"))
 			has_a15 = true;
 		else if (of_device_is_compatible(np, "arm,cortex-a7"))
diff --git a/arch/arm/mach-shmobile/pm-rmobile.c b/arch/arm/mach-shmobile/pm-rmobile.c
index e348bcfe389d..94fdeef11b81 100644
--- a/arch/arm/mach-shmobile/pm-rmobile.c
+++ b/arch/arm/mach-shmobile/pm-rmobile.c
@@ -202,7 +202,7 @@ static void __init get_special_pds(void)
 	const struct of_device_id *id;

 	/* PM domains containing CPUs */
-	for_each_node_by_type(np, "cpu")
+	for_each_of_cpu_node(np)
 		add_special_pd(np, PD_CPU);

 	/* PM domain containing console */
diff --git a/arch/arm/mach-shmobile/timer.c b/arch/arm/mach-shmobile/timer.c
index 828e8aea037e..e48b0939693f 100644
--- a/arch/arm/mach-shmobile/timer.c
+++ b/arch/arm/mach-shmobile/timer.c
@@ -22,22 +22,16 @@

 void __init shmobile_init_delay(void)
 {
-	struct device_node *np, *cpus;
+	struct device_node *np;
 	u32 max_freq = 0;

-	cpus = of_find_node_by_path("/cpus");
-	if (!cpus)
-		return;
-
-	for_each_child_of_node(cpus, np) {
+	for_each_of_cpu_node(np) {
 		u32 freq;

 		if (!of_property_read_u32(np, "clock-frequency", &freq))
 			max_freq = max(max_freq, freq);
 	}

-	of_node_put(cpus);
-
 	if (!max_freq)
 		return;

--
2.17.1

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

* [PATCH 06/21] arm64: use for_each_of_cpu_node iterator
  2018-09-05 19:37 [PATCH 00/21] DT cpu node iterator Rob Herring
                   ` (4 preceding siblings ...)
  2018-09-05 19:37 ` [PATCH 05/21] ARM: shmobile: use for_each_of_cpu_node iterator Rob Herring
@ 2018-09-05 19:37 ` Rob Herring
  2018-09-06 10:04   ` Will Deacon
  2018-09-05 19:37 ` [PATCH 07/21] c6x: " Rob Herring
                   ` (15 subsequent siblings)
  21 siblings, 1 reply; 49+ messages in thread
From: Rob Herring @ 2018-09-05 19:37 UTC (permalink / raw)
  To: devicetree, linux-kernel; +Cc: Catalin Marinas, Will Deacon, linux-arm-kernel

Use the for_each_of_cpu_node iterator to iterate over cpu nodes. This
has the side effect of defaulting to iterating using "cpu" node names in
preference to the deprecated (for FDT) device_type == "cpu".

Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Rob Herring <robh@kernel.org>
---
Please ack and I will take via the DT tree. This is dependent on the
first 2 patches.

 arch/arm64/kernel/smp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
index 25fcd22a4bb2..96b8f2f51ab2 100644
--- a/arch/arm64/kernel/smp.c
+++ b/arch/arm64/kernel/smp.c
@@ -602,7 +602,7 @@ static void __init of_parse_and_init_cpus(void)
 {
 	struct device_node *dn;

-	for_each_node_by_type(dn, "cpu") {
+	for_each_of_cpu_node(dn) {
 		u64 hwid = of_get_cpu_mpidr(dn);

 		if (hwid == INVALID_HWID)
--
2.17.1

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

* [PATCH 07/21] c6x: use for_each_of_cpu_node iterator
  2018-09-05 19:37 [PATCH 00/21] DT cpu node iterator Rob Herring
                   ` (5 preceding siblings ...)
  2018-09-05 19:37 ` [PATCH 06/21] arm64: " Rob Herring
@ 2018-09-05 19:37 ` Rob Herring
  2018-09-05 19:37 ` [PATCH 08/21] microblaze: get cpu node with of_get_cpu_node Rob Herring
                   ` (14 subsequent siblings)
  21 siblings, 0 replies; 49+ messages in thread
From: Rob Herring @ 2018-09-05 19:37 UTC (permalink / raw)
  To: devicetree, linux-kernel; +Cc: Mark Salter, Aurelien Jacquiot, linux-c6x-dev

Use the for_each_of_cpu_node iterator to iterate over cpu nodes. This
has the side effect of defaulting to iterating using "cpu" node names
in preference to the deprecated (for FDT) device_type == "cpu".

Cc: Mark Salter <msalter@redhat.com>
Cc: Aurelien Jacquiot <jacquiot.aurelien@gmail.com>
Cc: linux-c6x-dev@linux-c6x.org
Signed-off-by: Rob Herring <robh@kernel.org>
---
Please ack and I will take via the DT tree. This is dependent on the
first 2 patches.

 arch/c6x/kernel/setup.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/arch/c6x/kernel/setup.c b/arch/c6x/kernel/setup.c
index 786e36e2f61d..2e97455ca0b7 100644
--- a/arch/c6x/kernel/setup.c
+++ b/arch/c6x/kernel/setup.c
@@ -96,7 +96,7 @@ static void __init get_cpuinfo(void)
 	unsigned long core_khz;
 	u64 tmp;
 	struct cpuinfo_c6x *p;
-	struct device_node *node, *np;
+	struct device_node *node;

 	p = &per_cpu(cpu_data, smp_processor_id());

@@ -190,13 +190,8 @@ static void __init get_cpuinfo(void)

 	p->core_id = get_coreid();

-	node = of_find_node_by_name(NULL, "cpus");
-	if (node) {
-		for_each_child_of_node(node, np)
-			if (!strcmp("cpu", np->name))
-				++c6x_num_cores;
-		of_node_put(node);
-	}
+	for_each_of_cpu_node(node)
+		++c6x_num_cores;

 	node = of_find_node_by_name(NULL, "soc");
 	if (node) {
--
2.17.1

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

* [PATCH 08/21] microblaze: get cpu node with of_get_cpu_node
  2018-09-05 19:37 [PATCH 00/21] DT cpu node iterator Rob Herring
                   ` (6 preceding siblings ...)
  2018-09-05 19:37 ` [PATCH 07/21] c6x: " Rob Herring
@ 2018-09-05 19:37 ` Rob Herring
  2018-09-10 14:56   ` Michal Simek
  2018-09-05 19:37 ` [PATCH 09/21] nios2: " Rob Herring
                   ` (13 subsequent siblings)
  21 siblings, 1 reply; 49+ messages in thread
From: Rob Herring @ 2018-09-05 19:37 UTC (permalink / raw)
  To: devicetree, linux-kernel; +Cc: Michal Simek

"device_type" use is deprecated for FDT though it has continued to be used
for nodes like cpu nodes. Use of_get_cpu_node() instead which works using
node names by default. This will allow the eventually removal of cpu
device_type properties.

Also, fix a leaked reference by adding a missing of_node_put.

Cc: Michal Simek <monstr@monstr.eu>
Signed-off-by: Rob Herring <robh@kernel.org>
---
Please ack and I will take via the DT tree. This is dependent on the
first 2 patches.

 arch/microblaze/kernel/cpu/cpuinfo.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/microblaze/kernel/cpu/cpuinfo.c b/arch/microblaze/kernel/cpu/cpuinfo.c
index 96b3f26d16be..0c52aca87478 100644
--- a/arch/microblaze/kernel/cpu/cpuinfo.c
+++ b/arch/microblaze/kernel/cpu/cpuinfo.c
@@ -89,7 +89,7 @@ static struct device_node *cpu;

 void __init setup_cpuinfo(void)
 {
-	cpu = (struct device_node *) of_find_node_by_type(NULL, "cpu");
+	cpu = of_get_cpu_node(0, NULL);
 	if (!cpu)
 		pr_err("You don't have cpu!!!\n");

@@ -117,6 +117,8 @@ void __init setup_cpuinfo(void)
 	if (cpuinfo.mmu_privins)
 		pr_warn("%s: Stream instructions enabled"
 			" - USERSPACE CAN LOCK THIS KERNEL!\n", __func__);
+
+	of_node_put(cpu);
 }

 void __init setup_cpuinfo_clk(void)
--
2.17.1

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

* [PATCH 09/21] nios2: get cpu node with of_get_cpu_node
  2018-09-05 19:37 [PATCH 00/21] DT cpu node iterator Rob Herring
                   ` (7 preceding siblings ...)
  2018-09-05 19:37 ` [PATCH 08/21] microblaze: get cpu node with of_get_cpu_node Rob Herring
@ 2018-09-05 19:37 ` Rob Herring
  2018-09-05 19:37 ` [PATCH 10/21] openrisc: use for_each_of_cpu_node iterator Rob Herring
                   ` (12 subsequent siblings)
  21 siblings, 0 replies; 49+ messages in thread
From: Rob Herring @ 2018-09-05 19:37 UTC (permalink / raw)
  To: devicetree, linux-kernel; +Cc: Ley Foon Tan, nios2-dev

"device_type" use is deprecated for FDT though it has continued to be used
for nodes like cpu nodes. Use of_get_cpu_node() instead which works using
node names by default. This will allow the eventually removal of cpu
device_type properties.

Also, fix a leaked reference by adding a missing of_node_put.

Cc: Ley Foon Tan <lftan@altera.com>
Cc: nios2-dev@lists.rocketboards.org
Signed-off-by: Rob Herring <robh@kernel.org>
---
Please ack and I will take via the DT tree. This is dependent on the
first 2 patches.

 arch/nios2/kernel/cpuinfo.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/nios2/kernel/cpuinfo.c b/arch/nios2/kernel/cpuinfo.c
index 93207718bb22..ccc1d2a15a0a 100644
--- a/arch/nios2/kernel/cpuinfo.c
+++ b/arch/nios2/kernel/cpuinfo.c
@@ -47,7 +47,7 @@ void __init setup_cpuinfo(void)
 	const char *str;
 	int len;

-	cpu = of_find_node_by_type(NULL, "cpu");
+	cpu = of_get_cpu_node(0, NULL);
 	if (!cpu)
 		panic("%s: No CPU found in devicetree!\n", __func__);

@@ -120,6 +120,8 @@ void __init setup_cpuinfo(void)
 	cpuinfo.reset_addr = fcpu(cpu, "altr,reset-addr");
 	cpuinfo.exception_addr = fcpu(cpu, "altr,exception-addr");
 	cpuinfo.fast_tlb_miss_exc_addr = fcpu(cpu, "altr,fast-tlb-miss-addr");
+
+	of_node_put(cpu);
 }

 #ifdef CONFIG_PROC_FS
--
2.17.1

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

* [PATCH 10/21] openrisc: use for_each_of_cpu_node iterator
  2018-09-05 19:37 [PATCH 00/21] DT cpu node iterator Rob Herring
                   ` (8 preceding siblings ...)
  2018-09-05 19:37 ` [PATCH 09/21] nios2: " Rob Herring
@ 2018-09-05 19:37 ` Rob Herring
  2018-09-06  9:12   ` Stafford Horne
  2018-09-05 19:37 ` [PATCH 11/21] powerpc: " Rob Herring
                   ` (11 subsequent siblings)
  21 siblings, 1 reply; 49+ messages in thread
From: Rob Herring @ 2018-09-05 19:37 UTC (permalink / raw)
  To: devicetree, linux-kernel
  Cc: Jonas Bonn, Stefan Kristiansson, Stafford Horne, openrisc

Use the for_each_of_cpu_node iterator to iterate over cpu nodes. This
has the side effect of defaulting to iterating using "cpu" node names in
preference to the deprecated (for FDT) device_type == "cpu".

This also fixes a leaked reference for cpus node.

Cc: Jonas Bonn <jonas@southpole.se>
Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
Cc: Stafford Horne <shorne@gmail.com>
Cc: openrisc@lists.librecores.org
Signed-off-by: Rob Herring <robh@kernel.org>
---
Please ack and I will take via the DT tree. This is dependent on the
first 2 patches.

 arch/openrisc/kernel/setup.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/openrisc/kernel/setup.c b/arch/openrisc/kernel/setup.c
index 9d28ab14d139..e17fcd83120f 100644
--- a/arch/openrisc/kernel/setup.c
+++ b/arch/openrisc/kernel/setup.c
@@ -158,9 +158,8 @@ static struct device_node *setup_find_cpu_node(int cpu)
 {
 	u32 hwid;
 	struct device_node *cpun;
-	struct device_node *cpus = of_find_node_by_path("/cpus");

-	for_each_available_child_of_node(cpus, cpun) {
+	for_each_of_cpu_node(cpun) {
 		if (of_property_read_u32(cpun, "reg", &hwid))
 			continue;
 		if (hwid == cpu)
--
2.17.1

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

* [PATCH 11/21] powerpc: use for_each_of_cpu_node iterator
  2018-09-05 19:37 [PATCH 00/21] DT cpu node iterator Rob Herring
                   ` (9 preceding siblings ...)
  2018-09-05 19:37 ` [PATCH 10/21] openrisc: use for_each_of_cpu_node iterator Rob Herring
@ 2018-09-05 19:37 ` Rob Herring
  2018-09-05 19:37 ` [PATCH 12/21] powerpc: 4xx: get cpu node with of_get_cpu_node Rob Herring
                   ` (10 subsequent siblings)
  21 siblings, 0 replies; 49+ messages in thread
From: Rob Herring @ 2018-09-05 19:37 UTC (permalink / raw)
  To: devicetree, linux-kernel
  Cc: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, linuxppc-dev

Use the for_each_of_cpu_node iterator to iterate over cpu nodes. This
has the side effect of defaulting to iterating using "cpu" node names in
preference to the deprecated (for FDT) device_type == "cpu".

Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Rob Herring <robh@kernel.org>
---
Please ack and I will take via the DT tree. This is dependent on the
first 2 patches.

 arch/powerpc/platforms/powermac/feature.c | 51 ++++++++---------------
 arch/powerpc/platforms/powermac/setup.c   | 15 +++----
 2 files changed, 26 insertions(+), 40 deletions(-)

diff --git a/arch/powerpc/platforms/powermac/feature.c b/arch/powerpc/platforms/powermac/feature.c
index 4eb8cb38fc69..ed2f54b3f173 100644
--- a/arch/powerpc/platforms/powermac/feature.c
+++ b/arch/powerpc/platforms/powermac/feature.c
@@ -1049,7 +1049,6 @@ core99_reset_cpu(struct device_node *node, long param, long value)
 	unsigned long flags;
 	struct macio_chip *macio;
 	struct device_node *np;
-	struct device_node *cpus;
 	const int dflt_reset_lines[] = {	KL_GPIO_RESET_CPU0,
 						KL_GPIO_RESET_CPU1,
 						KL_GPIO_RESET_CPU2,
@@ -1059,10 +1058,7 @@ core99_reset_cpu(struct device_node *node, long param, long value)
 	if (macio->type != macio_keylargo)
 		return -ENODEV;

-	cpus = of_find_node_by_path("/cpus");
-	if (cpus == NULL)
-		return -ENODEV;
-	for (np = cpus->child; np != NULL; np = np->sibling) {
+	for_each_of_cpu_node(np) {
 		const u32 *num = of_get_property(np, "reg", NULL);
 		const u32 *rst = of_get_property(np, "soft-reset", NULL);
 		if (num == NULL || rst == NULL)
@@ -1072,7 +1068,6 @@ core99_reset_cpu(struct device_node *node, long param, long value)
 			break;
 		}
 	}
-	of_node_put(cpus);
 	if (np == NULL || reset_io == 0)
 		reset_io = dflt_reset_lines[param];

@@ -1504,16 +1499,12 @@ static long g5_reset_cpu(struct device_node *node, long param, long value)
 	unsigned long flags;
 	struct macio_chip *macio;
 	struct device_node *np;
-	struct device_node *cpus;

 	macio = &macio_chips[0];
 	if (macio->type != macio_keylargo2 && macio->type != macio_shasta)
 		return -ENODEV;

-	cpus = of_find_node_by_path("/cpus");
-	if (cpus == NULL)
-		return -ENODEV;
-	for (np = cpus->child; np != NULL; np = np->sibling) {
+	for_each_of_cpu_node(np) {
 		const u32 *num = of_get_property(np, "reg", NULL);
 		const u32 *rst = of_get_property(np, "soft-reset", NULL);
 		if (num == NULL || rst == NULL)
@@ -1523,7 +1514,6 @@ static long g5_reset_cpu(struct device_node *node, long param, long value)
 			break;
 		}
 	}
-	of_node_put(cpus);
 	if (np == NULL || reset_io == 0)
 		return -ENODEV;

@@ -2515,31 +2505,26 @@ static int __init probe_motherboard(void)
 	 * supposed to be set when not supported, but I'm not very confident
 	 * that all Apple OF revs did it properly, I do it the paranoid way.
 	 */
-	while (uninorth_base && uninorth_rev > 3) {
-		struct device_node *cpus = of_find_node_by_path("/cpus");
+	if (uninorth_base && uninorth_rev > 3) {
 		struct device_node *np;

-		if (!cpus || !cpus->child) {
-			printk(KERN_WARNING "Can't find CPU(s) in device tree !\n");
-			of_node_put(cpus);
-			break;
-		}
-		np = cpus->child;
-		/* Nap mode not supported on SMP */
-		if (np->sibling) {
-			of_node_put(cpus);
-			break;
-		}
-		/* Nap mode not supported if flush-on-lock property is present */
-		if (of_get_property(np, "flush-on-lock", NULL)) {
-			of_node_put(cpus);
-			break;
+		for_each_of_cpu_node(np) {
+			int cpu_count = 1;
+
+			/* Nap mode not supported on SMP */
+			if (of_get_property(np, "flush-on-lock", NULL) ||
+			    (cpu_count > 1)) {
+				powersave_nap = 0;
+				of_node_put(np);
+				break;
+			}
+
+			cpu_count++;
+			powersave_nap = 1;
 		}
-		of_node_put(cpus);
-		powersave_nap = 1;
-		printk(KERN_DEBUG "Processor NAP mode on idle enabled.\n");
-		break;
 	}
+	if (powersave_nap)
+		printk(KERN_DEBUG "Processor NAP mode on idle enabled.\n");

 	/* On CPUs that support it (750FX), lowspeed by default during
 	 * NAP mode
diff --git a/arch/powerpc/platforms/powermac/setup.c b/arch/powerpc/platforms/powermac/setup.c
index 3a529fcdae97..2f00e3daafb0 100644
--- a/arch/powerpc/platforms/powermac/setup.c
+++ b/arch/powerpc/platforms/powermac/setup.c
@@ -243,10 +243,9 @@ static void __init l2cr_init(void)
 {
 	/* Checks "l2cr-value" property in the registry */
 	if (cpu_has_feature(CPU_FTR_L2CR)) {
-		struct device_node *np = of_find_node_by_name(NULL, "cpus");
-		if (!np)
-			np = of_find_node_by_type(NULL, "cpu");
-		if (np) {
+		struct device_node *np;
+
+		for_each_of_cpu_node(np) {
 			const unsigned int *l2cr =
 				of_get_property(np, "l2cr-value", NULL);
 			if (l2cr) {
@@ -256,6 +255,7 @@ static void __init l2cr_init(void)
 				_set_L2CR(ppc_override_l2cr_value);
 			}
 			of_node_put(np);
+			break;
 		}
 	}

@@ -279,8 +279,8 @@ static void __init pmac_setup_arch(void)
 	/* Set loops_per_jiffy to a half-way reasonable value,
 	   for use until calibrate_delay gets called. */
 	loops_per_jiffy = 50000000 / HZ;
-	cpu = of_find_node_by_type(NULL, "cpu");
-	if (cpu != NULL) {
+
+	for_each_of_cpu_node(cpu) {
 		fp = of_get_property(cpu, "clock-frequency", NULL);
 		if (fp != NULL) {
 			if (pvr >= 0x30 && pvr < 0x80)
@@ -292,8 +292,9 @@ static void __init pmac_setup_arch(void)
 			else
 				/* 601, 603, etc. */
 				loops_per_jiffy = *fp / (2 * HZ);
+			of_node_put(cpu);
+			break;
 		}
-		of_node_put(cpu);
 	}

 	/* See if newworld or oldworld */
--
2.17.1

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

* [PATCH 12/21] powerpc: 4xx: get cpu node with of_get_cpu_node
  2018-09-05 19:37 [PATCH 00/21] DT cpu node iterator Rob Herring
                   ` (10 preceding siblings ...)
  2018-09-05 19:37 ` [PATCH 11/21] powerpc: " Rob Herring
@ 2018-09-05 19:37 ` Rob Herring
  2018-09-05 19:37 ` [PATCH 13/21] powerpc: 8xx: " Rob Herring
                   ` (9 subsequent siblings)
  21 siblings, 0 replies; 49+ messages in thread
From: Rob Herring @ 2018-09-05 19:37 UTC (permalink / raw)
  To: devicetree, linux-kernel
  Cc: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, linuxppc-dev

"device_type" use is deprecated for FDT though it has continued to be used
for nodes like cpu nodes. Use of_get_cpu_node() instead which works using
node names by default. This will allow the eventually removal of cpu
device_type properties.

Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Rob Herring <robh@kernel.org>
---
Please ack and I will take via the DT tree. This is dependent on the
first 2 patches.

 arch/powerpc/platforms/4xx/soc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/4xx/soc.c b/arch/powerpc/platforms/4xx/soc.c
index 5e36508b2a70..1844bf502fcf 100644
--- a/arch/powerpc/platforms/4xx/soc.c
+++ b/arch/powerpc/platforms/4xx/soc.c
@@ -200,7 +200,7 @@ void ppc4xx_reset_system(char *cmd)
 	u32 reset_type = DBCR0_RST_SYSTEM;
 	const u32 *prop;

-	np = of_find_node_by_type(NULL, "cpu");
+	np = of_get_cpu_node(0, NULL);
 	if (np) {
 		prop = of_get_property(np, "reset-type", NULL);

--
2.17.1

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

* [PATCH 13/21] powerpc: 8xx: get cpu node with of_get_cpu_node
  2018-09-05 19:37 [PATCH 00/21] DT cpu node iterator Rob Herring
                   ` (11 preceding siblings ...)
  2018-09-05 19:37 ` [PATCH 12/21] powerpc: 4xx: get cpu node with of_get_cpu_node Rob Herring
@ 2018-09-05 19:37 ` Rob Herring
  2018-09-05 19:37 ` [PATCH 14/21] riscv: use for_each_of_cpu_node iterator Rob Herring
                   ` (8 subsequent siblings)
  21 siblings, 0 replies; 49+ messages in thread
From: Rob Herring @ 2018-09-05 19:37 UTC (permalink / raw)
  To: devicetree, linux-kernel
  Cc: Vitaly Bordug, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman, linuxppc-dev

"device_type" use is deprecated for FDT though it has continued to be used
for nodes like cpu nodes. Use of_get_cpu_node() instead which works using
node names by default. This will allow the eventually removal of cpu
device_type properties.

Also, fix a leaked reference and add a missing of_node_put.

Cc: Vitaly Bordug <vitb@kernel.crashing.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Rob Herring <robh@kernel.org>
---
Please ack and I will take via the DT tree. This is dependent on the
first 2 patches.

 arch/powerpc/platforms/8xx/m8xx_setup.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/platforms/8xx/m8xx_setup.c b/arch/powerpc/platforms/8xx/m8xx_setup.c
index 027c42d8966c..f1c805c8adbc 100644
--- a/arch/powerpc/platforms/8xx/m8xx_setup.c
+++ b/arch/powerpc/platforms/8xx/m8xx_setup.c
@@ -66,7 +66,7 @@ static int __init get_freq(char *name, unsigned long *val)
 	int found = 0;

 	/* The cpu node should have timebase and clock frequency properties */
-	cpu = of_find_node_by_type(NULL, "cpu");
+	cpu = of_get_cpu_node(0, NULL);

 	if (cpu) {
 		fp = of_get_property(cpu, name, NULL);
@@ -147,8 +147,9 @@ void __init mpc8xx_calibrate_decr(void)
 	 * we have to enable the timebase).  The decrementer interrupt
 	 * is wired into the vector table, nothing to do here for that.
 	 */
-	cpu = of_find_node_by_type(NULL, "cpu");
+	cpu = of_get_cpu_node(0, NULL);
 	virq= irq_of_parse_and_map(cpu, 0);
+	of_node_put(cpu);
 	irq = virq_to_hw(virq);

 	sys_tmr2 = immr_map(im_sit);
--
2.17.1

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

* [PATCH 14/21] riscv: use for_each_of_cpu_node iterator
  2018-09-05 19:37 [PATCH 00/21] DT cpu node iterator Rob Herring
                   ` (12 preceding siblings ...)
  2018-09-05 19:37 ` [PATCH 13/21] powerpc: 8xx: " Rob Herring
@ 2018-09-05 19:37 ` Rob Herring
  2018-09-10 13:37   ` Christoph Hellwig
  2018-09-18 22:53   ` Palmer Dabbelt
  2018-09-05 19:37 ` [PATCH 15/21] SH: " Rob Herring
                   ` (7 subsequent siblings)
  21 siblings, 2 replies; 49+ messages in thread
From: Rob Herring @ 2018-09-05 19:37 UTC (permalink / raw)
  To: devicetree, linux-kernel; +Cc: Palmer Dabbelt, Albert Ou, linux-riscv

Use the for_each_of_cpu_node iterator to iterate over cpu nodes. This
has the side effect of defaulting to iterating using "cpu" node names in
preference to the deprecated (for FDT) device_type == "cpu".

Cc: Palmer Dabbelt <palmer@sifive.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: linux-riscv@lists.infradead.org
Signed-off-by: Rob Herring <robh@kernel.org>
---
Please ack and I will take via the DT tree. This is dependent on the
first 2 patches.

 arch/riscv/kernel/smpboot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c
index 56abab6a9812..3c59afe67951 100644
--- a/arch/riscv/kernel/smpboot.c
+++ b/arch/riscv/kernel/smpboot.c
@@ -52,7 +52,7 @@ void __init setup_smp(void)
 	struct device_node *dn = NULL;
 	int hart, im_okay_therefore_i_am = 0;

-	while ((dn = of_find_node_by_type(dn, "cpu"))) {
+	for_each_of_cpu_node(dn) {
 		hart = riscv_of_processor_hart(dn);
 		if (hart >= 0) {
 			set_cpu_possible(hart, true);
--
2.17.1

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

* [PATCH 15/21] SH: use for_each_of_cpu_node iterator
  2018-09-05 19:37 [PATCH 00/21] DT cpu node iterator Rob Herring
                   ` (13 preceding siblings ...)
  2018-09-05 19:37 ` [PATCH 14/21] riscv: use for_each_of_cpu_node iterator Rob Herring
@ 2018-09-05 19:37 ` Rob Herring
  2018-09-05 19:37 ` [PATCH 16/21] x86: DT: " Rob Herring
                   ` (6 subsequent siblings)
  21 siblings, 0 replies; 49+ messages in thread
From: Rob Herring @ 2018-09-05 19:37 UTC (permalink / raw)
  To: devicetree, linux-kernel; +Cc: Yoshinori Sato, Rich Felker, linux-sh

Use the for_each_of_cpu_node iterator to iterate over cpu nodes. This
has the side effect of defaulting to iterating using "cpu" node names in
preference to the deprecated (for FDT) device_type == "cpu".

Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
Cc: linux-sh@vger.kernel.org
Signed-off-by: Rob Herring <robh@kernel.org>
---
Please ack and I will take via the DT tree. This is dependent on the
first 2 patches.

 arch/sh/boards/of-generic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sh/boards/of-generic.c b/arch/sh/boards/of-generic.c
index 26789ad28193..cde370cad4ae 100644
--- a/arch/sh/boards/of-generic.c
+++ b/arch/sh/boards/of-generic.c
@@ -64,7 +64,7 @@ static void sh_of_smp_probe(void)

 	init_cpu_possible(cpumask_of(0));

-	for_each_node_by_type(np, "cpu") {
+	for_each_of_cpu_node(np) {
 		const __be32 *cell = of_get_property(np, "reg", NULL);
 		u64 id = -1;
 		if (cell) id = of_read_number(cell, of_n_addr_cells(np));
--
2.17.1

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

* [PATCH 16/21] x86: DT: use for_each_of_cpu_node iterator
  2018-09-05 19:37 [PATCH 00/21] DT cpu node iterator Rob Herring
                   ` (14 preceding siblings ...)
  2018-09-05 19:37 ` [PATCH 15/21] SH: " Rob Herring
@ 2018-09-05 19:37 ` Rob Herring
  2018-09-06  8:15   ` Thomas Gleixner
  2018-09-05 19:37 ` [PATCH 17/21] clk: mvebu: " Rob Herring
                   ` (5 subsequent siblings)
  21 siblings, 1 reply; 49+ messages in thread
From: Rob Herring @ 2018-09-05 19:37 UTC (permalink / raw)
  To: devicetree, linux-kernel
  Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86

Use the for_each_of_cpu_node iterator to iterate over cpu nodes. This
has the side effect of defaulting to iterating using "cpu" node names in
preference to the deprecated (for FDT) device_type == "cpu".

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Signed-off-by: Rob Herring <robh@kernel.org>
---
Please ack and I will take via the DT tree. This is dependent on the
first 2 patches.

 arch/x86/kernel/devicetree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c
index f39f3a06c26f..7299dcbf8e85 100644
--- a/arch/x86/kernel/devicetree.c
+++ b/arch/x86/kernel/devicetree.c
@@ -140,7 +140,7 @@ static void __init dtb_cpu_setup(void)
 	int ret;

 	version = GET_APIC_VERSION(apic_read(APIC_LVR));
-	for_each_node_by_type(dn, "cpu") {
+	for_each_of_cpu_node(dn) {
 		ret = of_property_read_u32(dn, "reg", &apic_id);
 		if (ret < 0) {
 			pr_warn("%pOF: missing local APIC ID\n", dn);
--
2.17.1

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

* [PATCH 17/21] clk: mvebu: use for_each_of_cpu_node iterator
  2018-09-05 19:37 [PATCH 00/21] DT cpu node iterator Rob Herring
                   ` (15 preceding siblings ...)
  2018-09-05 19:37 ` [PATCH 16/21] x86: DT: " Rob Herring
@ 2018-09-05 19:37 ` Rob Herring
  2018-09-06  1:47   ` Stephen Boyd
  2018-09-05 19:37 ` [PATCH 18/21] edac: cpc925: " Rob Herring
                   ` (4 subsequent siblings)
  21 siblings, 1 reply; 49+ messages in thread
From: Rob Herring @ 2018-09-05 19:37 UTC (permalink / raw)
  To: devicetree, linux-kernel; +Cc: Michael Turquette, Stephen Boyd, linux-clk

Use the for_each_of_cpu_node iterator to iterate over cpu nodes. This
has the side effect of defaulting to iterating using "cpu" node names in
preference to the deprecated (for FDT) device_type == "cpu".

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: linux-clk@vger.kernel.org
Signed-off-by: Rob Herring <robh@kernel.org>
---
Please ack and I will take via the DT tree. This is dependent on the
first 2 patches.

 drivers/clk/mvebu/clk-cpu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/mvebu/clk-cpu.c b/drivers/clk/mvebu/clk-cpu.c
index 072aa38374ce..3045067448fb 100644
--- a/drivers/clk/mvebu/clk-cpu.c
+++ b/drivers/clk/mvebu/clk-cpu.c
@@ -183,7 +183,7 @@ static void __init of_cpu_clk_setup(struct device_node *node)
 		pr_warn("%s: pmu-dfs base register not set, dynamic frequency scaling not available\n",
 			__func__);

-	for_each_node_by_type(dn, "cpu")
+	for_each_of_cpu_node(dn)
 		ncpus++;

 	cpuclk = kcalloc(ncpus, sizeof(*cpuclk), GFP_KERNEL);
@@ -194,7 +194,7 @@ static void __init of_cpu_clk_setup(struct device_node *node)
 	if (WARN_ON(!clks))
 		goto clks_out;

-	for_each_node_by_type(dn, "cpu") {
+	for_each_of_cpu_node(dn) {
 		struct clk_init_data init;
 		struct clk *clk;
 		char *clk_name = kzalloc(5, GFP_KERNEL);
--
2.17.1

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

* [PATCH 18/21] edac: cpc925: use for_each_of_cpu_node iterator
  2018-09-05 19:37 [PATCH 00/21] DT cpu node iterator Rob Herring
                   ` (16 preceding siblings ...)
  2018-09-05 19:37 ` [PATCH 17/21] clk: mvebu: " Rob Herring
@ 2018-09-05 19:37 ` Rob Herring
  2018-09-06  8:35   ` Borislav Petkov
  2018-09-05 19:37 ` [PATCH 19/21] iommu: fsl_pamu: " Rob Herring
                   ` (3 subsequent siblings)
  21 siblings, 1 reply; 49+ messages in thread
From: Rob Herring @ 2018-09-05 19:37 UTC (permalink / raw)
  To: devicetree, linux-kernel
  Cc: Borislav Petkov, Mauro Carvalho Chehab, linux-edac

Use the for_each_of_cpu_node iterator to iterate over cpu nodes. This
has the side effect of defaulting to iterating using "cpu" node names in
preference to the deprecated (for FDT) device_type == "cpu".

Cc: Borislav Petkov <bp@alien8.de>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-edac@vger.kernel.org
Signed-off-by: Rob Herring <robh@kernel.org>
---
Please ack and I will take via the DT tree. This is dependent on the
first 2 patches.

 drivers/edac/cpc925_edac.c | 20 ++------------------
 1 file changed, 2 insertions(+), 18 deletions(-)

diff --git a/drivers/edac/cpc925_edac.c b/drivers/edac/cpc925_edac.c
index 2c98e020df05..3c0881ac9880 100644
--- a/drivers/edac/cpc925_edac.c
+++ b/drivers/edac/cpc925_edac.c
@@ -593,8 +593,7 @@ static void cpc925_mc_check(struct mem_ctl_info *mci)
 /******************** CPU err device********************************/
 static u32 cpc925_cpu_mask_disabled(void)
 {
-	struct device_node *cpus;
-	struct device_node *cpunode = NULL;
+	struct device_node *cpunode;
 	static u32 mask = 0;

 	/* use cached value if available */
@@ -603,20 +602,8 @@ static u32 cpc925_cpu_mask_disabled(void)

 	mask = APIMASK_ADI0 | APIMASK_ADI1;

-	cpus = of_find_node_by_path("/cpus");
-	if (cpus == NULL) {
-		cpc925_printk(KERN_DEBUG, "No /cpus node !\n");
-		return 0;
-	}
-
-	while ((cpunode = of_get_next_child(cpus, cpunode)) != NULL) {
+	for_each_of_cpu_node(cpunode) {
 		const u32 *reg = of_get_property(cpunode, "reg", NULL);
-
-		if (strcmp(cpunode->type, "cpu")) {
-			cpc925_printk(KERN_ERR, "Not a cpu node in /cpus: %s\n", cpunode->name);
-			continue;
-		}
-
 		if (reg == NULL || *reg > 2) {
 			cpc925_printk(KERN_ERR, "Bad reg value at %pOF\n", cpunode);
 			continue;
@@ -633,9 +620,6 @@ static u32 cpc925_cpu_mask_disabled(void)
 				"Assuming PI id is equal to CPU MPIC id!\n");
 	}

-	of_node_put(cpunode);
-	of_node_put(cpus);
-
 	return mask;
 }

--
2.17.1

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

* [PATCH 19/21] iommu: fsl_pamu: use for_each_of_cpu_node iterator
  2018-09-05 19:37 [PATCH 00/21] DT cpu node iterator Rob Herring
                   ` (17 preceding siblings ...)
  2018-09-05 19:37 ` [PATCH 18/21] edac: cpc925: " Rob Herring
@ 2018-09-05 19:37 ` Rob Herring
  2018-09-05 19:37 ` [PATCH 20/21] of: " Rob Herring
                   ` (2 subsequent siblings)
  21 siblings, 0 replies; 49+ messages in thread
From: Rob Herring @ 2018-09-05 19:37 UTC (permalink / raw)
  To: devicetree, linux-kernel; +Cc: Joerg Roedel, iommu

Use the for_each_of_cpu_node iterator to iterate over cpu nodes. This
has the side effect of defaulting to iterating using "cpu" node names in
preference to the deprecated (for FDT) device_type == "cpu".

Cc: Joerg Roedel <joro@8bytes.org>
Cc: iommu@lists.linux-foundation.org
Signed-off-by: Rob Herring <robh@kernel.org>
---
Please ack and I will take via the DT tree. This is dependent on the
first 2 patches.

 drivers/iommu/fsl_pamu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/fsl_pamu.c b/drivers/iommu/fsl_pamu.c
index 8540625796a1..1b955aea44dd 100644
--- a/drivers/iommu/fsl_pamu.c
+++ b/drivers/iommu/fsl_pamu.c
@@ -543,7 +543,7 @@ u32 get_stash_id(u32 stash_dest_hint, u32 vcpu)
 		return ~(u32)0;
 	}

-	for_each_node_by_type(node, "cpu") {
+	for_each_of_cpu_node(node) {
 		prop = of_get_property(node, "reg", &len);
 		for (i = 0; i < len / sizeof(u32); i++) {
 			if (be32_to_cpup(&prop[i]) == vcpu) {
--
2.17.1

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

* [PATCH 20/21] of: use for_each_of_cpu_node iterator
  2018-09-05 19:37 [PATCH 00/21] DT cpu node iterator Rob Herring
                   ` (18 preceding siblings ...)
  2018-09-05 19:37 ` [PATCH 19/21] iommu: fsl_pamu: " Rob Herring
@ 2018-09-05 19:37 ` Rob Herring
  2018-10-31 12:46   ` NXP P50XX/e5500 secondary CPUs not onlined with current mainline (was [PATCH 20/21] of: use for_each_of_cpu_node iterator) Michael Ellerman
  2018-09-05 19:37 ` [PATCH 21/21] fbdev: fsl-diu: get cpu node with of_get_cpu_node Rob Herring
       [not found] ` <CAHTX3d+BFKM-jFo8Ww_dXwAzsDVoWqE==erfwVTeijHfh8kkOw@mail.gmail.com>
  21 siblings, 1 reply; 49+ messages in thread
From: Rob Herring @ 2018-09-05 19:37 UTC (permalink / raw)
  To: devicetree, linux-kernel; +Cc: Frank Rowand

Use the for_each_of_cpu_node iterator to iterate over cpu nodes. This
has the side effect of defaulting to iterating using "cpu" node names in
preference to the deprecated (for FDT) device_type == "cpu".

Cc: Frank Rowand <frowand.list@gmail.com>
Cc: devicetree@vger.kernel.org
Signed-off-by: Rob Herring <robh@kernel.org>
---
Please ack and I will take via the DT tree. This is dependent on the
first 2 patches.

 drivers/of/base.c    |  2 +-
 drivers/of/of_numa.c | 15 ++-------------
 2 files changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 6389aeb2f48c..8285c07cab44 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -389,7 +389,7 @@ struct device_node *of_get_cpu_node(int cpu, unsigned int *thread)
 {
 	struct device_node *cpun;

-	for_each_node_by_type(cpun, "cpu") {
+	for_each_of_cpu_node(cpun) {
 		if (arch_find_n_match_cpu_physical_id(cpun, cpu, thread))
 			return cpun;
 	}
diff --git a/drivers/of/of_numa.c b/drivers/of/of_numa.c
index 27d9b4bba535..f165fe28f49d 100644
--- a/drivers/of/of_numa.c
+++ b/drivers/of/of_numa.c
@@ -24,18 +24,9 @@ static void __init of_numa_parse_cpu_nodes(void)
 {
 	u32 nid;
 	int r;
-	struct device_node *cpus;
-	struct device_node *np = NULL;
-
-	cpus = of_find_node_by_path("/cpus");
-	if (!cpus)
-		return;
-
-	for_each_child_of_node(cpus, np) {
-		/* Skip things that are not CPUs */
-		if (of_node_cmp(np->type, "cpu") != 0)
-			continue;
+	struct device_node *np;

+	for_each_of_cpu_node(np) {
 		r = of_property_read_u32(np, "numa-node-id", &nid);
 		if (r)
 			continue;
@@ -46,8 +37,6 @@ static void __init of_numa_parse_cpu_nodes(void)
 		else
 			node_set(nid, numa_nodes_parsed);
 	}
-
-	of_node_put(cpus);
 }

 static int __init of_numa_parse_memory_nodes(void)
--
2.17.1

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

* [PATCH 21/21] fbdev: fsl-diu: get cpu node with of_get_cpu_node
  2018-09-05 19:37 [PATCH 00/21] DT cpu node iterator Rob Herring
                   ` (19 preceding siblings ...)
  2018-09-05 19:37 ` [PATCH 20/21] of: " Rob Herring
@ 2018-09-05 19:37 ` Rob Herring
  2018-09-11  3:34   ` Timur Tabi
       [not found] ` <CAHTX3d+BFKM-jFo8Ww_dXwAzsDVoWqE==erfwVTeijHfh8kkOw@mail.gmail.com>
  21 siblings, 1 reply; 49+ messages in thread
From: Rob Herring @ 2018-09-05 19:37 UTC (permalink / raw)
  To: devicetree, linux-kernel
  Cc: Timur Tabi, Bartlomiej Zolnierkiewicz, linux-fbdev, dri-devel

"device_type" use is deprecated for FDT though it has continued to be used
for nodes like cpu nodes. Use of_get_cpu_node() instead which works using
node names by default. This will allow the eventually removal of cpu
device_type properties.

Cc: Timur Tabi <timur@kernel.org>
Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Cc: linux-fbdev@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Rob Herring <robh@kernel.org>
---
Please ack and I will take via the DT tree. This is dependent on the
first 2 patches.

 drivers/video/fbdev/fsl-diu-fb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/fsl-diu-fb.c b/drivers/video/fbdev/fsl-diu-fb.c
index bc9eb8afc313..332a56b6811f 100644
--- a/drivers/video/fbdev/fsl-diu-fb.c
+++ b/drivers/video/fbdev/fsl-diu-fb.c
@@ -1925,7 +1925,7 @@ static int __init fsl_diu_init(void)
 	pr_info("Freescale Display Interface Unit (DIU) framebuffer driver\n");

 #ifdef CONFIG_NOT_COHERENT_CACHE
-	np = of_find_node_by_type(NULL, "cpu");
+	np = of_get_cpu_node(0, NULL);
 	if (!np) {
 		pr_err("fsl-diu-fb: can't find 'cpu' device node\n");
 		return -ENODEV;
--
2.17.1

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

* Re: [PATCH 17/21] clk: mvebu: use for_each_of_cpu_node iterator
  2018-09-05 19:37 ` [PATCH 17/21] clk: mvebu: " Rob Herring
@ 2018-09-06  1:47   ` Stephen Boyd
  0 siblings, 0 replies; 49+ messages in thread
From: Stephen Boyd @ 2018-09-06  1:47 UTC (permalink / raw)
  To: Rob Herring, devicetree, linux-kernel; +Cc: Michael Turquette, linux-clk

Quoting Rob Herring (2018-09-05 12:37:34)
> Use the for_each_of_cpu_node iterator to iterate over cpu nodes. This
> has the side effect of defaulting to iterating using "cpu" node names in
> preference to the deprecated (for FDT) device_type == "cpu".
> 
> Cc: Michael Turquette <mturquette@baylibre.com>
> Cc: Stephen Boyd <sboyd@kernel.org>
> Cc: linux-clk@vger.kernel.org
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---

Acked-by: Stephen Boyd <sboyd@kernel.org>


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

* Re: [PATCH 16/21] x86: DT: use for_each_of_cpu_node iterator
  2018-09-05 19:37 ` [PATCH 16/21] x86: DT: " Rob Herring
@ 2018-09-06  8:15   ` Thomas Gleixner
  0 siblings, 0 replies; 49+ messages in thread
From: Thomas Gleixner @ 2018-09-06  8:15 UTC (permalink / raw)
  To: Rob Herring; +Cc: devicetree, linux-kernel, Ingo Molnar, H. Peter Anvin, x86

On Wed, 5 Sep 2018, Rob Herring wrote:

> Use the for_each_of_cpu_node iterator to iterate over cpu nodes. This
> has the side effect of defaulting to iterating using "cpu" node names in
> preference to the deprecated (for FDT) device_type == "cpu".
> 
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> Cc: x86@kernel.org
> Signed-off-by: Rob Herring <robh@kernel.org>

Reviewed-by: Thomas Gleixner <tglx@linutronix.de>

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

* Re: [PATCH 18/21] edac: cpc925: use for_each_of_cpu_node iterator
  2018-09-05 19:37 ` [PATCH 18/21] edac: cpc925: " Rob Herring
@ 2018-09-06  8:35   ` Borislav Petkov
  2018-09-06 11:12     ` Rob Herring
  0 siblings, 1 reply; 49+ messages in thread
From: Borislav Petkov @ 2018-09-06  8:35 UTC (permalink / raw)
  To: Rob Herring; +Cc: devicetree, linux-kernel, Mauro Carvalho Chehab, linux-edac

On Wed, Sep 05, 2018 at 02:37:35PM -0500, Rob Herring wrote:
> Use the for_each_of_cpu_node iterator to iterate over cpu nodes. This
> has the side effect of defaulting to iterating using "cpu" node names in
> preference to the deprecated (for FDT) device_type == "cpu".
> 
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> Cc: linux-edac@vger.kernel.org
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---
> Please ack and I will take via the DT tree. This is dependent on the
> first 2 patches.

Completely unknown territory for me so I'd trust your judgement. Staring
at 1/21, the conversion looks ok except the removal of those prints that
a cpu nodes are not present - I wonder if they even meant anything or
were just there during driver development...

>  drivers/edac/cpc925_edac.c | 20 ++------------------
>  1 file changed, 2 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/edac/cpc925_edac.c b/drivers/edac/cpc925_edac.c
> index 2c98e020df05..3c0881ac9880 100644
> --- a/drivers/edac/cpc925_edac.c
> +++ b/drivers/edac/cpc925_edac.c
> @@ -593,8 +593,7 @@ static void cpc925_mc_check(struct mem_ctl_info *mci)
>  /******************** CPU err device********************************/
>  static u32 cpc925_cpu_mask_disabled(void)
>  {
> -	struct device_node *cpus;
> -	struct device_node *cpunode = NULL;
> +	struct device_node *cpunode;
>  	static u32 mask = 0;
> 
>  	/* use cached value if available */
> @@ -603,20 +602,8 @@ static u32 cpc925_cpu_mask_disabled(void)
> 
>  	mask = APIMASK_ADI0 | APIMASK_ADI1;
> 
> -	cpus = of_find_node_by_path("/cpus");
> -	if (cpus == NULL) {
> -		cpc925_printk(KERN_DEBUG, "No /cpus node !\n");

This thing...

> -		return 0;
> -	}
> -
> -	while ((cpunode = of_get_next_child(cpus, cpunode)) != NULL) {
> +	for_each_of_cpu_node(cpunode) {
>  		const u32 *reg = of_get_property(cpunode, "reg", NULL);
> -
> -		if (strcmp(cpunode->type, "cpu")) {
> -			cpc925_printk(KERN_ERR, "Not a cpu node in /cpus: %s\n", cpunode->name);

... and this thing.

Thx.

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

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

* Re: [PATCH 01/21] of: Add cpu node iterator for_each_of_cpu_node()
  2018-09-05 19:37 ` [PATCH 01/21] of: Add cpu node iterator for_each_of_cpu_node() Rob Herring
@ 2018-09-06  8:45   ` Geert Uytterhoeven
  2018-10-30 14:18   ` Michael Ellerman
  1 sibling, 0 replies; 49+ messages in thread
From: Geert Uytterhoeven @ 2018-09-06  8:45 UTC (permalink / raw)
  To: Rob Herring
  Cc: open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Linux Kernel Mailing List, Frank Rowand

On Wed, Sep 5, 2018 at 9:38 PM Rob Herring <robh@kernel.org> wrote:
> Iterating thru cpu nodes is a common pattern. Create a common iterator
> which can find child nodes either by node name or device_type == cpu.
> Using the former will allow for eventually dropping device_type
> properties which are deprecated for FDT.
>
> Cc: Frank Rowand <frowand.list@gmail.com>
> Signed-off-by: Rob Herring <robh@kernel.org>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH 05/21] ARM: shmobile: use for_each_of_cpu_node iterator
  2018-09-05 19:37 ` [PATCH 05/21] ARM: shmobile: use for_each_of_cpu_node iterator Rob Herring
@ 2018-09-06  8:52   ` Geert Uytterhoeven
  2018-09-06  8:56   ` Simon Horman
  1 sibling, 0 replies; 49+ messages in thread
From: Geert Uytterhoeven @ 2018-09-06  8:52 UTC (permalink / raw)
  To: Rob Herring
  Cc: open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Linux Kernel Mailing List, Simon Horman, Magnus Damm,
	Russell King, Linux ARM, Linux-Renesas

On Wed, Sep 5, 2018 at 9:38 PM Rob Herring <robh@kernel.org> wrote:
> Use the for_each_of_cpu_node iterator to iterate over cpu nodes. This
> has the side effect of defaulting to iterating using "cpu" node names in
> preference to the deprecated (for FDT) device_type == "cpu".
>
> Cc: Simon Horman <horms@verge.net.au>
> Cc: Magnus Damm <magnus.damm@gmail.com>
> Cc: Russell King <linux@armlinux.org.uk>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-renesas-soc@vger.kernel.org
> Signed-off-by: Rob Herring <robh@kernel.org>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH 05/21] ARM: shmobile: use for_each_of_cpu_node iterator
  2018-09-05 19:37 ` [PATCH 05/21] ARM: shmobile: use for_each_of_cpu_node iterator Rob Herring
  2018-09-06  8:52   ` Geert Uytterhoeven
@ 2018-09-06  8:56   ` Simon Horman
  1 sibling, 0 replies; 49+ messages in thread
From: Simon Horman @ 2018-09-06  8:56 UTC (permalink / raw)
  To: Rob Herring
  Cc: devicetree, linux-kernel, Magnus Damm, Russell King,
	linux-arm-kernel, linux-renesas-soc

On Wed, Sep 05, 2018 at 02:37:22PM -0500, Rob Herring wrote:
> Use the for_each_of_cpu_node iterator to iterate over cpu nodes. This
> has the side effect of defaulting to iterating using "cpu" node names in
> preference to the deprecated (for FDT) device_type == "cpu".
> 
> Cc: Simon Horman <horms@verge.net.au>
> Cc: Magnus Damm <magnus.damm@gmail.com>
> Cc: Russell King <linux@armlinux.org.uk>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-renesas-soc@vger.kernel.org
> Signed-off-by: Rob Herring <robh@kernel.org>

Reviewed-by: Simon Horman <horms+renesas@verge.net.au>


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

* Re: [PATCH 10/21] openrisc: use for_each_of_cpu_node iterator
  2018-09-05 19:37 ` [PATCH 10/21] openrisc: use for_each_of_cpu_node iterator Rob Herring
@ 2018-09-06  9:12   ` Stafford Horne
  0 siblings, 0 replies; 49+ messages in thread
From: Stafford Horne @ 2018-09-06  9:12 UTC (permalink / raw)
  To: Rob Herring
  Cc: devicetree, linux-kernel, Jonas Bonn, Stefan Kristiansson, openrisc

On Wed, Sep 05, 2018 at 02:37:27PM -0500, Rob Herring wrote:
> Use the for_each_of_cpu_node iterator to iterate over cpu nodes. This
> has the side effect of defaulting to iterating using "cpu" node names in
> preference to the deprecated (for FDT) device_type == "cpu".
> 
> This also fixes a leaked reference for cpus node.
> 
> Cc: Jonas Bonn <jonas@southpole.se>
> Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
> Cc: Stafford Horne <shorne@gmail.com>
> Cc: openrisc@lists.librecores.org
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---
> Please ack and I will take via the DT tree. This is dependent on the
> first 2 patches.
> 
>  arch/openrisc/kernel/setup.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/arch/openrisc/kernel/setup.c b/arch/openrisc/kernel/setup.c
> index 9d28ab14d139..e17fcd83120f 100644
> --- a/arch/openrisc/kernel/setup.c
> +++ b/arch/openrisc/kernel/setup.c
> @@ -158,9 +158,8 @@ static struct device_node *setup_find_cpu_node(int cpu)
>  {
>  	u32 hwid;
>  	struct device_node *cpun;
> -	struct device_node *cpus = of_find_node_by_path("/cpus");
> 
> -	for_each_available_child_of_node(cpus, cpun) {
> +	for_each_of_cpu_node(cpun) {
>  		if (of_property_read_u32(cpun, "reg", &hwid))
>  			continue;
>  		if (hwid == cpu)

This looks fine to me.  Thanks Rob

Acked-by: Stafford Horne <shorne@gmail.com>


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

* Re: [PATCH 06/21] arm64: use for_each_of_cpu_node iterator
  2018-09-05 19:37 ` [PATCH 06/21] arm64: " Rob Herring
@ 2018-09-06 10:04   ` Will Deacon
  0 siblings, 0 replies; 49+ messages in thread
From: Will Deacon @ 2018-09-06 10:04 UTC (permalink / raw)
  To: Rob Herring; +Cc: devicetree, linux-kernel, Catalin Marinas, linux-arm-kernel

On Wed, Sep 05, 2018 at 02:37:23PM -0500, Rob Herring wrote:
> Use the for_each_of_cpu_node iterator to iterate over cpu nodes. This
> has the side effect of defaulting to iterating using "cpu" node names in
> preference to the deprecated (for FDT) device_type == "cpu".
> 
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: linux-arm-kernel@lists.infradead.org
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---
> Please ack and I will take via the DT tree. This is dependent on the
> first 2 patches.

Acked-by: Will Deacon <will.deacon@arm.com>

Will

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

* Re: [PATCH 18/21] edac: cpc925: use for_each_of_cpu_node iterator
  2018-09-06  8:35   ` Borislav Petkov
@ 2018-09-06 11:12     ` Rob Herring
  2018-09-06 12:20       ` Borislav Petkov
  0 siblings, 1 reply; 49+ messages in thread
From: Rob Herring @ 2018-09-06 11:12 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: devicetree, linux-kernel, Mauro Carvalho Chehab, linux-edac

On Thu, Sep 6, 2018 at 3:35 AM Borislav Petkov <bp@alien8.de> wrote:
>
> On Wed, Sep 05, 2018 at 02:37:35PM -0500, Rob Herring wrote:
> > Use the for_each_of_cpu_node iterator to iterate over cpu nodes. This
> > has the side effect of defaulting to iterating using "cpu" node names in
> > preference to the deprecated (for FDT) device_type == "cpu".
> >
> > Cc: Borislav Petkov <bp@alien8.de>
> > Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> > Cc: linux-edac@vger.kernel.org
> > Signed-off-by: Rob Herring <robh@kernel.org>
> > ---
> > Please ack and I will take via the DT tree. This is dependent on the
> > first 2 patches.
>
> Completely unknown territory for me so I'd trust your judgement. Staring
> at 1/21, the conversion looks ok except the removal of those prints that
> a cpu nodes are not present - I wonder if they even meant anything or
> were just there during driver development...

I should have noted this. It's not the kernel's job to validate the DT
and certainly not some driver's job to validate cpu nodes. It's bad
enough that some random driver is parsing cpu nodes. If they are
missing or are crap, you should get warnings or messages well before
this point.

Rob

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

* Re: [PATCH 18/21] edac: cpc925: use for_each_of_cpu_node iterator
  2018-09-06 11:12     ` Rob Herring
@ 2018-09-06 12:20       ` Borislav Petkov
  0 siblings, 0 replies; 49+ messages in thread
From: Borislav Petkov @ 2018-09-06 12:20 UTC (permalink / raw)
  To: Rob Herring; +Cc: devicetree, linux-kernel, Mauro Carvalho Chehab, linux-edac

On Thu, Sep 06, 2018 at 06:12:51AM -0500, Rob Herring wrote:
> I should have noted this. It's not the kernel's job to validate the DT
> and certainly not some driver's job to validate cpu nodes. It's bad
> enough that some random driver is parsing cpu nodes. If they are
> missing or are crap, you should get warnings or messages well before
> this point.

That is useful info for the commit message, I'd say.

In any case:

Acked-by: Borislav Petkov <bp@suse.de>

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

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

* Re: [PATCH 00/21] DT cpu node iterator
       [not found] ` <CAHTX3d+BFKM-jFo8Ww_dXwAzsDVoWqE==erfwVTeijHfh8kkOw@mail.gmail.com>
@ 2018-09-07 13:58   ` Rob Herring
  0 siblings, 0 replies; 49+ messages in thread
From: Rob Herring @ 2018-09-07 13:58 UTC (permalink / raw)
  To: Michal Simek
  Cc: devicetree, linux-kernel, Frank Rowand, Russell King, Albert Ou,
	Aurelien Jacquiot, Bartlomiej Zolnierkiewicz,
	Benjamin Herrenschmidt, Borislav Petkov, Catalin Marinas,
	dri-devel, H. Peter Anvin, Ingo Molnar, Linux IOMMU,
	Joerg Roedel, Jonas Bonn, Ley Foon Tan, Magnus Damm, Mark Salter,
	Mauro Carvalho Chehab, Michael Ellerman, nios2-dev, Openrisc,
	Palmer Dabbelt, Rich Felker, Simon Horman, Stafford Horne,
	Stefan Kristiansson, Stephen Boyd, Thomas Gleixner, vitb,
	Will Deacon, Yoshinori Sato,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	linux-c6x-dev, linux-clk, linux-edac, linux-fbdev, linuxppc-dev,
	open list:MEDIA DRIVERS FOR RENESAS - FCP, linux-riscv, SH-Linux

On Fri, Sep 7, 2018 at 7:54 AM Michal Simek <monstr@monstr.eu> wrote:
>
> Hi Rob,
>
> 2018-09-05 21:37 GMT+02:00 Rob Herring <robh@kernel.org>:
>>
>> This series adds an iterator for cpu nodes and converts users over to use
>> it or of_get_cpu_node in some cases. This allows us to remove the
>> dependency on device_type property for cpu nodes though removing that
>> from DTS files will have to wait for some time. In some cases, this makes
>> the DT search more strict by only looking in /cpus child nodes rather
>> than any node with the device_type == cpu. The iterator also honors the
>> status property which is often forgotten.
>>
>> I've only tested on ARM under QEMU and compiled powerpc.
>
>
>
> Do you have this somewhere in your tree not to apply 21 patches by hand?

Yes, dt/cpu-type branch on my kernel.org tree.

Rob

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

* Re: [PATCH 14/21] riscv: use for_each_of_cpu_node iterator
  2018-09-05 19:37 ` [PATCH 14/21] riscv: use for_each_of_cpu_node iterator Rob Herring
@ 2018-09-10 13:37   ` Christoph Hellwig
  2018-09-10 13:51     ` Rob Herring
  2018-09-18 22:53   ` Palmer Dabbelt
  1 sibling, 1 reply; 49+ messages in thread
From: Christoph Hellwig @ 2018-09-10 13:37 UTC (permalink / raw)
  To: Rob Herring
  Cc: devicetree, linux-kernel, linux-riscv, Palmer Dabbelt, Albert Ou

On Wed, Sep 05, 2018 at 02:37:31PM -0500, Rob Herring wrote:
> Use the for_each_of_cpu_node iterator to iterate over cpu nodes. This
> has the side effect of defaulting to iterating using "cpu" node names in
> preference to the deprecated (for FDT) device_type == "cpu".
> 
> Cc: Palmer Dabbelt <palmer@sifive.com>
> Cc: Albert Ou <aou@eecs.berkeley.edu>
> Cc: linux-riscv@lists.infradead.org
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---
> Please ack and I will take via the DT tree. This is dependent on the
> first 2 patches.

We have a few pending patches in this area that look like they might
conflict.  It might be worth to delay this one and apply it post -rc1
to avoid dependencies if that isn't a problem for you.

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

* Re: [PATCH 14/21] riscv: use for_each_of_cpu_node iterator
  2018-09-10 13:37   ` Christoph Hellwig
@ 2018-09-10 13:51     ` Rob Herring
  0 siblings, 0 replies; 49+ messages in thread
From: Rob Herring @ 2018-09-10 13:51 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: devicetree, linux-kernel, linux-riscv, Palmer Dabbelt, Albert Ou

On Mon, Sep 10, 2018 at 8:38 AM Christoph Hellwig <hch@infradead.org> wrote:
>
> On Wed, Sep 05, 2018 at 02:37:31PM -0500, Rob Herring wrote:
> > Use the for_each_of_cpu_node iterator to iterate over cpu nodes. This
> > has the side effect of defaulting to iterating using "cpu" node names in
> > preference to the deprecated (for FDT) device_type == "cpu".
> >
> > Cc: Palmer Dabbelt <palmer@sifive.com>
> > Cc: Albert Ou <aou@eecs.berkeley.edu>
> > Cc: linux-riscv@lists.infradead.org
> > Signed-off-by: Rob Herring <robh@kernel.org>
> > ---
> > Please ack and I will take via the DT tree. This is dependent on the
> > first 2 patches.
>
> We have a few pending patches in this area that look like they might
> conflict.  It might be worth to delay this one and apply it post -rc1
> to avoid dependencies if that isn't a problem for you.

Sure. That's fine.

Rob

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

* Re: [PATCH 08/21] microblaze: get cpu node with of_get_cpu_node
  2018-09-05 19:37 ` [PATCH 08/21] microblaze: get cpu node with of_get_cpu_node Rob Herring
@ 2018-09-10 14:56   ` Michal Simek
  2018-09-10 20:49     ` Rob Herring
  0 siblings, 1 reply; 49+ messages in thread
From: Michal Simek @ 2018-09-10 14:56 UTC (permalink / raw)
  To: Rob Herring, devicetree, linux-kernel

On 5.9.2018 21:37, Rob Herring wrote:
> "device_type" use is deprecated for FDT though it has continued to be used
> for nodes like cpu nodes. Use of_get_cpu_node() instead which works using
> node names by default. This will allow the eventually removal of cpu
> device_type properties.
> 
> Also, fix a leaked reference by adding a missing of_node_put.
> 
> Cc: Michal Simek <monstr@monstr.eu>
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---
> Please ack and I will take via the DT tree. This is dependent on the
> first 2 patches.

I have tested it and it is align with the spec and all dtses generated
before 2015 will work without any issue.
In 2015 new device tree generator was introduced and it is not adding
reg property to cpu node which is required by this change.
This will be fixed but that means that all generated dtses from 2015 are
affected.

That's why will be great if you can also change that pr_err message to
mentioned to also check reg property to give users a chance to fix it
properly. Error log below.

Anyway here is my
Tested-by: Michal Simek <michal.simek@xilinx.com>

Thanks,
Michal


[    0.000000] Ramdisk addr 0x00000000,
[    0.000000] Compiled-in FDT at (ptrval)
[    0.000000] Linux version 4.19.0-rc2-00010-gf9a96b0ac503
(monstr@monstr-desktop2) (gcc version 4.9.2 (crosstool-NG 1.20.0)) #4
Mon Sep 10 16:31:14 CEST 2018
[    0.000000] setup_memory: max_mapnr: 0x40000
[    0.000000] setup_memory: min_low_pfn: 0x80000
[    0.000000] setup_memory: max_low_pfn: 0xb0000
[    0.000000] setup_memory: max_pfn: 0xc0000
[    0.000000] Zone ranges:
[    0.000000]   DMA      [mem 0x0000000080000000-0x00000000afffffff]
[    0.000000]   Normal   empty
[    0.000000]   HighMem  [mem 0x00000000b0000000-0x00000000bfffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000080000000-0x00000000bfffffff]
[    0.000000] Initmem setup node 0 [mem
0x0000000080000000-0x00000000bfffffff]
[    0.000000] earlycon: ns16550a0 at MMIO 0x44a01000 (options '')
[    0.000000] bootconsole [ns16550a0] enabled
[    0.000000] You don't have cpu!!!
[    0.000000] setup_cpuinfo: initialising
[    0.000000] setup_cpuinfo: Using full CPU PVR support
[    0.000000] ERROR: Microblaze BARREL, MSR, PCMP or DIV-different for
PVR and DTS
[    0.000000] ERROR: Microblaze HW_MUL-different for PVR and DTS
[    0.000000] wt_msr_noirq
[    0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[    0.000000] pcpu-alloc: [0] 0
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 260608
[    0.000000] Kernel command line: console=ttyS0,115200 earlycon
[    0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288
bytes)
[    0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144
bytes)
[    0.000000] Memory: 1027496K/1048576K available (4270K kernel code,
153K rwdata, 1256K rodata, 4989K init, 561K bss, 21080K reserved, 0K
cma-reserved, 262144K highmem)
[    0.000000] Kernel virtual memory layout:
[    0.000000]   * 0xfffea000..0xfffff000  : fixmap
[    0.000000]   * 0xff800000..0xffc00000  : highmem PTEs
[    0.000000]   * 0xff7ff000..0xff800000  : early ioremap
[    0.000000]   * 0xf0000000..0xff7ff000  : vmalloc & ioremap
[    0.000000] NR_IRQS: 33
[    0.000000] irq-xilinx: /amba_pl/interrupt-controller@41200000:
num_irq=6, edge=0x0
[    0.000000] Oops: kernel access of bad area, sig: 11
[    0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted
4.19.0-rc2-00010-gf9a96b0ac503 #4
[    0.000000]  Registers dump: mode=80571E90
[    0.000000]  r1=C028BD54, r2=C056FAB6, r3=00000000, r4=00000010
[    0.000000]  r5=00000000, r6=C0495348, r7=C0495350, r8=00000000
[    0.000000]  r9=C0571F44, r10=EF002400, r11=00000030, r12=00000000
[    0.000000]  r13=410C2FC0, r14=C0496688, r15=C02831F0, r16=00000000
[    0.000000]  r17=C02831EC, r18=FFFFFFFF, r19=C05BABE0, r20=BFFEC168
[    0.000000]  r21=BFFEC168, r22=EF7F9A80, r23=00000000, r24=00000000
[    0.000000]  r25=BFE6B84C, r26=80000000, r27=00000001, r28=90000040
[    0.000000]  r29=01000000, r30=00000380, r31=C05782E8, rPC=C02831EC
[    0.000000]  msr=000046A0, ear=0000000C, esr=00001A72, fsr=000065A0
[    0.000000] Kernel panic - not syncing: Attempted to kill the idle task!
[    0.000000] ---[ end Kernel panic - not syncing: Attempted to kill
the idle task! ]---

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

* Re: [PATCH 08/21] microblaze: get cpu node with of_get_cpu_node
  2018-09-10 14:56   ` Michal Simek
@ 2018-09-10 20:49     ` Rob Herring
  2018-09-11 12:15       ` Michal Simek
  0 siblings, 1 reply; 49+ messages in thread
From: Rob Herring @ 2018-09-10 20:49 UTC (permalink / raw)
  To: Michal Simek; +Cc: devicetree, linux-kernel

On Mon, Sep 10, 2018 at 9:56 AM Michal Simek <michal.simek@xilinx.com> wrote:
>
> On 5.9.2018 21:37, Rob Herring wrote:
> > "device_type" use is deprecated for FDT though it has continued to be used
> > for nodes like cpu nodes. Use of_get_cpu_node() instead which works using
> > node names by default. This will allow the eventually removal of cpu
> > device_type properties.
> >
> > Also, fix a leaked reference by adding a missing of_node_put.
> >
> > Cc: Michal Simek <monstr@monstr.eu>
> > Signed-off-by: Rob Herring <robh@kernel.org>
> > ---
> > Please ack and I will take via the DT tree. This is dependent on the
> > first 2 patches.
>
> I have tested it and it is align with the spec and all dtses generated
> before 2015 will work without any issue.
> In 2015 new device tree generator was introduced and it is not adding
> reg property to cpu node which is required by this change.
> This will be fixed but that means that all generated dtses from 2015 are
> affected.

Patch 2 was supposed to handle that case. However, it does expect that
there should be an #address-cells equal to 0 in that case. Is that not
a valid assumption?

> That's why will be great if you can also change that pr_err message to
> mentioned to also check reg property to give users a chance to fix it
> properly. Error log below.

I don't think breaking users is good.

I could make this a find by path (/cpus/cpu) instead or just drop it
for microblaze. It doesn't really affect my plans for removing
device_node.type ptr.

Rob


> Anyway here is my
> Tested-by: Michal Simek <michal.simek@xilinx.com>
>
> Thanks,
> Michal

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

* Re: [PATCH 21/21] fbdev: fsl-diu: get cpu node with of_get_cpu_node
  2018-09-05 19:37 ` [PATCH 21/21] fbdev: fsl-diu: get cpu node with of_get_cpu_node Rob Herring
@ 2018-09-11  3:34   ` Timur Tabi
  0 siblings, 0 replies; 49+ messages in thread
From: Timur Tabi @ 2018-09-11  3:34 UTC (permalink / raw)
  To: Rob Herring, devicetree, linux-kernel
  Cc: Bartlomiej Zolnierkiewicz, linux-fbdev, dri-devel

On 9/5/18 2:37 PM, Rob Herring wrote:
>   #ifdef CONFIG_NOT_COHERENT_CACHE
> -	np = of_find_node_by_type(NULL, "cpu");
> +	np = of_get_cpu_node(0, NULL);

This #ifdef means that it's only compiled on an MPC5121, which is a very 
dead platform.  of_get_cpu_node() looks okay to me, but I'm going to 
have to assume that you know what you're doing.

Acked-by: Timur Tabi <timur@kernel.org>

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

* Re: [PATCH 08/21] microblaze: get cpu node with of_get_cpu_node
  2018-09-10 20:49     ` Rob Herring
@ 2018-09-11 12:15       ` Michal Simek
  0 siblings, 0 replies; 49+ messages in thread
From: Michal Simek @ 2018-09-11 12:15 UTC (permalink / raw)
  To: Rob Herring, Michal Simek; +Cc: devicetree, linux-kernel

On 10.9.2018 22:49, Rob Herring wrote:
> On Mon, Sep 10, 2018 at 9:56 AM Michal Simek <michal.simek@xilinx.com> wrote:
>>
>> On 5.9.2018 21:37, Rob Herring wrote:
>>> "device_type" use is deprecated for FDT though it has continued to be used
>>> for nodes like cpu nodes. Use of_get_cpu_node() instead which works using
>>> node names by default. This will allow the eventually removal of cpu
>>> device_type properties.
>>>
>>> Also, fix a leaked reference by adding a missing of_node_put.
>>>
>>> Cc: Michal Simek <monstr@monstr.eu>
>>> Signed-off-by: Rob Herring <robh@kernel.org>
>>> ---
>>> Please ack and I will take via the DT tree. This is dependent on the
>>> first 2 patches.
>>
>> I have tested it and it is align with the spec and all dtses generated
>> before 2015 will work without any issue.
>> In 2015 new device tree generator was introduced and it is not adding
>> reg property to cpu node which is required by this change.
>> This will be fixed but that means that all generated dtses from 2015 are
>> affected.
> 
> Patch 2 was supposed to handle that case. However, it does expect that
> there should be an #address-cells equal to 0 in that case. Is that not
> a valid assumption?

as you can expect we have

#address-cells = <0x1>;
#cpus = <0x1>;
#size-cells = <0x0>;
cpu@0 {
	/* no reg property */
};

That missing reg property was even reported by dtc but none has fixed
that. This will be fixed for xilinx releases.


>> That's why will be great if you can also change that pr_err message to
>> mentioned to also check reg property to give users a chance to fix it
>> properly. Error log below.
> 
> I don't think breaking users is good.
> 
> I could make this a find by path (/cpus/cpu) instead or just drop it
> for microblaze. It doesn't really affect my plans for removing
> device_node.type ptr.

If this is fine for you that will be the best solution.

Thanks,
Michal

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

* Re: [PATCH 14/21] riscv: use for_each_of_cpu_node iterator
  2018-09-05 19:37 ` [PATCH 14/21] riscv: use for_each_of_cpu_node iterator Rob Herring
  2018-09-10 13:37   ` Christoph Hellwig
@ 2018-09-18 22:53   ` Palmer Dabbelt
  1 sibling, 0 replies; 49+ messages in thread
From: Palmer Dabbelt @ 2018-09-18 22:53 UTC (permalink / raw)
  To: robh; +Cc: devicetree, linux-kernel, aou, linux-riscv

On Wed, 05 Sep 2018 12:37:31 PDT (-0700), robh@kernel.org wrote:
> Use the for_each_of_cpu_node iterator to iterate over cpu nodes. This
> has the side effect of defaulting to iterating using "cpu" node names in
> preference to the deprecated (for FDT) device_type == "cpu".
>
> Cc: Palmer Dabbelt <palmer@sifive.com>
> Cc: Albert Ou <aou@eecs.berkeley.edu>
> Cc: linux-riscv@lists.infradead.org
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---
> Please ack and I will take via the DT tree. This is dependent on the
> first 2 patches.
>
>  arch/riscv/kernel/smpboot.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c
> index 56abab6a9812..3c59afe67951 100644
> --- a/arch/riscv/kernel/smpboot.c
> +++ b/arch/riscv/kernel/smpboot.c
> @@ -52,7 +52,7 @@ void __init setup_smp(void)
>  	struct device_node *dn = NULL;
>  	int hart, im_okay_therefore_i_am = 0;
>
> -	while ((dn = of_find_node_by_type(dn, "cpu"))) {
> +	for_each_of_cpu_node(dn) {
>  		hart = riscv_of_processor_hart(dn);
>  		if (hart >= 0) {
>  			set_cpu_possible(hart, true);

Acked-by: Palmer Dabbelt <palmer@sifive.com>

Thanks!

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

* Re: [PATCH 01/21] of: Add cpu node iterator for_each_of_cpu_node()
  2018-09-05 19:37 ` [PATCH 01/21] of: Add cpu node iterator for_each_of_cpu_node() Rob Herring
  2018-09-06  8:45   ` Geert Uytterhoeven
@ 2018-10-30 14:18   ` Michael Ellerman
  2018-10-30 14:20     ` Michael Ellerman
  1 sibling, 1 reply; 49+ messages in thread
From: Michael Ellerman @ 2018-10-30 14:18 UTC (permalink / raw)
  To: Rob Herring, devicetree, linux-kernel, linuxppc-dev; +Cc: Frank Rowand

Hi Rob,

Sorry I missed this when you posted it.

Rob Herring <robh@kernel.org> writes:
> Iterating thru cpu nodes is a common pattern. Create a common iterator
> which can find child nodes either by node name or device_type == cpu.
> Using the former will allow for eventually dropping device_type
> properties which are deprecated for FDT.

Device trees we see on powerpc generally don't (never?) use "cpu" as the
node name for CPU nodes. And many of those device trees come from
firmware, so we can't update them.

So dropping support for device_type is a non-starter from our POV.

cheers

> Cc: Frank Rowand <frowand.list@gmail.com>
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---
>  drivers/of/base.c  | 39 +++++++++++++++++++++++++++++++++++++++
>  include/linux/of.h | 11 +++++++++++
>  2 files changed, 50 insertions(+)
>
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index a055cd1ef96d..4807db0a35b3 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -741,6 +741,45 @@ struct device_node *of_get_next_available_child(const struct device_node *node,
>  }
>  EXPORT_SYMBOL(of_get_next_available_child);
>
> +/**
> + *	of_get_next_cpu_node - Iterate on cpu nodes
> + *	@prev:	previous child of the /cpus node, or NULL to get first
> + *
> + *	Returns a cpu node pointer with refcount incremented, use of_node_put()
> + *	on it when done. Returns NULL when prev is the last child. Decrements
> + *	the refcount of prev.
> + */
> +struct device_node *of_get_next_cpu_node(struct device_node *prev)
> +{
> +	struct device_node *next = NULL;
> +	unsigned long flags;
> +	struct device_node *node;
> +
> +	if (!prev)
> +		node = of_find_node_by_path("/cpus");
> +
> +	raw_spin_lock_irqsave(&devtree_lock, flags);
> +	if (prev)
> +		next = prev->sibling;
> +	else if (node) {
> +		next = node->child;
> +		of_node_put(node);
> +	}
> +	for (; next; next = next->sibling) {
> +		if (!(of_node_name_eq(next, "cpu") ||
> +		      (next->type && !of_node_cmp(next->type, "cpu"))))
> +			continue;
> +		if (!__of_device_is_available(next))
> +			continue;
> +		if (of_node_get(next))
> +			break;
> +	}
> +	of_node_put(prev);
> +	raw_spin_unlock_irqrestore(&devtree_lock, flags);
> +	return next;
> +}
> +EXPORT_SYMBOL(of_get_next_cpu_node);
> +
>  /**
>   * of_get_compatible_child - Find compatible child node
>   * @parent:	parent node
> diff --git a/include/linux/of.h b/include/linux/of.h
> index 99b0ebf49632..1aca0dbd35df 100644
> --- a/include/linux/of.h
> +++ b/include/linux/of.h
> @@ -353,6 +353,8 @@ extern const void *of_get_property(const struct device_node *node,
>  				const char *name,
>  				int *lenp);
>  extern struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
> +extern struct device_node *of_get_next_cpu_node(struct device_node *prev);
> +
>  #define for_each_property_of_node(dn, pp) \
>  	for (pp = dn->properties; pp != NULL; pp = pp->next)
>
> @@ -754,6 +756,11 @@ static inline struct device_node *of_get_cpu_node(int cpu,
>  	return NULL;
>  }
>
> +static inline struct device_node *of_get_next_cpu_node(struct device_node *prev)
> +{
> +	return NULL;
> +}
> +
>  static inline int of_n_addr_cells(struct device_node *np)
>  {
>  	return 0;
> @@ -1217,6 +1224,10 @@ static inline int of_property_read_s32(const struct device_node *np,
>  	for (child = of_get_next_available_child(parent, NULL); child != NULL; \
>  	     child = of_get_next_available_child(parent, child))
>
> +#define for_each_of_cpu_node(cpu) \
> +	for (cpu = of_get_next_cpu_node(NULL); cpu != NULL; \
> +	     cpu = of_get_next_cpu_node(cpu))
> +
>  #define for_each_node_with_property(dn, prop_name) \
>  	for (dn = of_find_node_with_property(NULL, prop_name); dn; \
>  	     dn = of_find_node_with_property(dn, prop_name))
> --
> 2.17.1

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

* Re: [PATCH 01/21] of: Add cpu node iterator for_each_of_cpu_node()
  2018-10-30 14:18   ` Michael Ellerman
@ 2018-10-30 14:20     ` Michael Ellerman
  2018-10-30 15:00       ` Rob Herring
  0 siblings, 1 reply; 49+ messages in thread
From: Michael Ellerman @ 2018-10-30 14:20 UTC (permalink / raw)
  To: Rob Herring, devicetree, linux-kernel, linuxppc-dev; +Cc: Frank Rowand

Michael Ellerman <mpe@ellerman.id.au> writes:
> Hi Rob,
>
> Sorry I missed this when you posted it.
>
> Rob Herring <robh@kernel.org> writes:
>> Iterating thru cpu nodes is a common pattern. Create a common iterator
>> which can find child nodes either by node name or device_type == cpu.
>> Using the former will allow for eventually dropping device_type
>> properties which are deprecated for FDT.
>
> Device trees we see on powerpc generally don't (never?) use "cpu" as the
> node name for CPU nodes. And many of those device trees come from
> firmware, so we can't update them.
>
> So dropping support for device_type is a non-starter from our POV.

ps. presumably that's what you meant by deprecated *for FDT*.

But anyway just wanted to make sure we are on the same page.

cheers

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

* Re: [PATCH 01/21] of: Add cpu node iterator for_each_of_cpu_node()
  2018-10-30 14:20     ` Michael Ellerman
@ 2018-10-30 15:00       ` Rob Herring
  2018-11-01 10:52         ` Michael Ellerman
  0 siblings, 1 reply; 49+ messages in thread
From: Rob Herring @ 2018-10-30 15:00 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: devicetree, Linux Kernel Mailing List, linuxppc-dev, Frank Rowand

On Tue, Oct 30, 2018 at 9:20 AM Michael Ellerman <mpe@ellerman.id.au> wrote:
>
> Michael Ellerman <mpe@ellerman.id.au> writes:
> > Hi Rob,
> >
> > Sorry I missed this when you posted it.
> >
> > Rob Herring <robh@kernel.org> writes:
> >> Iterating thru cpu nodes is a common pattern. Create a common iterator
> >> which can find child nodes either by node name or device_type == cpu.
> >> Using the former will allow for eventually dropping device_type
> >> properties which are deprecated for FDT.
> >
> > Device trees we see on powerpc generally don't (never?) use "cpu" as the
> > node name for CPU nodes. And many of those device trees come from
> > firmware, so we can't update them.
> >
> > So dropping support for device_type is a non-starter from our POV.
>
> ps. presumably that's what you meant by deprecated *for FDT*.

Right.

> But anyway just wanted to make sure we are on the same page.

Yes, I was aware at least older powerpc DTs don't use 'cpu' for node names.

Rob

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

* NXP P50XX/e5500 secondary CPUs not onlined with current mainline (was [PATCH 20/21] of: use for_each_of_cpu_node iterator)
  2018-09-05 19:37 ` [PATCH 20/21] of: " Rob Herring
@ 2018-10-31 12:46   ` Michael Ellerman
  2018-10-31 14:25     ` Rob Herring
  0 siblings, 1 reply; 49+ messages in thread
From: Michael Ellerman @ 2018-10-31 12:46 UTC (permalink / raw)
  To: Rob Herring, devicetree, linux-kernel; +Cc: Frank Rowand, Christian Zigotzky

Hi Rob,

This change is breaking some powerpc machines, ...

Rob Herring <robh@kernel.org> writes:
> Use the for_each_of_cpu_node iterator to iterate over cpu nodes. This
> has the side effect of defaulting to iterating using "cpu" node names in
> preference to the deprecated (for FDT) device_type == "cpu".
>
> Cc: Frank Rowand <frowand.list@gmail.com>
> Cc: devicetree@vger.kernel.org
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---
> Please ack and I will take via the DT tree. This is dependent on the
> first 2 patches.
>
>  drivers/of/base.c    |  2 +-
>  drivers/of/of_numa.c | 15 ++-------------
>  2 files changed, 3 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 6389aeb2f48c..8285c07cab44 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -389,7 +389,7 @@ struct device_node *of_get_cpu_node(int cpu, unsigned int *thread)
>  {
>  	struct device_node *cpun;
>
> -	for_each_node_by_type(cpun, "cpu") {
> +	for_each_of_cpu_node(cpun) {
>  		if (arch_find_n_match_cpu_physical_id(cpun, cpu, thread))
>  			return cpun;
>  	}

Previously we just looked for any node with a type of "cpu", but now
we're using for_each_of_cpu_node(), which does:

	for (; next; next = next->sibling) {
		if (!(of_node_name_eq(next, "cpu") ||
		      (next->type && !of_node_cmp(next->type, "cpu"))))
			continue;

		if (!__of_device_is_available(next))
			continue;
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

		if (of_node_get(next))
			break;
	}


ie. the available check is new.

On this machine the 2nd CPU is not marked as available:

  root@p5020ds:/proc/device-tree/cpus/PowerPC,e5500@1# lsprop status 
  status           "disabled"

This has the effect of preventing the SMP code from finding the 2nd CPU
in order to bring it up (in smp_85xx_start_cpu()). And so only the boot
CPU is onlined.

The device tree is built from a dts:

  arch/powerpc/boot/dts/fsl/p5020si-pre.dtsi

But we don't set the status in there, so presumably u-boot is changing
the status during boot? (not a u-boot expert).


We could work around this in the platform code presumably, but I'm
worried this might break other things as well. You didn't mention the
addition of the available check in the change log so I wonder if it was
deliberate or just seemed like a good idea?

cheers

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

* Re: NXP P50XX/e5500 secondary CPUs not onlined with current mainline (was [PATCH 20/21] of: use for_each_of_cpu_node iterator)
  2018-10-31 12:46   ` NXP P50XX/e5500 secondary CPUs not onlined with current mainline (was [PATCH 20/21] of: use for_each_of_cpu_node iterator) Michael Ellerman
@ 2018-10-31 14:25     ` Rob Herring
  2018-11-01 10:55       ` Michael Ellerman
  0 siblings, 1 reply; 49+ messages in thread
From: Rob Herring @ 2018-10-31 14:25 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: devicetree, linux-kernel, Frank Rowand, chzigotzky

On Wed, Oct 31, 2018 at 7:46 AM Michael Ellerman <mpe@ellerman.id.au> wrote:
>
> Hi Rob,
>
> This change is breaking some powerpc machines, ...
>
> Rob Herring <robh@kernel.org> writes:
> > Use the for_each_of_cpu_node iterator to iterate over cpu nodes. This
> > has the side effect of defaulting to iterating using "cpu" node names in
> > preference to the deprecated (for FDT) device_type == "cpu".
> >
> > Cc: Frank Rowand <frowand.list@gmail.com>
> > Cc: devicetree@vger.kernel.org
> > Signed-off-by: Rob Herring <robh@kernel.org>
> > ---
> > Please ack and I will take via the DT tree. This is dependent on the
> > first 2 patches.
> >
> >  drivers/of/base.c    |  2 +-
> >  drivers/of/of_numa.c | 15 ++-------------
> >  2 files changed, 3 insertions(+), 14 deletions(-)
> >
> > diff --git a/drivers/of/base.c b/drivers/of/base.c
> > index 6389aeb2f48c..8285c07cab44 100644
> > --- a/drivers/of/base.c
> > +++ b/drivers/of/base.c
> > @@ -389,7 +389,7 @@ struct device_node *of_get_cpu_node(int cpu, unsigned int *thread)
> >  {
> >       struct device_node *cpun;
> >
> > -     for_each_node_by_type(cpun, "cpu") {
> > +     for_each_of_cpu_node(cpun) {
> >               if (arch_find_n_match_cpu_physical_id(cpun, cpu, thread))
> >                       return cpun;
> >       }
>
> Previously we just looked for any node with a type of "cpu", but now
> we're using for_each_of_cpu_node(), which does:
>
>         for (; next; next = next->sibling) {
>                 if (!(of_node_name_eq(next, "cpu") ||
>                       (next->type && !of_node_cmp(next->type, "cpu"))))
>                         continue;
>
>                 if (!__of_device_is_available(next))
>                         continue;
>                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
>                 if (of_node_get(next))
>                         break;
>         }
>
>
> ie. the available check is new.
>
> On this machine the 2nd CPU is not marked as available:
>
>   root@p5020ds:/proc/device-tree/cpus/PowerPC,e5500@1# lsprop status
>   status           "disabled"
>
> This has the effect of preventing the SMP code from finding the 2nd CPU
> in order to bring it up (in smp_85xx_start_cpu()). And so only the boot
> CPU is onlined.
>
> The device tree is built from a dts:
>
>   arch/powerpc/boot/dts/fsl/p5020si-pre.dtsi
>
> But we don't set the status in there, so presumably u-boot is changing
> the status during boot? (not a u-boot expert).

Ah, status for cpus is a bit different. For most nodes, it should be
equivalent to the node not being present, but for cpus it means
offline if disabled. Though ARM platforms have never used it in that
way.

> We could work around this in the platform code presumably, but I'm
> worried this might break other things as well. You didn't mention the
> addition of the available check in the change log so I wonder if it was
> deliberate or just seemed like a good idea?

Just seemed like a good idea...

I'll send a patch now dropping those 2 lines.

Rob

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

* Re: [PATCH 01/21] of: Add cpu node iterator for_each_of_cpu_node()
  2018-10-30 15:00       ` Rob Herring
@ 2018-11-01 10:52         ` Michael Ellerman
  2018-11-01 15:12           ` Segher Boessenkool
  0 siblings, 1 reply; 49+ messages in thread
From: Michael Ellerman @ 2018-11-01 10:52 UTC (permalink / raw)
  To: Rob Herring
  Cc: devicetree, Linux Kernel Mailing List, linuxppc-dev,
	Frank Rowand, Tyrel Datwyler

Rob Herring <robh@kernel.org> writes:
> On Tue, Oct 30, 2018 at 9:20 AM Michael Ellerman <mpe@ellerman.id.au> wrote:
>>
>> Michael Ellerman <mpe@ellerman.id.au> writes:
>> > Hi Rob,
>> >
>> > Sorry I missed this when you posted it.
>> >
>> > Rob Herring <robh@kernel.org> writes:
>> >> Iterating thru cpu nodes is a common pattern. Create a common iterator
>> >> which can find child nodes either by node name or device_type == cpu.
>> >> Using the former will allow for eventually dropping device_type
>> >> properties which are deprecated for FDT.
>> >
>> > Device trees we see on powerpc generally don't (never?) use "cpu" as the
>> > node name for CPU nodes. And many of those device trees come from
>> > firmware, so we can't update them.
>> >
>> > So dropping support for device_type is a non-starter from our POV.
>>
>> ps. presumably that's what you meant by deprecated *for FDT*.
>
> Right.
>
>> But anyway just wanted to make sure we are on the same page.
>
> Yes, I was aware at least older powerpc DTs don't use 'cpu' for node names.

Actually newer ones too, see below :)

And there's code out there that expects this, so we can't realistically
change it any time soon :/

  https://github.com/ibm-power-utilities/powerpc-utils/blob/master/src/drmgr/common_cpu.c#L186
  https://github.com/ibm-power-utilities/powerpc-utils/blob/master/src/ppc64_cpu.c#L344

cheers

$ ls -d1 /proc/device-tree/cpus/PowerPC\,POWER9@*
/proc/device-tree/cpus/PowerPC,POWER9@14
/proc/device-tree/cpus/PowerPC,POWER9@1c
/proc/device-tree/cpus/PowerPC,POWER9@34
/proc/device-tree/cpus/PowerPC,POWER9@3c
/proc/device-tree/cpus/PowerPC,POWER9@4
/proc/device-tree/cpus/PowerPC,POWER9@48
/proc/device-tree/cpus/PowerPC,POWER9@54
/proc/device-tree/cpus/PowerPC,POWER9@804
/proc/device-tree/cpus/PowerPC,POWER9@80c
/proc/device-tree/cpus/PowerPC,POWER9@814
/proc/device-tree/cpus/PowerPC,POWER9@81c
/proc/device-tree/cpus/PowerPC,POWER9@834
/proc/device-tree/cpus/PowerPC,POWER9@83c
/proc/device-tree/cpus/PowerPC,POWER9@844
/proc/device-tree/cpus/PowerPC,POWER9@84c
/proc/device-tree/cpus/PowerPC,POWER9@c

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

* Re: NXP P50XX/e5500 secondary CPUs not onlined with current mainline (was [PATCH 20/21] of: use for_each_of_cpu_node iterator)
  2018-10-31 14:25     ` Rob Herring
@ 2018-11-01 10:55       ` Michael Ellerman
  0 siblings, 0 replies; 49+ messages in thread
From: Michael Ellerman @ 2018-11-01 10:55 UTC (permalink / raw)
  To: Rob Herring; +Cc: devicetree, linux-kernel, Frank Rowand, chzigotzky

Rob Herring <robh@kernel.org> writes:
> On Wed, Oct 31, 2018 at 7:46 AM Michael Ellerman <mpe@ellerman.id.au> wrote:
>> Rob Herring <robh@kernel.org> writes:
>> > Use the for_each_of_cpu_node iterator to iterate over cpu nodes. This
>> > has the side effect of defaulting to iterating using "cpu" node names in
>> > preference to the deprecated (for FDT) device_type == "cpu".
>> >
>> > Cc: Frank Rowand <frowand.list@gmail.com>
>> > Cc: devicetree@vger.kernel.org
>> > Signed-off-by: Rob Herring <robh@kernel.org>
>> > ---
>> > Please ack and I will take via the DT tree. This is dependent on the
>> > first 2 patches.
>> >
>> >  drivers/of/base.c    |  2 +-
>> >  drivers/of/of_numa.c | 15 ++-------------
>> >  2 files changed, 3 insertions(+), 14 deletions(-)
>> >
>> > diff --git a/drivers/of/base.c b/drivers/of/base.c
>> > index 6389aeb2f48c..8285c07cab44 100644
>> > --- a/drivers/of/base.c
>> > +++ b/drivers/of/base.c
>> > @@ -389,7 +389,7 @@ struct device_node *of_get_cpu_node(int cpu, unsigned int *thread)
>> >  {
>> >       struct device_node *cpun;
>> >
>> > -     for_each_node_by_type(cpun, "cpu") {
>> > +     for_each_of_cpu_node(cpun) {
>> >               if (arch_find_n_match_cpu_physical_id(cpun, cpu, thread))
>> >                       return cpun;
>> >       }
>>
>> Previously we just looked for any node with a type of "cpu", but now
>> we're using for_each_of_cpu_node(), which does:
>>
>>         for (; next; next = next->sibling) {
>>                 if (!(of_node_name_eq(next, "cpu") ||
>>                       (next->type && !of_node_cmp(next->type, "cpu"))))
>>                         continue;
>>
>>                 if (!__of_device_is_available(next))
>>                         continue;
>>                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>
>>                 if (of_node_get(next))
>>                         break;
>>         }
>>
>>
>> ie. the available check is new.
>>
>> On this machine the 2nd CPU is not marked as available:
>>
>>   root@p5020ds:/proc/device-tree/cpus/PowerPC,e5500@1# lsprop status
>>   status           "disabled"
>>
>> This has the effect of preventing the SMP code from finding the 2nd CPU
>> in order to bring it up (in smp_85xx_start_cpu()). And so only the boot
>> CPU is onlined.
>>
>> The device tree is built from a dts:
>>
>>   arch/powerpc/boot/dts/fsl/p5020si-pre.dtsi
>>
>> But we don't set the status in there, so presumably u-boot is changing
>> the status during boot? (not a u-boot expert).
>
> Ah, status for cpus is a bit different. For most nodes, it should be
> equivalent to the node not being present, but for cpus it means
> offline if disabled. Though ARM platforms have never used it in that
> way.

Aha. We don't use it like that on server CPUs either, so perhaps it's
just a u-boot thing.

>> We could work around this in the platform code presumably, but I'm
>> worried this might break other things as well. You didn't mention the
>> addition of the available check in the change log so I wonder if it was
>> deliberate or just seemed like a good idea?
>
> Just seemed like a good idea...

Yeah fair enough.

> I'll send a patch now dropping those 2 lines.

Awesome, thanks.

cheers

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

* Re: [PATCH 01/21] of: Add cpu node iterator for_each_of_cpu_node()
  2018-11-01 10:52         ` Michael Ellerman
@ 2018-11-01 15:12           ` Segher Boessenkool
  2018-11-01 15:57             ` Rob Herring
  0 siblings, 1 reply; 49+ messages in thread
From: Segher Boessenkool @ 2018-11-01 15:12 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Rob Herring, devicetree, linuxppc-dev, Linux Kernel Mailing List,
	Frank Rowand, Tyrel Datwyler

On Thu, Nov 01, 2018 at 09:52:57PM +1100, Michael Ellerman wrote:
> Rob Herring <robh@kernel.org> writes:
> > Yes, I was aware at least older powerpc DTs don't use 'cpu' for node names.
> 
> Actually newer ones too, see below :)

Good, because that is required by the Open Firmware standard (the PowerPC
binding, to be exact):

http://www.openbios.org/data/docs/ppc-2_1.ps

(see 5.1.4, "name").


Segher

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

* Re: [PATCH 01/21] of: Add cpu node iterator for_each_of_cpu_node()
  2018-11-01 15:12           ` Segher Boessenkool
@ 2018-11-01 15:57             ` Rob Herring
  0 siblings, 0 replies; 49+ messages in thread
From: Rob Herring @ 2018-11-01 15:57 UTC (permalink / raw)
  To: segher
  Cc: Michael Ellerman, devicetree, linuxppc-dev, linux-kernel,
	Frank Rowand, Tyrel Datwyler

On Thu, Nov 1, 2018 at 10:12 AM Segher Boessenkool
<segher@kernel.crashing.org> wrote:
>
> On Thu, Nov 01, 2018 at 09:52:57PM +1100, Michael Ellerman wrote:
> > Rob Herring <robh@kernel.org> writes:
> > > Yes, I was aware at least older powerpc DTs don't use 'cpu' for node names.
> >
> > Actually newer ones too, see below :)
>
> Good, because that is required by the Open Firmware standard (the PowerPC
> binding, to be exact):
>
> http://www.openbios.org/data/docs/ppc-2_1.ps
>
> (see 5.1.4, "name").

Yes. I should say I only expect systems following ePAPR (3.7) or DT
Spec will use 'cpu' node names. Those specs also require 'device_type'
which is supposed to indicate what OF methods are available for a node
which doesn't exist on FDT.

Rob

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

end of thread, other threads:[~2018-11-01 15:57 UTC | newest]

Thread overview: 49+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-05 19:37 [PATCH 00/21] DT cpu node iterator Rob Herring
2018-09-05 19:37 ` [PATCH 01/21] of: Add cpu node iterator for_each_of_cpu_node() Rob Herring
2018-09-06  8:45   ` Geert Uytterhoeven
2018-10-30 14:18   ` Michael Ellerman
2018-10-30 14:20     ` Michael Ellerman
2018-10-30 15:00       ` Rob Herring
2018-11-01 10:52         ` Michael Ellerman
2018-11-01 15:12           ` Segher Boessenkool
2018-11-01 15:57             ` Rob Herring
2018-09-05 19:37 ` [PATCH 02/21] of: Support matching cpu nodes with no 'reg' property Rob Herring
2018-09-05 19:37 ` [PATCH 03/21] ARM: use for_each_of_cpu_node iterator Rob Herring
2018-09-05 19:37 ` [PATCH 04/21] ARM: topology: remove unneeded check for /cpus node Rob Herring
2018-09-05 19:37 ` [PATCH 05/21] ARM: shmobile: use for_each_of_cpu_node iterator Rob Herring
2018-09-06  8:52   ` Geert Uytterhoeven
2018-09-06  8:56   ` Simon Horman
2018-09-05 19:37 ` [PATCH 06/21] arm64: " Rob Herring
2018-09-06 10:04   ` Will Deacon
2018-09-05 19:37 ` [PATCH 07/21] c6x: " Rob Herring
2018-09-05 19:37 ` [PATCH 08/21] microblaze: get cpu node with of_get_cpu_node Rob Herring
2018-09-10 14:56   ` Michal Simek
2018-09-10 20:49     ` Rob Herring
2018-09-11 12:15       ` Michal Simek
2018-09-05 19:37 ` [PATCH 09/21] nios2: " Rob Herring
2018-09-05 19:37 ` [PATCH 10/21] openrisc: use for_each_of_cpu_node iterator Rob Herring
2018-09-06  9:12   ` Stafford Horne
2018-09-05 19:37 ` [PATCH 11/21] powerpc: " Rob Herring
2018-09-05 19:37 ` [PATCH 12/21] powerpc: 4xx: get cpu node with of_get_cpu_node Rob Herring
2018-09-05 19:37 ` [PATCH 13/21] powerpc: 8xx: " Rob Herring
2018-09-05 19:37 ` [PATCH 14/21] riscv: use for_each_of_cpu_node iterator Rob Herring
2018-09-10 13:37   ` Christoph Hellwig
2018-09-10 13:51     ` Rob Herring
2018-09-18 22:53   ` Palmer Dabbelt
2018-09-05 19:37 ` [PATCH 15/21] SH: " Rob Herring
2018-09-05 19:37 ` [PATCH 16/21] x86: DT: " Rob Herring
2018-09-06  8:15   ` Thomas Gleixner
2018-09-05 19:37 ` [PATCH 17/21] clk: mvebu: " Rob Herring
2018-09-06  1:47   ` Stephen Boyd
2018-09-05 19:37 ` [PATCH 18/21] edac: cpc925: " Rob Herring
2018-09-06  8:35   ` Borislav Petkov
2018-09-06 11:12     ` Rob Herring
2018-09-06 12:20       ` Borislav Petkov
2018-09-05 19:37 ` [PATCH 19/21] iommu: fsl_pamu: " Rob Herring
2018-09-05 19:37 ` [PATCH 20/21] of: " Rob Herring
2018-10-31 12:46   ` NXP P50XX/e5500 secondary CPUs not onlined with current mainline (was [PATCH 20/21] of: use for_each_of_cpu_node iterator) Michael Ellerman
2018-10-31 14:25     ` Rob Herring
2018-11-01 10:55       ` Michael Ellerman
2018-09-05 19:37 ` [PATCH 21/21] fbdev: fsl-diu: get cpu node with of_get_cpu_node Rob Herring
2018-09-11  3:34   ` Timur Tabi
     [not found] ` <CAHTX3d+BFKM-jFo8Ww_dXwAzsDVoWqE==erfwVTeijHfh8kkOw@mail.gmail.com>
2018-09-07 13:58   ` [PATCH 00/21] DT cpu node iterator Rob Herring

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