From: Michael Kelley <mikelley@microsoft.com>
To: "virtualization@lists.linux-foundation.org"
<virtualization@lists.linux-foundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"daniel.lezcano@linaro.org" <daniel.lezcano@linaro.org>,
"jgross@suse.com" <jgross@suse.com>,
"akataria@vmware.com" <akataria@vmware.com>,
"olaf@aepfle.de" <olaf@aepfle.de>,
"apw@canonical.com" <apw@canonical.com>,
vkuznets <vkuznets@redhat.com>,
"jasowang@redhat.com" <jasowang@redhat.com>,
"marcelo.cerri@canonical.com" <marcelo.cerri@canonical.com>,
KY Srinivasan <kys@microsoft.com>
Cc: Michael Kelley <mikelley@microsoft.com>
Subject: [PATCH 2/2] i8253: Fix PIT shutdown quirk on Hyper-V
Date: Thu, 1 Nov 2018 17:32:32 +0000 [thread overview]
Message-ID: <1541093509-10576-1-git-send-email-mikelley@microsoft.com> (raw)
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
reply other threads:[~2018-11-01 17:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1541093509-10576-1-git-send-email-mikelley@microsoft.com \
--to=mikelley@microsoft.com \
--cc=akataria@vmware.com \
--cc=apw@canonical.com \
--cc=daniel.lezcano@linaro.org \
--cc=jasowang@redhat.com \
--cc=jgross@suse.com \
--cc=kys@microsoft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo.cerri@canonical.com \
--cc=olaf@aepfle.de \
--cc=tglx@linutronix.de \
--cc=virtualization@lists.linux-foundation.org \
--cc=vkuznets@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).