From: Miao Yan Date: Mon, 27 Jul 2015 11:16:07 +0000 (+0800) Subject: x86: Add a 'pause' instruction in __udelay() for QEMU target X-Git-Tag: v2015.10-rc2~410^2~69 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=417576c2f1f2c5392cd69ef3ed33668cc9900e6e;p=oweals%2Fu-boot.git x86: Add a 'pause' instruction in __udelay() for QEMU target When running SMP configuration on QEMU (tcg mode, no kvm), there is a busy loop in start_aps(), calling udelay(), that waits for APs to show up online. However, there is a chance that VCPU1 will be timeout waiting, IOW the secondary VCPUs haven't started their execution yet. This patch adds a 'pause' instruction in __udelay() only for QEMU target, to give other VCPUs a chance to run. When QEMU sees the 'pause' instruction, it will yeild the execution to other CPUs. Signed-off-by: Miao Yan Signed-off-by: Bin Meng Acked-by: Simon Glass Tested-by: Simon Glass --- diff --git a/arch/x86/lib/tsc_timer.c b/arch/x86/lib/tsc_timer.c index 7f5ba2ca6f..0df1af238c 100644 --- a/arch/x86/lib/tsc_timer.c +++ b/arch/x86/lib/tsc_timer.c @@ -355,7 +355,15 @@ void __udelay(unsigned long usec) stop = now + usec * get_tbclk_mhz(); while ((int64_t)(stop - get_ticks()) > 0) +#if defined(CONFIG_QEMU) && defined(CONFIG_SMP) + /* + * Add a 'pause' instruction on qemu target, + * to give other VCPUs a chance to run. + */ + asm volatile("pause"); +#else ; +#endif } int timer_init(void)