]> git.baikalelectronics.ru Git - kernel.git/commit
x86/timer: Make delay() work during early bootup
authorJiri Slaby <jslaby@suse.cz>
Thu, 19 Jan 2017 11:47:30 +0000 (12:47 +0100)
committerIngo Molnar <mingo@kernel.org>
Sun, 22 Jan 2017 09:03:12 +0000 (10:03 +0100)
commit56c4ed1543d19a59b60a31a8437ecd1bc551415b
tree4a248dcdcdc4783cb0173be4d30825601e698a68
parentc88d4547f034c073cc914698b92503aa18fbf022
x86/timer: Make delay() work during early bootup

When a panic happens during bootup, "Rebooting in X seconds.." is
shown, but reboot happens immediatelly. It is because panic() uses mdelay()
and mdelay() calls __const_udelay() immediately, which does not
work while booting.

The per_cpu cpu_info.loops_per_jiffy value is not initialized yet, so
__const_udelay() actually multiplies the number of loops by zero. This
results in __const_udelay() to delay the execution only by a nanosecond
or so.

So check whether cpu_info.loops_per_jiffy is zero and use
loops_per_jiffy in that case. mdelay() will not be so precise without
proper calibration, but it works relatively well.

Before:

  [    0.170039] delaying 100ms
  [    0.170828] done

After

  [    0.214042] delaying 100ms
  [    0.313974] done

I do not think the added check matters given we are about to spin the
processor in the next few hundred cycles.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20170119114730.2670-1-jslaby@suse.cz
[ Minor edits. ]
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/lib/delay.c