[U-Boot] [PATCH][v1] ppc/85xx,86xx: Handling Unknown SOC version

Incase the system is detected with Unknown SVR, let the system boot with a default value and a proper message. Now with dynamic detection of SOC properties from SVR, this is necessary to prevent a crash.
Signed-off-by: Poonam Aggrwal poonam.aggrwal@freescale.com Signed-off-by: Kumar Gala galak@kernel.crashing.org --- applies on git.am.freescale.net/mirrors/u-boot.git cpu/mpc85xx/cpu.c | 10 +++------- cpu/mpc86xx/cpu.c | 5 +---- cpu/mpc8xxx/cpu.c | 4 ++-- include/asm-ppc/processor.h | 2 ++ 4 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/cpu/mpc85xx/cpu.c b/cpu/mpc85xx/cpu.c index 6be98dc..63bdb6f 100644 --- a/cpu/mpc85xx/cpu.c +++ b/cpu/mpc85xx/cpu.c @@ -69,13 +69,9 @@ int checkcpu (void)
cpu = gd->cpu;
- if (cpu->name) { - puts(cpu->name); - if (IS_E_PROCESSOR(svr)) - puts("E"); - } else { - puts("Unknown"); - } + puts(cpu->name); + if (IS_E_PROCESSOR(svr)) + puts("E");
printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr);
diff --git a/cpu/mpc86xx/cpu.c b/cpu/mpc86xx/cpu.c index 04409ce..e97ab6d 100644 --- a/cpu/mpc86xx/cpu.c +++ b/cpu/mpc86xx/cpu.c @@ -65,10 +65,7 @@ checkcpu(void)
cpu = gd->cpu;
- if (cpu->name) - puts(cpu->name); - else - puts("Unknown"); + puts(cpu->name);
printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr); puts("Core: "); diff --git a/cpu/mpc8xxx/cpu.c b/cpu/mpc8xxx/cpu.c index 339f6d9..56fb141 100644 --- a/cpu/mpc8xxx/cpu.c +++ b/cpu/mpc8xxx/cpu.c @@ -77,6 +77,7 @@ struct cpu_type cpu_type_list [] = { CPU_TYPE_ENTRY(8641, 8641, 2), CPU_TYPE_ENTRY(8641D, 8641D, 2), #endif + CPU_TYPE_ENTRY(Unknown, Unknown, 1), };
struct cpu_type *identify_cpu(u32 ver) @@ -86,8 +87,7 @@ struct cpu_type *identify_cpu(u32 ver) if (cpu_type_list[i].soc_ver == ver) return &cpu_type_list[i]; } - - return NULL; + return &cpu_type_list[i-1]; }
int cpu_numcores() { diff --git a/include/asm-ppc/processor.h b/include/asm-ppc/processor.h index dcaf8c0..9b27634 100644 --- a/include/asm-ppc/processor.h +++ b/include/asm-ppc/processor.h @@ -1022,6 +1022,8 @@ #define SVR_8641 0x809000 #define SVR_8641D 0x809001
+#define SVR_Unknown 0x000000 + #define _GLOBAL(n)\ .globl n;\ n:

Dear Poonam Aggrwal,
In message 1251864186-11732-1-git-send-email-poonam.aggrwal@freescale.com you wrote:
Incase the system is detected with Unknown SVR, let the system boot with a default value and a proper message. Now with dynamic detection of SOC properties from SVR, this is necessary to prevent a crash.
Signed-off-by: Poonam Aggrwal poonam.aggrwal@freescale.com Signed-off-by: Kumar Gala galak@kernel.crashing.org
...
--- a/cpu/mpc8xxx/cpu.c +++ b/cpu/mpc8xxx/cpu.c @@ -77,6 +77,7 @@ struct cpu_type cpu_type_list [] = { CPU_TYPE_ENTRY(8641, 8641, 2), CPU_TYPE_ENTRY(8641D, 8641D, 2), #endif
- CPU_TYPE_ENTRY(Unknown, Unknown, 1),
};
struct cpu_type *identify_cpu(u32 ver) @@ -86,8 +87,7 @@ struct cpu_type *identify_cpu(u32 ver) if (cpu_type_list[i].soc_ver == ver) return &cpu_type_list[i]; }
- return NULL;
- return &cpu_type_list[i-1];
This looks unlogical to me. First, with this change you should change the 'for' loop into
for (i = 0; i < ARRAY_SIZE(cpu_type_list) - 1; i++) { ... }
But all this makes the code just harder to read and understand.
Why not add a separate
struct cpu_type cpu_type_unknown = CPU_TYPE_ENTRY(Unknown, Unknown, 1);
and then do a simple
return &cpu_type_unknown;
?
diff --git a/include/asm-ppc/processor.h b/include/asm-ppc/processor.h index dcaf8c0..9b27634 100644 --- a/include/asm-ppc/processor.h +++ b/include/asm-ppc/processor.h @@ -1022,6 +1022,8 @@ #define SVR_8641 0x809000 #define SVR_8641D 0x809001
+#define SVR_Unknown 0x000000
Is this a good and reliable choice? I don't know the rules for SVR contents... Maybe 0xFFFFFF would be better?
Best regards,
Wolfgang Denk

-----Original Message----- From: Wolfgang Denk [mailto:wd@denx.de] Sent: Wednesday, September 02, 2009 1:03 PM To: Aggrwal Poonam-B10812 Cc: u-boot@lists.denx.de; Kumar Gala Subject: Re: [U-Boot] [PATCH][v1] ppc/85xx,86xx: Handling Unknown SOC version
Dear Poonam Aggrwal,
In message <1251864186-11732-1-git-send-email-poonam.aggrwal@freescale.co
m> you wrote:
Incase the system is detected with Unknown SVR, let the system boot with a default value and a proper message. Now with dynamic detection of SOC properties from SVR, this is necessary to prevent a crash.
Signed-off-by: Poonam Aggrwal poonam.aggrwal@freescale.com Signed-off-by: Kumar Gala galak@kernel.crashing.org
...
--- a/cpu/mpc8xxx/cpu.c +++ b/cpu/mpc8xxx/cpu.c @@ -77,6 +77,7 @@ struct cpu_type cpu_type_list [] = { CPU_TYPE_ENTRY(8641, 8641, 2), CPU_TYPE_ENTRY(8641D, 8641D, 2), #endif
- CPU_TYPE_ENTRY(Unknown, Unknown, 1),
};
struct cpu_type *identify_cpu(u32 ver) @@ -86,8 +87,7 @@ struct cpu_type *identify_cpu(u32 ver) if (cpu_type_list[i].soc_ver == ver) return &cpu_type_list[i]; }
- return NULL;
- return &cpu_type_list[i-1];
This looks unlogical to me. First, with this change you should change the 'for' loop into
for (i = 0; i < ARRAY_SIZE(cpu_type_list) - 1; i++) { ... }
But all this makes the code just harder to read and understand.
Why not add a separate
struct cpu_type cpu_type_unknown = CPU_TYPE_ENTRY(Unknown, Unknown, 1);
and then do a simple
return &cpu_type_unknown;
?
diff --git a/include/asm-ppc/processor.h
b/include/asm-ppc/processor.h
index dcaf8c0..9b27634 100644 --- a/include/asm-ppc/processor.h +++ b/include/asm-ppc/processor.h @@ -1022,6 +1022,8 @@ #define SVR_8641 0x809000 #define SVR_8641D 0x809001
+#define SVR_Unknown 0x000000
Is this a good and reliable choice? I don't know the rules for SVR contents... Maybe 0xFFFFFF would be better?
Thanks for the comments , let me incorporate them and resend. Regards Poonam
Best regards,
Wolfgang Denk
-- 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@denx.de "Intelligence without character is a dangerous thing." - G. Steinem
participants (3)
-
Aggrwal Poonam-B10812
-
Poonam Aggrwal
-
Wolfgang Denk