All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] i8253: Fix PIT shutdown quirk on Hyper-V
@ 2018-11-01 17:32 Michael Kelley
  0 siblings, 0 replies; only message in thread
From: Michael Kelley @ 2018-11-01 17:32 UTC (permalink / raw)
  To: virtualization, linux-kernel, tglx, daniel.lezcano, jgross,
	akataria, olaf, apw, vkuznets, jasowang, marcelo.cerri,
	KY Srinivasan
  Cc: Michael Kelley

pit_shutdown() doesn't work on Hyper-V because of a quirk in the
PIT emulation. This problem exists in all versions of Hyper-V and
had not been noticed previously. When the counter register is set
to zero, the emulated PIT continues to interrupt @18.2 HZ. So
skip setting the counter register when running on Hyper-V.

Signed-off-by: Michael Kelley <mikelley@microsoft.com>
---
 drivers/clocksource/i8253.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/clocksource/i8253.c b/drivers/clocksource/i8253.c
index 9c38895..62025c8 100644
--- a/drivers/clocksource/i8253.c
+++ b/drivers/clocksource/i8253.c
@@ -10,6 +10,7 @@
 #include <linux/module.h>
 #include <linux/i8253.h>
 #include <linux/smp.h>
+#include <linux/hypervisor.h>
 
 /*
  * Protects access to I/O ports
@@ -109,8 +110,17 @@ static int pit_shutdown(struct clock_event_device *evt)
 	raw_spin_lock(&i8253_lock);
 
 	outb_p(0x30, PIT_MODE);
-	outb_p(0, PIT_CH0);
-	outb_p(0, PIT_CH0);
+
+	/*
+	 * A quirk in Hyper-V's emulation of the PIT causes the PIT
+	 * to continue to run and interrupt @18.2 Hz when the counter
+	 * register is set to zero. So skip setting the counter
+	 * register when running as a guest on Hyper-V.
+	 */
+	if (!hypervisor_is_mshyperv()) {
+		outb_p(0, PIT_CH0);
+		outb_p(0, PIT_CH0);
+	}
 
 	raw_spin_unlock(&i8253_lock);
 	return 0;
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-11-01 17:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-01 17:32 [PATCH 2/2] i8253: Fix PIT shutdown quirk on Hyper-V Michael Kelley

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.