X-Git-Url: https://git.stricted.de/?a=blobdiff_plain;f=kernel%2Fprintk.c;h=b2b5c3a22a36b302da177fafae653740f7eeeddf;hb=a4d63e729edad704af95e5f2a56e8c8eaaa5216b;hp=8451dfc31d25b4e0e6903e84a55de230fb5363e2;hpb=cb00e99c0abd844b884c64c6b54aa3b7d345ebb1;p=GitHub%2Fmt8127%2Fandroid_kernel_alcatel_ttab.git diff --git a/kernel/printk.c b/kernel/printk.c index 8451dfc31d25..b2b5c3a22a36 100644 --- a/kernel/printk.c +++ b/kernel/printk.c @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include #include #include /* For in_interrupt() */ @@ -162,6 +164,61 @@ out: __setup("log_buf_len=", log_buf_len_setup); +#ifdef CONFIG_BOOT_PRINTK_DELAY + +static unsigned int boot_delay; /* msecs delay after each printk during bootup */ +static unsigned long long printk_delay_msec; /* per msec, based on boot_delay */ + +static int __init boot_delay_setup(char *str) +{ + unsigned long lpj; + unsigned long long loops_per_msec; + + lpj = preset_lpj ? preset_lpj : 1000000; /* some guess */ + loops_per_msec = (unsigned long long)lpj / 1000 * HZ; + + get_option(&str, &boot_delay); + if (boot_delay > 10 * 1000) + boot_delay = 0; + + printk_delay_msec = loops_per_msec; + printk(KERN_DEBUG "boot_delay: %u, preset_lpj: %ld, lpj: %lu, " + "HZ: %d, printk_delay_msec: %llu\n", + boot_delay, preset_lpj, lpj, HZ, printk_delay_msec); + return 1; +} +__setup("boot_delay=", boot_delay_setup); + +static void boot_delay_msec(void) +{ + unsigned long long k; + unsigned long timeout; + + if (boot_delay == 0 || system_state != SYSTEM_BOOTING) + return; + + k = (unsigned long long)printk_delay_msec * boot_delay; + + timeout = jiffies + msecs_to_jiffies(boot_delay); + while (k) { + k--; + cpu_relax(); + /* + * use (volatile) jiffies to prevent + * compiler reduction; loop termination via jiffies + * is secondary and may or may not happen. + */ + if (time_after(jiffies, timeout)) + break; + touch_nmi_watchdog(); + } +} +#else +static inline void boot_delay_msec(void) +{ +} +#endif + /* * Commands to do_syslog: * @@ -527,6 +584,8 @@ asmlinkage int vprintk(const char *fmt, va_list args) static char printk_buf[1024]; static int log_level_unknown = 1; + boot_delay_msec(); + preempt_disable(); if (unlikely(oops_in_progress) && printk_cpu == smp_processor_id()) /* If a crash is occurring during printk() on this CPU,