LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Michael Kelley <mikelley@microsoft.com>
Cc: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"x86@kernel.org" <x86@kernel.org>,
"daniel.lezcano@linaro.org" <daniel.lezcano@linaro.org>,
"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>,
Stephen Hemminger <sthemmin@microsoft.com>,
KY Srinivasan <kys@microsoft.com>
Subject: Re: [PATCH v2 char-misc 1/1] x86/hyperv: Fix PIT shutdown quirk
Date: Tue, 30 Oct 2018 09:35:59 +0100 (CET) [thread overview]
Message-ID: <alpine.DEB.2.21.1810300859420.5984@nanos.tec.linutronix.de> (raw)
In-Reply-To: <1540226025-45092-1-git-send-email-mikelley@microsoft.com>
Michael,
On Mon, 22 Oct 2018, Michael Kelley wrote:
> pit_shutdown() doesn't work on Hyper-V because of a quirk in the
> PIT emulation. After shutdown the emulated PIT continues to interrupt
> @18.2 HZ. This problem exists in all versions of Hyper-V and just
> had not previously been noticed. So replace the normal PIT shutdown
> function with an alternate version that works on Hyper-V.
>
> The alternate shutdown function could go in the i8253.c module,
> but it seems better to keep the hack with the Hyper-V code rather
> than clutter up i8253.c with #ifdef CONFIG_HYPERV.
You can avoid the ideffery completely. Something like the uncompiled patch
(lacks comments) below keeps everything in i8253 and should just work.
Thanks,
tglx
8<-------------------
diff --git a/drivers/clocksource/i8253.c b/drivers/clocksource/i8253.c
index 9c38895542f4..9b5d2259c2e5 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,9 +110,10 @@ 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);
-
+ if (!hypervisor_is_mshyperv()) {
+ outb_p(0, PIT_CH0);
+ outb_p(0, PIT_CH0);
+ }
raw_spin_unlock(&i8253_lock);
return 0;
}
diff --git a/include/linux/hypervisor.h b/include/linux/hypervisor.h
index fc08b433c856..2ab7303675f3 100644
--- a/include/linux/hypervisor.h
+++ b/include/linux/hypervisor.h
@@ -10,6 +10,7 @@
#ifdef CONFIG_X86
#include <asm/jailhouse_para.h>
+#include <asm/hypervisor.h>
#include <asm/x86_init.h>
static inline void hypervisor_pin_vcpu(int cpu)
@@ -17,6 +18,11 @@ static inline void hypervisor_pin_vcpu(int cpu)
x86_platform.hyper.pin_vcpu(cpu);
}
+static inline bool hypervisor_is_mshyperv(void)
+{
+ return hypervisor_is_type(X86_HYPER_MS_HYPERV);
+}
+
#else /* !CONFIG_X86 */
#include <linux/of.h>
@@ -30,6 +36,11 @@ static inline bool jailhouse_paravirt(void)
return of_find_compatible_node(NULL, NULL, "jailhouse,cell");
}
+static inline bool hypervisor_is_mshyperv(void)
+{
+ return false;
+}
+
#endif /* !CONFIG_X86 */
#endif /* __LINUX_HYPEVISOR_H */
next prev parent reply other threads:[~2018-10-30 8:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-22 16:34 Michael Kelley
2018-10-30 8:35 ` Thomas Gleixner [this message]
2018-10-30 13:41 ` Michael Kelley
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=alpine.DEB.2.21.1810300859420.5984@nanos.tec.linutronix.de \
--to=tglx@linutronix.de \
--cc=apw@canonical.com \
--cc=daniel.lezcano@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=jasowang@redhat.com \
--cc=kys@microsoft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo.cerri@canonical.com \
--cc=mikelley@microsoft.com \
--cc=olaf@aepfle.de \
--cc=sthemmin@microsoft.com \
--cc=vkuznets@redhat.com \
--cc=x86@kernel.org \
--subject='Re: [PATCH v2 char-misc 1/1] x86/hyperv: Fix PIT shutdown quirk' \
/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
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).