Skip to contentSkip to conversation

powerpc/fsl_soc: Search all global-utilities nodes for rstccr

PATCH Superseded Matthew McClintock 4 participants 7 messages Aug 27, 2010 – Oct 7, 2010 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/fsl_soc: Search all global-utilities nodes for rstccr

The first global-utilities node might not contain the rstcr property, so we should search all the nodes

---
 arch/powerpc/sysdev/fsl_soc.c |   20 +++++++++++---------
 1 files changed, 11 insertions(+), 9 deletions(-)
arch/powerpc/sysdev/fsl_soc.c +11 -9
index b91f7ac..e2c8e47 100644
@@ -378,17 +378,19 @@ static __be32 __iomem *rstcr;
 static int __init setup_rstcr(void)
 {
 	struct device_node *np;
-	np = of_find_node_by_name(NULL, "global-utilities");
-	if ((np && of_get_property(np, "fsl,has-rstcr", NULL))) {
-		rstcr = of_iomap(np, 0) + 0xb0;
-		if (!rstcr)
-			printk (KERN_EMERG "Error: reset control register "
-					"not mapped!\n");
-	} else if (ppc_md.restart == fsl_rstcr_restart)
+
+	for_each_node_by_name(np, "global-utilities") {
+		if ((of_get_property(np, "fsl,has-rstcr", NULL))) {
+			rstcr = of_iomap(np, 0) + 0xb0;
+			if (!rstcr)
+				printk (KERN_EMERG "Error: reset control "
+						"register not mapped!\n");
+		}
+	}
+
+	if (!rstcr && ppc_md.restart == fsl_rstcr_restart)
 		printk(KERN_ERR "No RSTCR register, warm reboot won't work\n");
 
-	if (np)
-		of_node_put(np);
 	return 0;
 }
 
Signature · 1 line
1.6.6.1
#1 lore raw
Quoted 5 lines

<[email protected]> wrote:

+
+ =A0 =A0 =A0 for_each_node_by_name(np, "global-utilities") {
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 if ((of_get_property(np, "fsl,has-rstcr", N=

ULL))) {

Quoted 1 line

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 rstcr =3D of_iomap(np, 0) +=

0xb0;

Quoted 2 lines

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!rstcr)
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 printk (KER=

N_EMERG "Error: reset control "

I'm not sure KERN_EMERG is warranted for this kind of error.

Quoted 1 line

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=

=A0 =A0 =A0 =A0 =A0 "register not mapped!\n");

Quoted 1 line

+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 }

So if a node has an fsl,rstcr property, but the of_iomap() fails, we jump to the next global-utilities node? Perhaps you need a 'break' after the printk()?

Quoted 3 lines

+ =A0 =A0 =A0 }
+
+ =A0 =A0 =A0 if (!rstcr && ppc_md.restart =3D=3D fsl_rstcr_restart)

Wouldn't it make more sense to assign fsl_rstcr_restart to ppc_md.restart only if we find a valid fsl,has-rstcr property?

--=20
Timur Tabi
Linux kernel developer at Freescale

#2 lore raw
Quoted 8 lines · Timur Tabi
Quoted 1 line

<[email protected]> wrote:

=20

Quoted 6 lines
arch/powerpc/sysdev/fsl_soc.c +6 -0
+
+       for_each_node_by_name(np, "global-utilities") {
+               if ((of_get_property(np, "fsl,has-rstcr", NULL))) {
+                       rstcr =3D of_iomap(np, 0) + 0xb0;
+                       if (!rstcr)
+                               printk (KERN_EMERG "Error: reset =

control "

Quoted 2 lines

=20
I'm not sure KERN_EMERG is warranted for this kind of error.

I'm not sure either - I left it as it was before.

Quoted 2 lines

=20

Quoted 1 line

+ "register not =

mapped!\n");

Quoted 5 lines
Quoted 1 line

+ }

=20
So if a node has an fsl,rstcr property, but the of_iomap() fails, we jump to the next global-utilities node? Perhaps you need a 'break' after the printk()?

Or potentially a continue to be more robust? Or would two (or more) = "has-rstcr" nodes be wrong?

Quoted 7 lines

=20

arch/powerpc/sysdev/fsl_soc.c static __be32 __iomem *rstcr;

Quoted 3 lines
arch/powerpc/sysdev/fsl_soc.c +3 -0
+       }
+
+       if (!rstcr && ppc_md.restart =3D=3D fsl_rstcr_restart)

=20
Wouldn't it make more sense to assign fsl_rstcr_restart to ppc_md.restart only if we find a valid fsl,has-rstcr property?

Again I'm not entirely sure, I left this as it was before. Is there = another way to reset the board if the rstcr node was not found = correctly?

-M

Quoted 5 lines

=20
--=20
Timur Tabi
Linux kernel developer at Freescale
=20

#3 lore raw

On Tue, Aug 31, 2010 at 11:26 AM, Matthew McClintock <[email protected]> wr= ote:

Quoted 3 lines
Quoted 1 line

I'm not sure KERN_EMERG is warranted for this kind of error.

I'm not sure either - I left it as it was before.

My vote is to change it to KERN_ERR, but it's your call.

Quoted 5 lines
Quoted 3 lines

So if a node has an fsl,rstcr property, but the of_iomap() fails, we jump to the next global-utilities node? =A0Perhaps you need a 'break' after the printk()?

Or potentially a continue to be more robust? Or would two (or more) "has-=

rstcr" nodes be wrong?

My point is that if the of_iomap() call fails, looking for another global-utilities node is not the right course of action. of_iomap() failing is a serious error that should result in an immediate exit.

Quoted 4 lines
Quoted 2 lines

Wouldn't it make more sense to assign fsl_rstcr_restart to ppc_md.restart only if we find a valid fsl,has-rstcr property?

Again I'm not entirely sure, I left this as it was before. Is there anoth=

er way to reset the board if the rstcr node was not found correctly?

Not on our 85xx boards. On 83xx, there's mpc83xx_restart(). I just don't like "ppc_md.restart =3D=3D fsl_rstcr_restart", because it assumes that the define_machine() entry is incorrect.

--=20
Timur Tabi
Linux kernel developer at Freescale

#4 lore raw

PATCH v2 1/1 powerpc/fsl_soc: Search all global-utilities nodes for rstccr

The first global-utilities node might not contain the rstcr property, so we should search all the nodes

---
-Changed KERN_EMERG to KERN_ERR
-Break if we do not find rstcr mapped
-Restore of_put_node that was dropped

 arch/powerpc/sysdev/fsl_soc.c |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)
arch/powerpc/sysdev/fsl_soc.c +13 -7
index b91f7ac..6c67d9e 100644
@@ -378,17 +378,23 @@ static __be32 __iomem *rstcr;
 static int __init setup_rstcr(void)
 {
 	struct device_node *np;
-	np = of_find_node_by_name(NULL, "global-utilities");
-	if ((np && of_get_property(np, "fsl,has-rstcr", NULL))) {
-		rstcr = of_iomap(np, 0) + 0xb0;
-		if (!rstcr)
-			printk (KERN_EMERG "Error: reset control register "
-					"not mapped!\n");
-	} else if (ppc_md.restart == fsl_rstcr_restart)
+
+	for_each_node_by_name(np, "global-utilities") {
+		if ((of_get_property(np, "fsl,has-rstcr", NULL))) {
+			rstcr = of_iomap(np, 0) + 0xb0;
+			if (!rstcr)
+				printk (KERN_ERR "Error: reset control "
+						"register not mapped!\n");
+			break;
+		}
+	}
+
+	if (!rstcr && ppc_md.restart == fsl_rstcr_restart)
 		printk(KERN_ERR "No RSTCR register, warm reboot won't work\n");
 
 	if (np)
 		of_node_put(np);
+
 	return 0;
 }
 
Signature · 1 line
1.6.6.1
Applied
#6 lore raw
In reply to Matthew McClintock
Quoted 11 lines · Matthew McClintock

The first global-utilities node might not contain the rstcr property, so we should search all the nodes

---

(quoted diff) +0 -3
-Changed KERN_EMERG to KERN_ERR
-Break if we do not find rstcr mapped
-Restore of_put_node that was dropped

arch/powerpc/sysdev/fsl_soc.c | 20 +++++++++++++-------

1 files changed, 13 insertions(+), 7 deletions(-)

applied to next

- k