[SPARC64]: Must run smp_setup_cpu_possible_map() after paging_init()
[safe/jmp/linux-2.6] / arch / sparc64 / kernel / setup.c
index ca75f3b..a6a7d81 100644 (file)
@@ -220,9 +220,8 @@ char reboot_command[COMMAND_LINE_SIZE];
 
 static struct pt_regs fake_swapper_regs = { { 0, }, 0, 0, 0, 0 };
 
-static void __init per_cpu_patch(void)
+void __init per_cpu_patch(void)
 {
-#ifdef CONFIG_SMP
        struct cpuid_patch_entry *p;
        unsigned long ver;
        int is_jbus;
@@ -233,8 +232,8 @@ static void __init per_cpu_patch(void)
        is_jbus = 0;
        if (tlb_type != hypervisor) {
                __asm__ ("rdpr %%ver, %0" : "=r" (ver));
-               is_jbus = ((ver >> 32) == __JALAPENO_ID ||
-                          (ver >> 32) == __SERRANO_ID);
+               is_jbus = ((ver >> 32UL) == __JALAPENO_ID ||
+                          (ver >> 32UL) == __SERRANO_ID);
        }
 
        p = &__cpuid_patch;
@@ -279,10 +278,9 @@ static void __init per_cpu_patch(void)
 
                p++;
        }
-#endif
 }
 
-static void __init sun4v_patch(void)
+void __init sun4v_patch(void)
 {
        struct sun4v_1insn_patch_entry *p1;
        struct sun4v_2insn_patch_entry *p2;
@@ -317,6 +315,15 @@ static void __init sun4v_patch(void)
        }
 }
 
+#ifdef CONFIG_SMP
+void __init boot_cpu_id_too_large(int cpu)
+{
+       prom_printf("Serious problem, boot cpu id (%d) >= NR_CPUS (%d)\n",
+                   cpu, NR_CPUS);
+       prom_halt();
+}
+#endif
+
 void __init setup_arch(char **cmdline_p)
 {
        /* Initialize PROM console and command line. */
@@ -334,16 +341,6 @@ void __init setup_arch(char **cmdline_p)
        conswitchp = &prom_con;
 #endif
 
-       /* Work out if we are starfire early on */
-       check_if_starfire();
-
-       /* Now we know enough to patch the get_cpuid sequences
-        * used by trap code.
-        */
-       per_cpu_patch();
-
-       sun4v_patch();
-
        boot_flags_init(*cmdline_p);
 
        idprom_init();
@@ -351,7 +348,7 @@ void __init setup_arch(char **cmdline_p)
        if (!root_flags)
                root_mountflags &= ~MS_RDONLY;
        ROOT_DEV = old_decode_dev(root_dev);
-#ifdef CONFIG_BLK_DEV_INITRD
+#ifdef CONFIG_BLK_DEV_RAM
        rd_image_start = ram_flags & RAMDISK_IMAGE_START_MASK;
        rd_prompt = ((ram_flags & RAMDISK_PROMPT_FLAG) != 0);
        rd_doload = ((ram_flags & RAMDISK_LOAD_FLAG) != 0);     
@@ -379,12 +376,12 @@ void __init setup_arch(char **cmdline_p)
        }
 #endif
 
-       smp_setup_cpu_possible_map();
+       /* Get boot processor trap_block[] setup.  */
+       init_cur_cpu_trap(current_thread_info());
 
        paging_init();
 
-       /* Get boot processor trap_block[] setup.  */
-       init_cur_cpu_trap();
+       smp_setup_cpu_possible_map();
 }
 
 static int __init set_preferred_console(void)
@@ -405,6 +402,12 @@ static int __init set_preferred_console(void)
                serial_console = 2;
        } else if (idev == PROMDEV_IRSC && odev == PROMDEV_ORSC) {
                serial_console = 3;
+       } else if (idev == PROMDEV_IVCONS && odev == PROMDEV_OVCONS) {
+               /* sunhv_console_init() doesn't check the serial_console
+                * value anyways...
+                */
+               serial_console = 4;
+               return add_preferred_console("ttyHV", 0, NULL);
        } else {
                prom_printf("Inconsistent console: "
                            "input %d, output %d\n",
@@ -438,9 +441,8 @@ static int show_cpuinfo(struct seq_file *m, void *__unused)
        seq_printf(m, 
                   "cpu\t\t: %s\n"
                   "fpu\t\t: %s\n"
-                  "promlib\t\t: Version 3 Revision %d\n"
-                  "prom\t\t: %d.%d.%d\n"
-                  "type\t\t: sun4u\n"
+                  "prom\t\t: %s\n"
+                  "type\t\t: %s\n"
                   "ncpus probed\t: %d\n"
                   "ncpus active\t: %d\n"
                   "D$ parity tl1\t: %u\n"
@@ -452,10 +454,10 @@ static int show_cpuinfo(struct seq_file *m, void *__unused)
                   ,
                   sparc_cpu_type,
                   sparc_fpu_type,
-                  prom_rev,
-                  prom_prev >> 16,
-                  (prom_prev >> 8) & 0xff,
-                  prom_prev & 0xff,
+                  prom_version,
+                  ((tlb_type == hypervisor) ?
+                   "sun4v" :
+                   "sun4u"),
                   ncpus_probed,
                   num_online_cpus(),
                   dcache_parity_tl1_occurred,
@@ -532,15 +534,11 @@ static int __init topology_init(void)
        while (!cpu_find_by_instance(ncpus_probed, NULL, NULL))
                ncpus_probed++;
 
-       for (i = 0; i < NR_CPUS; i++) {
-               if (cpu_possible(i)) {
-                       struct cpu *p = kmalloc(sizeof(*p), GFP_KERNEL);
-
-                       if (p) {
-                               memset(p, 0, sizeof(*p));
-                               register_cpu(p, i, NULL);
-                               err = 0;
-                       }
+       for_each_possible_cpu(i) {
+               struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL);
+               if (p) {
+                       register_cpu(p, i, NULL);
+                       err = 0;
                }
        }