Skip to contentSkip to conversation

x86/timers updates for 4.13

GIT PULL Thomas Gleixner 2 participants 3 messages Jul 3, 2017 – Jul 4, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Linus,

please pull the latest x86-timers-for-linus git tree from:

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86-timers-for-linus

This update contains:

- The final solution for the TSC deadline timer borkage, which is caused by a hardware problem in the TSC_ADJUST/TSC_DEADLINE_TIMER logic.

The problem is documented now fixed with a microcode update, so we can remove the workaround and check for the microcode version. If the microcode is not up to date, then the TSC deadline timer is enabled. If the borkage is fixed by the proper micro code version, then the deadline timer can be used. In both cases the restrictions to the range of the TSC_ADJUST value, which were added as workarounds, are removed.

- A few simple fixes and updates to the timer related x86 code.

Thanks,

tglx

------------------>
Borislav Petkov (1):
x86/hpet: Do not use smp_processor_id() in preemptible code

Dou Liyang (1):
x86/time: Make setup_default_timer_irq() static

Peter Zijlstra (3):
x86/apic: Change the lapic name in deadline mode x86/apic: Add TSC_DEADLINE quirk due to errata x86/tsc: Remove the TSC_ADJUST clamp

Zhenzhong Duan (1):
x86/tsc: Call check_system_tsc_reliable() before unsynchronized_tsc()

 arch/x86/include/asm/setup.h |  1 -
 arch/x86/kernel/apic/apic.c  | 80 ++++++++++++++++++++++++++++++++++++++++++++
 arch/x86/kernel/hpet.c       |  2 +-
 arch/x86/kernel/time.c       |  2 +-
 arch/x86/kernel/tsc.c        |  4 +--
 arch/x86/kernel/tsc_sync.c   | 21 +-----------
 6 files changed, 85 insertions(+), 25 deletions(-)
arch/x86/include/asm/setup.h +0 -1
index ac1d5da14734..e4585a393965 100644
@@ -44,7 +44,6 @@ extern unsigned long saved_video_mode;
 
 extern void reserve_standard_io_resources(void);
 extern void i386_reserve_resources(void);
-extern void setup_default_timer_irq(void);
 
 #ifdef CONFIG_X86_INTEL_MID
 extern void x86_intel_mid_early_setup(void);
arch/x86/kernel/apic/apic.c +80 -0

104 lines not on this page · raw message

arch/x86/kernel/hpet.c +1 -1
index 89ff7af2de50..16f82a3aaec7 100644
@@ -285,7 +285,7 @@ static void hpet_legacy_clockevent_register(void)
 	 * Start hpet with the boot cpu mask and make it
 	 * global after the IO_APIC has been initialized.
 	 */
-	hpet_clockevent.cpumask = cpumask_of(smp_processor_id());
+	hpet_clockevent.cpumask = cpumask_of(boot_cpu_data.cpu_index);
 	clockevents_config_and_register(&hpet_clockevent, hpet_freq,
 					HPET_MIN_PROG_DELTA, 0x7FFFFFFF);
 	global_clock_event = &hpet_clockevent;
arch/x86/kernel/time.c +1 -1
index d39c09119db6..e0754cdbad37 100644
@@ -66,7 +66,7 @@ static struct irqaction irq0  = {
 	.name = "timer"
 };
 
-void __init setup_default_timer_irq(void)
+static void __init setup_default_timer_irq(void)
 {
 	if (!nr_legacy_irqs())
 		return;
arch/x86/kernel/tsc.c +2 -2
index 714dfba6a1e7..a316bdd42a37 100644
@@ -1412,11 +1412,11 @@ void __init tsc_init(void)
 
 	use_tsc_delay();
 
+	check_system_tsc_reliable();
+
 	if (unsynchronized_tsc())
 		mark_tsc_unstable("TSCs unsynchronized");
 
-	check_system_tsc_reliable();
-
 	detect_art();
 }
 
arch/x86/kernel/tsc_sync.c +1 -20
index 728f75378475..7842371bc9e4 100644
@@ -71,13 +71,8 @@ static void tsc_sanitize_first_cpu(struct tsc_adjust *cur, s64 bootval,
 	 * non zero. We don't do that on non boot cpus because physical
 	 * hotplug should have set the ADJUST register to a value > 0 so
 	 * the TSC is in sync with the already running cpus.
-	 *
-	 * But we always force positive ADJUST values. Otherwise the TSC
-	 * deadline timer creates an interrupt storm. We also have to
-	 * prevent values > 0x7FFFFFFF as those wreckage the timer as well.
 	 */
-	if ((bootcpu && bootval != 0) || (!bootcpu && bootval < 0) ||
-	    (bootval > 0x7FFFFFFF)) {
+	if (bootcpu && bootval != 0) {
 		pr_warn(FW_BUG "TSC ADJUST: CPU%u: %lld force to 0\n", cpu,
 			bootval);
 		wrmsrl(MSR_IA32_TSC_ADJUST, 0);
@@ -451,20 +446,6 @@ void check_tsc_sync_target(void)
 	 */
 	cur->adjusted += cur_max_warp;
 
-	/*
-	 * TSC deadline timer stops working or creates an interrupt storm
-	 * with adjust values < 0 and > x07ffffff.
-	 *
-	 * To allow adjust values > 0x7FFFFFFF we need to disable the
-	 * deadline timer and use the local APIC timer, but that requires
-	 * more intrusive changes and we do not have any useful information
-	 * from Intel about the underlying HW wreckage yet.
-	 */
-	if (cur->adjusted < 0)
-		cur->adjusted = 0;
-	if (cur->adjusted > 0x7FFFFFFF)
-		cur->adjusted = 0x7FFFFFFF;
-
 	pr_warn("TSC ADJUST compensate: CPU%u observed %lld warp. Adjust: %lld\n",
 		cpu, cur_max_warp, cur->adjusted);
 
#1 lore raw
Quoted 14 lines · Thomas Gleixner

This update contains:

- The final solution for the TSC deadline timer borkage, which is caused by a hardware problem in the TSC_ADJUST/TSC_DEADLINE_TIMER logic.

The problem is documented now fixed with a microcode update, so we can remove the workaround and check for the microcode version. If the microcode is not up to date, then the TSC deadline timer is enabled. If the borkage is fixed by the proper micro code version, then the deadline timer can be used. In both cases the restrictions to the range of the TSC_ADJUST value, which were added as workarounds, are removed.

Quoted 1 line

- A few simple fixes and updates to the timer related x86 code.

That deadline timer explanation made no sense.

I edited it to what I think you wanted to say in the commit message.

Linus

#2 lore raw
Quoted 15 lines · Linus Torvalds
Quoted 14 lines · Thomas Gleixner

This update contains:

- The final solution for the TSC deadline timer borkage, which is caused by a hardware problem in the TSC_ADJUST/TSC_DEADLINE_TIMER logic.

The problem is documented now fixed with a microcode update, so we can remove the workaround and check for the microcode version. If the microcode is not up to date, then the TSC deadline timer is enabled. If the borkage is fixed by the proper micro code version, then the deadline timer can be used. In both cases the restrictions to the range of the TSC_ADJUST value, which were added as workarounds, are removed.

Quoted 3 lines
Quoted 1 line

- A few simple fixes and updates to the timer related x86 code.

That deadline timer explanation made no sense.

Indeed. Sorry.

Quoted 1 line

I edited it to what I think you wanted to say in the commit message.

Yes. Thank you for fixing it up!

tglx