diff options
author | Michael Kelley <mikelley@microsoft.com> | 2018-11-03 23:48:54 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2018-11-04 05:04:46 -0500 |
commit | 35b69a420bfb56b7b74cb635ea903db05e357bec (patch) | |
tree | 61e86bf8c336ee41ba3c5f0cc4fa1fbed3686cc7 | |
parent | 71e56028173bc84f01456a5679d8be9d681b49f1 (diff) |
clockevents/drivers/i8253: Add support for PIT shutdown quirk
Add support for platforms where pit_shutdown() doesn't work because of a
quirk in the PIT emulation. On these platforms setting the counter register
to zero causes the PIT to start running again, negating the shutdown.
Provide a global variable that controls whether the counter register is
zero'ed, which platform specific code can override.
Signed-off-by: Michael Kelley <mikelley@microsoft.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>
Cc: "devel@linuxdriverproject.org" <devel@linuxdriverproject.org>
Cc: "daniel.lezcano@linaro.org" <daniel.lezcano@linaro.org>
Cc: "virtualization@lists.linux-foundation.org" <virtualization@lists.linux-foundation.org>
Cc: "jgross@suse.com" <jgross@suse.com>
Cc: "akataria@vmware.com" <akataria@vmware.com>
Cc: "olaf@aepfle.de" <olaf@aepfle.de>
Cc: "apw@canonical.com" <apw@canonical.com>
Cc: vkuznets <vkuznets@redhat.com>
Cc: "jasowang@redhat.com" <jasowang@redhat.com>
Cc: "marcelo.cerri@canonical.com" <marcelo.cerri@canonical.com>
Cc: KY Srinivasan <kys@microsoft.com>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/1541303219-11142-2-git-send-email-mikelley@microsoft.com
-rw-r--r-- | drivers/clocksource/i8253.c | 14 | ||||
-rw-r--r-- | include/linux/i8253.h | 1 |
2 files changed, 13 insertions, 2 deletions
diff --git a/drivers/clocksource/i8253.c b/drivers/clocksource/i8253.c index 9c38895542f4..d4350bb10b83 100644 --- a/drivers/clocksource/i8253.c +++ b/drivers/clocksource/i8253.c | |||
@@ -20,6 +20,13 @@ | |||
20 | DEFINE_RAW_SPINLOCK(i8253_lock); | 20 | DEFINE_RAW_SPINLOCK(i8253_lock); |
21 | EXPORT_SYMBOL(i8253_lock); | 21 | EXPORT_SYMBOL(i8253_lock); |
22 | 22 | ||
23 | /* | ||
24 | * Handle PIT quirk in pit_shutdown() where zeroing the counter register | ||
25 | * restarts the PIT, negating the shutdown. On platforms with the quirk, | ||
26 | * platform specific code can set this to false. | ||
27 | */ | ||
28 | bool i8253_clear_counter_on_shutdown __ro_after_init = true; | ||
29 | |||
23 | #ifdef CONFIG_CLKSRC_I8253 | 30 | #ifdef CONFIG_CLKSRC_I8253 |
24 | /* | 31 | /* |
25 | * Since the PIT overflows every tick, its not very useful | 32 | * Since the PIT overflows every tick, its not very useful |
@@ -109,8 +116,11 @@ static int pit_shutdown(struct clock_event_device *evt) | |||
109 | raw_spin_lock(&i8253_lock); | 116 | raw_spin_lock(&i8253_lock); |
110 | 117 | ||
111 | outb_p(0x30, PIT_MODE); | 118 | outb_p(0x30, PIT_MODE); |
112 | outb_p(0, PIT_CH0); | 119 | |
113 | outb_p(0, PIT_CH0); | 120 | if (i8253_clear_counter_on_shutdown) { |
121 | outb_p(0, PIT_CH0); | ||
122 | outb_p(0, PIT_CH0); | ||
123 | } | ||
114 | 124 | ||
115 | raw_spin_unlock(&i8253_lock); | 125 | raw_spin_unlock(&i8253_lock); |
116 | return 0; | 126 | return 0; |
diff --git a/include/linux/i8253.h b/include/linux/i8253.h index e6bb36a97519..8336b2f6f834 100644 --- a/include/linux/i8253.h +++ b/include/linux/i8253.h | |||
@@ -21,6 +21,7 @@ | |||
21 | #define PIT_LATCH ((PIT_TICK_RATE + HZ/2) / HZ) | 21 | #define PIT_LATCH ((PIT_TICK_RATE + HZ/2) / HZ) |
22 | 22 | ||
23 | extern raw_spinlock_t i8253_lock; | 23 | extern raw_spinlock_t i8253_lock; |
24 | extern bool i8253_clear_counter_on_shutdown; | ||
24 | extern struct clock_event_device i8253_clockevent; | 25 | extern struct clock_event_device i8253_clockevent; |
25 | extern void clockevent_i8253_init(bool oneshot); | 26 | extern void clockevent_i8253_init(bool oneshot); |
26 | 27 | ||