linuxppc-dev.lists.ozlabs.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 11/21] powerpc: use for_each_of_cpu_node iterator Rob Herring
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ 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] 11+ 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
@ 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
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 11+ 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 related	[flat|nested] 11+ 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
  2018-09-05 19:37 ` [PATCH 11/21] powerpc: use for_each_of_cpu_node iterator Rob Herring
@ 2018-09-05 19:37 ` Rob Herring
  2018-09-05 19:37 ` [PATCH 13/21] powerpc: 8xx: " Rob Herring
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 11+ 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 related	[flat|nested] 11+ 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
  2018-09-05 19:37 ` [PATCH 11/21] powerpc: use for_each_of_cpu_node iterator 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 ` Rob Herring
       [not found] ` <CAHTX3d+BFKM-jFo8Ww_dXwAzsDVoWqE==erfwVTeijHfh8kkOw@mail.gmail.com>
       [not found] ` <20180905193738.19325-2-robh@kernel.org>
  4 siblings, 0 replies; 11+ 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 related	[flat|nested] 11+ 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; 11+ messages in thread
From: Rob Herring @ 2018-09-07 13:58 UTC (permalink / raw)
  To: Michal Simek
  Cc: devicetree, linux-kernel@vger.kernel.org, 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] 11+ messages in thread

* Re: [PATCH 01/21] of: Add cpu node iterator for_each_of_cpu_node()
       [not found] ` <20180905193738.19325-2-robh@kernel.org>
@ 2018-10-30 14:18   ` Michael Ellerman
  2018-10-30 14:20     ` Michael Ellerman
  0 siblings, 1 reply; 11+ 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] 11+ messages in thread

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

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] 11+ 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; 11+ messages in thread
From: Rob Herring @ 2018-11-01 15:57 UTC (permalink / raw)
  To: segher
  Cc: devicetree, Frank Rowand, linux-kernel@vger.kernel.org,
	Tyrel Datwyler, linuxppc-dev

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] 11+ messages in thread

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

Thread overview: 11+ 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 11/21] powerpc: use for_each_of_cpu_node iterator 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
     [not found] ` <CAHTX3d+BFKM-jFo8Ww_dXwAzsDVoWqE==erfwVTeijHfh8kkOw@mail.gmail.com>
2018-09-07 13:58   ` [PATCH 00/21] DT cpu node iterator Rob Herring
     [not found] ` <20180905193738.19325-2-robh@kernel.org>
2018-10-30 14:18   ` [PATCH 01/21] of: Add cpu node iterator for_each_of_cpu_node() 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

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