[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <tip-4c45c5167c9563b1a2eee3e2fe954621355e4ca8@git.kernel.org>
Date: Sun, 22 Jan 2017 01:08:03 -0800
From: tip-bot for Jiri Slaby <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: tglx@...utronix.de, hpa@...or.com, mingo@...nel.org,
jslaby@...e.cz, linux-kernel@...r.kernel.org, peterz@...radead.org,
andy.shevchenko@...il.com, torvalds@...ux-foundation.org
Subject: [tip:timers/core] x86/timer: Make delay() work during early bootup
Commit-ID: 4c45c5167c9563b1a2eee3e2fe954621355e4ca8
Gitweb: http://git.kernel.org/tip/4c45c5167c9563b1a2eee3e2fe954621355e4ca8
Author: Jiri Slaby <jslaby@...e.cz>
AuthorDate: Thu, 19 Jan 2017 12:47:30 +0100
Committer: Ingo Molnar <mingo@...nel.org>
CommitDate: Sun, 22 Jan 2017 10:03:12 +0100
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@...e.cz>
Reviewed-by: Andy Shevchenko <andy.shevchenko@...il.com>
Acked-by: Thomas Gleixner <tglx@...utronix.de>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Link: http://lkml.kernel.org/r/20170119114730.2670-1-jslaby@suse.cz
[ Minor edits. ]
Signed-off-by: Ingo Molnar <mingo@...nel.org>
---
arch/x86/lib/delay.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/lib/delay.c b/arch/x86/lib/delay.c
index 073d1f1..a8e91ae 100644
--- a/arch/x86/lib/delay.c
+++ b/arch/x86/lib/delay.c
@@ -156,13 +156,13 @@ EXPORT_SYMBOL(__delay);
inline void __const_udelay(unsigned long xloops)
{
+ unsigned long lpj = this_cpu_read(cpu_info.loops_per_jiffy) ? : loops_per_jiffy;
int d0;
xloops *= 4;
asm("mull %%edx"
:"=d" (xloops), "=&a" (d0)
- :"1" (xloops), "0"
- (this_cpu_read(cpu_info.loops_per_jiffy) * (HZ/4)));
+ :"1" (xloops), "0" (lpj * (HZ / 4)));
__delay(++xloops);
}
Powered by blists - more mailing lists