Skip to content

Commit 35b69a4

Browse files
kelleymhKAGA-KOKO
authored andcommitted
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
1 parent 71e5602 commit 35b69a4

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

drivers/clocksource/i8253.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020
DEFINE_RAW_SPINLOCK(i8253_lock);
2121
EXPORT_SYMBOL(i8253_lock);
2222

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+
2330
#ifdef CONFIG_CLKSRC_I8253
2431
/*
2532
* Since the PIT overflows every tick, its not very useful
@@ -109,8 +116,11 @@ static int pit_shutdown(struct clock_event_device *evt)
109116
raw_spin_lock(&i8253_lock);
110117

111118
outb_p(0x30, PIT_MODE);
112-
outb_p(0, PIT_CH0);
113-
outb_p(0, PIT_CH0);
119+
120+
if (i8253_clear_counter_on_shutdown) {
121+
outb_p(0, PIT_CH0);
122+
outb_p(0, PIT_CH0);
123+
}
114124

115125
raw_spin_unlock(&i8253_lock);
116126
return 0;

include/linux/i8253.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#define PIT_LATCH ((PIT_TICK_RATE + HZ/2) / HZ)
2222

2323
extern raw_spinlock_t i8253_lock;
24+
extern bool i8253_clear_counter_on_shutdown;
2425
extern struct clock_event_device i8253_clockevent;
2526
extern void clockevent_i8253_init(bool oneshot);
2627

0 commit comments

Comments
 (0)