]> nv-tegra.nvidia Code Review - linux-2.6.git/blobdiff - init/main.c
[PATCH] as-iosched: use new io context counting mechanism
[linux-2.6.git] / init / main.c
index 141e8896d2527e11bc666abc620dbbacf0980720..0766e69712b2a86efa74caf3c5bd487bbbcd3753 100644 (file)
 
 #define __KERNEL_SYSCALLS__
 
-#include <linux/config.h>
 #include <linux/types.h>
 #include <linux/module.h>
 #include <linux/proc_fs.h>
-#include <linux/devfs_fs_kernel.h>
 #include <linux/kernel.h>
 #include <linux/syscalls.h>
 #include <linux/string.h>
 #include <linux/cpu.h>
 #include <linux/cpuset.h>
 #include <linux/efi.h>
+#include <linux/taskstats_kern.h>
+#include <linux/delayacct.h>
 #include <linux/unistd.h>
 #include <linux/rmap.h>
 #include <linux/mempolicy.h>
 #include <linux/key.h>
+#include <linux/unwind.h>
+#include <linux/buffer_head.h>
+#include <linux/debug_locks.h>
+#include <linux/lockdep.h>
 
 #include <asm/io.h>
 #include <asm/bugs.h>
@@ -79,7 +83,6 @@ extern void mca_init(void);
 extern void sbus_init(void);
 extern void sysctl_init(void);
 extern void signals_init(void);
-extern void buffer_init(void);
 extern void pidhash_init(void);
 extern void pidmap_init(void);
 extern void prio_tree_init(void);
@@ -124,6 +127,18 @@ static char *ramdisk_execute_command;
 /* Setup configured maximum number of CPUs to activate */
 static unsigned int max_cpus = NR_CPUS;
 
+/*
+ * If set, this is an indication to the drivers that reset the underlying
+ * device before going ahead with the initialization otherwise driver might
+ * rely on the BIOS and skip the reset operation.
+ *
+ * This is useful if kernel is booting in an unreliable environment.
+ * For ex. kdump situaiton where previous kernel has crashed, BIOS has been
+ * skipped and devices will be in unknown state.
+ */
+unsigned int reset_devices;
+EXPORT_SYMBOL(reset_devices);
+
 /*
  * Setup routine for controlling SMP activation
  *
@@ -150,6 +165,14 @@ static int __init maxcpus(char *str)
 
 __setup("maxcpus=", maxcpus);
 
+static int __init set_reset_devices(char *str)
+{
+       reset_devices = 1;
+       return 1;
+}
+
+__setup("reset_devices", set_reset_devices);
+
 static char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
 char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
 static const char *panic_later, *panic_param;
@@ -159,16 +182,19 @@ extern struct obs_kernel_param __setup_start[], __setup_end[];
 static int __init obsolete_checksetup(char *line)
 {
        struct obs_kernel_param *p;
+       int had_early_param = 0;
 
        p = __setup_start;
        do {
                int n = strlen(p->str);
                if (!strncmp(line, p->str, n)) {
                        if (p->early) {
-                               /* Already done in parse_early_param?  (Needs
-                                * exact match on param part) */
+                               /* Already done in parse_early_param?
+                                * (Needs exact match on param part).
+                                * Keep iterating, as we can have early
+                                * params and __setups of same names 8( */
                                if (line[n] == '\0' || line[n] == '=')
-                                       return 1;
+                                       had_early_param = 1;
                        } else if (!p->setup_func) {
                                printk(KERN_WARNING "Parameter %s is obsolete,"
                                       " ignored\n", p->str);
@@ -178,7 +204,8 @@ static int __init obsolete_checksetup(char *line)
                }
                p++;
        } while (p < __setup_end);
-       return 0;
+
+       return had_early_param;
 }
 
 /*
@@ -306,8 +333,6 @@ static int __init rdinit_setup(char *str)
 }
 __setup("rdinit=", rdinit_setup);
 
-extern void setup_arch(char **);
-
 #ifndef CONFIG_SMP
 
 #ifdef CONFIG_X86_LOCAL_APIC
@@ -325,7 +350,7 @@ static inline void smp_prepare_cpus(unsigned int maxcpus) { }
 #else
 
 #ifdef __GENERIC_PER_CPU
-unsigned long __per_cpu_offset[NR_CPUS];
+unsigned long __per_cpu_offset[NR_CPUS] __read_mostly;
 
 EXPORT_SYMBOL(__per_cpu_offset);
 
@@ -333,6 +358,7 @@ static void __init setup_per_cpu_areas(void)
 {
        unsigned long size, i;
        char *ptr;
+       unsigned long nr_possible_cpus = num_possible_cpus();
 
        /* Copy section for each CPU (we discard the original) */
        size = ALIGN(__per_cpu_end - __per_cpu_start, SMP_CACHE_BYTES);
@@ -340,12 +366,12 @@ static void __init setup_per_cpu_areas(void)
        if (size < PERCPU_ENOUGH_ROOM)
                size = PERCPU_ENOUGH_ROOM;
 #endif
+       ptr = alloc_bootmem(size * nr_possible_cpus);
 
-       ptr = alloc_bootmem(size * NR_CPUS);
-
-       for (i = 0; i < NR_CPUS; i++, ptr += size) {
+       for_each_possible_cpu(i) {
                __per_cpu_offset[i] = ptr - __per_cpu_start;
                memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start);
+               ptr += size;
        }
 }
 #endif /* !__GENERIC_PER_CPU */
@@ -447,10 +473,28 @@ static void __init boot_cpu_init(void)
        cpu_set(cpu, cpu_possible_map);
 }
 
+void __init __attribute__((weak)) smp_setup_processor_id(void)
+{
+}
+
 asmlinkage void __init start_kernel(void)
 {
        char * command_line;
        extern struct kernel_param __start___param[], __stop___param[];
+
+       smp_setup_processor_id();
+
+       /*
+        * Need to run as early as possible, to initialize the
+        * lockdep hash:
+        */
+       unwind_init();
+       lockdep_init();
+
+       local_irq_disable();
+       early_boot_irqs_off();
+       early_init_irq_lock_class();
+
 /*
  * Interrupts are still disabled. Do necessary setups, then
  * enable them
@@ -490,7 +534,13 @@ asmlinkage void __init start_kernel(void)
        init_timers();
        hrtimers_init();
        softirq_init();
+       timekeeping_init();
        time_init();
+       profile_init();
+       if (!irqs_disabled())
+               printk("start_kernel(): bug: interrupts were enabled early\n");
+       early_boot_irqs_on();
+       local_irq_enable();
 
        /*
         * HACK ALERT! This is early. We're enabling the console before
@@ -500,8 +550,16 @@ asmlinkage void __init start_kernel(void)
        console_init();
        if (panic_later)
                panic(panic_later, panic_param);
-       profile_init();
-       local_irq_enable();
+
+       lockdep_info();
+
+       /*
+        * Need to run this when irqs are enabled, because it wants
+        * to self-test [hard/soft]-irqs on/off lock inversion bugs
+        * too:
+        */
+       locking_selftest();
+
 #ifdef CONFIG_BLK_DEV_INITRD
        if (initrd_start && !initrd_below_start_ok &&
                        initrd_start < min_low_pfn << PAGE_SHIFT) {
@@ -542,6 +600,8 @@ asmlinkage void __init start_kernel(void)
        proc_root_init();
 #endif
        cpuset_init();
+       taskstats_init_early();
+       delayacct_init();
 
        check_bugs();
 
@@ -570,17 +630,23 @@ static void __init do_initcalls(void)
        int count = preempt_count();
 
        for (call = __initcall_start; call < __initcall_end; call++) {
-               char *msg;
+               char *msg = NULL;
+               char msgbuf[40];
+               int result;
 
                if (initcall_debug) {
-                       printk(KERN_DEBUG "Calling initcall 0x%p", *call);
-                       print_fn_descriptor_symbol(": %s()", (unsigned long) *call);
+                       printk("Calling initcall 0x%p", *call);
+                       print_fn_descriptor_symbol(": %s()",
+                                       (unsigned long) *call);
                        printk("\n");
                }
 
-               (*call)();
+               result = (*call)();
 
-               msg = NULL;
+               if (result && result != -ENODEV && initcall_debug) {
+                       sprintf(msgbuf, "error code %d", result);
+                       msg = msgbuf;
+               }
                if (preempt_count() != count) {
                        msg = "preemption imbalance";
                        preempt_count() = count;
@@ -590,8 +656,10 @@ static void __init do_initcalls(void)
                        local_irq_enable();
                }
                if (msg) {
-                       printk(KERN_WARNING "error in initcall at 0x%p: "
-                               "returned with %s\n", *call, msg);
+                       printk(KERN_WARNING "initcall at 0x%p", *call);
+                       print_fn_descriptor_symbol(": %s()",
+                                       (unsigned long) *call);
+                       printk(": returned with %s\n", msg);
                }
        }
 
@@ -638,24 +706,6 @@ static void run_init_process(char *init_filename)
        execve(init_filename, argv_init, envp_init);
 }
 
-static inline void fixup_cpu_present_map(void)
-{
-#ifdef CONFIG_SMP
-       int i;
-
-       /*
-        * If arch is not hotplug ready and did not populate
-        * cpu_present_map, just make cpu_present_map same as cpu_possible_map
-        * for other cpu bringup code to function as normal. e.g smp_init() etc.
-        */
-       if (cpus_empty(cpu_present_map)) {
-               for_each_cpu(i) {
-                       cpu_set(i, cpu_present_map);
-               }
-       }
-#endif
-}
-
 static int init(void * unused)
 {
        lock_kernel();
@@ -677,7 +727,6 @@ static int init(void * unused)
 
        do_pre_smp_initcalls();
 
-       fixup_cpu_present_map();
        smp_init();
        sched_init_smp();