Skip to contentSkip to conversation

dm: ppc: Fixup cpu.c warning in mpc8xx

PATCH New Marek Vasut 2 participants 8 messages Jul 27, 2012 – Jul 30, 2012 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dm: ppc: Fixup cpu.c warning in mpc8xx

cpu.c: In function ?check_CPU?:
cpu.c:256:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]

---
 arch/powerpc/cpu/mpc8xx/cpu.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/powerpc/cpu/mpc8xx/cpu.c +2 -1
index 5cbf9a6..e453245 100644
@@ -41,6 +41,7 @@
 #include <netdev.h>
 #include <asm/cache.h>
 #include <linux/compiler.h>
+#include <asm/io.h>
 
 #if defined(CONFIG_OF_LIBFDT)
 #include <libfdt.h>
@@ -253,7 +254,7 @@ static int check_CPU (long clock, uint pvr, uint immr)
 	if ((pvr >> 16) != 0x0050)
 		return -1;
 
-	k = (immr << 16) | *((ushort *) & immap->im_cpm.cp_dparam[0xB0]);
+	k = (immr << 16) | readw(&immap->im_cpm.cp_dparam[0xB0]);
 	m = 0;
 
 	switch (k) {
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/1 dm: ppc: Fixup cpu.c warning in mpc8xx

Dear Marek Vasut,

Quoted 8 lines · In message <[email protected]> you wrote:

cpu.c: In function ?check_CPU?:
cpu.c:256:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]

---
 arch/powerpc/cpu/mpc8xx/cpu.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

...

arch/powerpc/cpu/mpc8xx/cpu.c static int check_CPU (long clock, uint pvr, uint immr) · line 257

Quoted 2 lines
arch/powerpc/cpu/mpc8xx/cpu.c +1 -1
-	k = (immr << 16) | *((ushort *) & immap->im_cpm.cp_dparam[0xB0]);
+	k = (immr << 16) | readw(&immap->im_cpm.cp_dparam[0xB0]);

I think this is wrong. readw() is a little endian I/O accessor, but PPC is all big-endian.

Guess this was untested?

Best regards,

Wolfgang Denk

Signature · 7 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"The good Christian should beware of mathematicians and all those who
make empty prophecies. The danger already exists that  mathematicians
have  made a covenant with the devil to darken the spirit and confine
man in the bonds of Hell."                          - Saint Augustine
#2 lore raw

PATCH 1/1 dm: ppc: Fixup cpu.c warning in mpc8xx

Dear Wolfgang Denk,

Quoted 14 lines

Dear Marek Vasut,

Quoted 10 lines · In message <[email protected]> you wrote:

cpu.c: In function ?check_CPU?:
cpu.c:256:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]

---

 arch/powerpc/cpu/mpc8xx/cpu.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 7 lines

...

arch/powerpc/cpu/mpc8xx/cpu.c static int check_CPU (long clock, uint pvr, uint immr) · line 257

Quoted 2 lines
arch/powerpc/cpu/mpc8xx/cpu.c +1 -1
-	k = (immr << 16) | *((ushort *) & immap->im_cpm.cp_dparam[0xB0]);
+	k = (immr << 16) | readw(&immap->im_cpm.cp_dparam[0xB0]);

I think this is wrong. readw() is a little endian I/O accessor, but PPC is all big-endian.

So in_be32 it is, I guess?

Quoted 1 line

Guess this was untested?

Of course it was not. Had trouble even sending this via the crappy cellular connection on a train ;-)

Thanks for catching it, glad you reviewed this.

Quoted 3 lines

Best regards,

Wolfgang Denk

Best regards,
Marek Vasut

#3 lore raw

PATCH 1/1 dm: ppc: Fixup cpu.c warning in mpc8xx

Dear Marek,

Quoted 8 lines · In message <[email protected]> you wrote:
Quoted 6 lines

arch/powerpc/cpu/mpc8xx/cpu.c static int check_CPU (long clock, uint pvr, uint immr) · line 257

Quoted 3 lines
arch/powerpc/cpu/mpc8xx/cpu.c +1 -1
-	k = (immr << 16) | *((ushort *) & immap->im_cpm.cp_dparam[0xB0]);
+	k = (immr << 16) | readw(&immap->im_cpm.cp_dparam[0xB0]);

I think this is wrong. readw() is a little endian I/O accessor, but PPC is all big-endian.

So in_be32 it is, I guess?

Wrong again. Looks more like in_be16 to me...

Quoted 4 lines
Quoted 1 line

Guess this was untested?

Of course it was not. Had trouble even sending this via the crappy cellular> connection on a train ;-)

You tested it? And it worked? I'm surprised. ... Really??

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Worlds are conquered, galaxies destroyed -- but a woman is  always  a
woman.
	-- Kirk, "Conscience of the King", stardate unknown
#4 lore raw

PATCH 1/1 dm: ppc: Fixup cpu.c warning in mpc8xx

Dear Wolfgang Denk,

Quoted 5 lines

Dear Marek,

Quoted 1 line · In message <[email protected]> you wrote:
Quoted 1 line

Review

Quoted 1 line
(quoted diff) +0 -1
-	k = (immr << 16) | *((ushort *) & immap-

im_cpm.cp_dparam[0xB0]);

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

arch/powerpc/cpu/mpc8xx/cpu.c static int check_CPU (long clock, uint pvr, uint immr) · line 257

Quoted 1 line
arch/powerpc/cpu/mpc8xx/cpu.c +1 -0
+	k = (immr << 16) | readw(&immap->im_cpm.cp_dparam[0xB0]);

I think this is wrong. readw() is a little endian I/O accessor, but PPC is all big-endian.

So in_be32 it is, I guess?

Wrong again. Looks more like in_be16 to me...

Ok, lemme try V2.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Guess this was untested?

Of course it was not. Had trouble even sending this via the crappy cellular> connection on a train ;-)

You tested it? And it worked? I'm surprised. ... Really??

No, I did not test it. The train control unit is MPC5200 too ... so I really had no hardware to test it on in close proximity ;-)

Quoted 3 lines

Best regards,

Wolfgang Denk

Best regards,
Marek Vasut

#5 lore raw

PATCH v2 1/1 dm: ppc: Fixup cpu.c warning in mpc8xx

In reply to Marek Vasut

cpu.c: In function ?check_CPU?:
cpu.c:256:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]

---
 arch/powerpc/cpu/mpc8xx/cpu.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

NOTE: This patch is likely to break something, it is only compile tested.
NOTE2: Something is seriously wrong with my damned locale again :-/

arch/powerpc/cpu/mpc8xx/cpu.c +2 -1
index 5cbf9a6..b3fcfe5 100644
@@ -41,6 +41,7 @@
 #include <netdev.h>
 #include <asm/cache.h>
 #include <linux/compiler.h>
+#include <asm/io.h>
 
 #if defined(CONFIG_OF_LIBFDT)
 #include <libfdt.h>
@@ -253,7 +254,7 @@ static int check_CPU (long clock, uint pvr, uint immr)
 	if ((pvr >> 16) != 0x0050)
 		return -1;
 
-	k = (immr << 16) | *((ushort *) & immap->im_cpm.cp_dparam[0xB0]);
+	k = (immr << 16) | in_be16((ushort *)&immap->im_cpm.cp_dparam[0xB0]);
 	m = 0;
 
 	switch (k) {
Signature · 1 line
1.7.10.4
#6 lore raw

PATCH v2 1/1 dm: ppc: Fixup cpu.c warning in mpc8xx

Dear Marek Vasut,

Quoted 11 lines · In message <[email protected]> you wrote:

cpu.c: In function ?check_CPU?:
cpu.c:256:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]

---
 arch/powerpc/cpu/mpc8xx/cpu.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

NOTE: This patch is likely to break something, it is only compile tested.
NOTE2: Something is seriously wrong with my damned locale again :-/

Tested on TQM855MDCBAB7-T66.102 (MPC855T at 66 MHz) and TQM860LDB0A3-T50.202 (MPC860T at 50MHz).

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Wish not to seem, but to be, the best."                  - Aeschylus
#7 lore raw

PATCH v2 1/1 dm: ppc: Fixup cpu.c warning in mpc8xx

In reply to Marek Vasut

Dear Marek Vasut,

Quoted 8 lines · In message <[email protected]> you wrote:

cpu.c: In function ?check_CPU?:
cpu.c:256:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]

---
 arch/powerpc/cpu/mpc8xx/cpu.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Applied to "next" branch, thanks.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Old programmers never die, they just branch to a new address.