From: tip-bot for Andreas Herrmann <andreas.herrmann3@amd.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@redhat.com,
andreas.herrmann3@amd.com, jeffm@suse.com, tglx@linutronix.de,
mingo@elte.hu
Subject: [tip:x86/urgent] x86: hpet: fix periodic mode programming on AMD 81xx
Date: Wed, 22 Apr 2009 11:21:31 GMT [thread overview]
Message-ID: <tip-86d855f62fabe344a4f66f509def6594abef9a91@git.kernel.org> (raw)
In-Reply-To: <20090421180037.GA2763@alberich.amd.com>
Commit-ID: 86d855f62fabe344a4f66f509def6594abef9a91
Gitweb: http://git.kernel.org/tip/86d855f62fabe344a4f66f509def6594abef9a91
Author: Andreas Herrmann <andreas.herrmann3@amd.com>
AuthorDate: Tue, 21 Apr 2009 20:00:37 +0200
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Wed, 22 Apr 2009 12:44:55 +0200
x86: hpet: fix periodic mode programming on AMD 81xx
(See http://bugzilla.kernel.org/show_bug.cgi?id=12961)
It partially reverts commit c23e253e67c9d8a91a0ffa33c1f571a17f0a2403
(x86: hpet: stop HPET_COUNTER when programming periodic mode)
HPET on AMD 81xx chipset needs a second write (with HPET_TN_SETVAL
cleared) to T0_CMP register to set the period in periodic mode.
With this patch HPET_COUNTER is still stopped but not reset when HPET
is programmed in periodic mode. This should help to avoid races when
HPET is programmed in periodic mode and fixes a boot time hang that
I've observed on a machine when using 1000HZ.
[ Impact: fix boot time hang on machines with AMD 81xx chipset ]
Signed-off-by: Andreas Herrmann <andreas.herrmann3@amd.com>
Cc: Jeff Mahoney <jeffm@suse.com>
LKML-Reference: <20090421180037.GA2763@alberich.amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/x86/kernel/hpet.c | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c
index 3f0019e..81408b9 100644
--- a/arch/x86/kernel/hpet.c
+++ b/arch/x86/kernel/hpet.c
@@ -236,6 +236,10 @@ static void hpet_stop_counter(void)
unsigned long cfg = hpet_readl(HPET_CFG);
cfg &= ~HPET_CFG_ENABLE;
hpet_writel(cfg, HPET_CFG);
+}
+
+static void hpet_reset_counter(void)
+{
hpet_writel(0, HPET_COUNTER);
hpet_writel(0, HPET_COUNTER + 4);
}
@@ -250,6 +254,7 @@ static void hpet_start_counter(void)
static void hpet_restart_counter(void)
{
hpet_stop_counter();
+ hpet_reset_counter();
hpet_start_counter();
}
@@ -309,7 +314,7 @@ static int hpet_setup_msi_irq(unsigned int irq);
static void hpet_set_mode(enum clock_event_mode mode,
struct clock_event_device *evt, int timer)
{
- unsigned long cfg;
+ unsigned long cfg, cmp, now;
uint64_t delta;
switch (mode) {
@@ -317,12 +322,23 @@ static void hpet_set_mode(enum clock_event_mode mode,
hpet_stop_counter();
delta = ((uint64_t)(NSEC_PER_SEC/HZ)) * evt->mult;
delta >>= evt->shift;
+ now = hpet_readl(HPET_COUNTER);
+ cmp = now + (unsigned long) delta;
cfg = hpet_readl(HPET_Tn_CFG(timer));
/* Make sure we use edge triggered interrupts */
cfg &= ~HPET_TN_LEVEL;
cfg |= HPET_TN_ENABLE | HPET_TN_PERIODIC |
HPET_TN_SETVAL | HPET_TN_32BIT;
hpet_writel(cfg, HPET_Tn_CFG(timer));
+ hpet_writel(cmp, HPET_Tn_CMP(timer));
+ udelay(1);
+ /*
+ * HPET on AMD 81xx needs a second write (with HPET_TN_SETVAL
+ * cleared) to T0_CMP to set the period. The HPET_TN_SETVAL
+ * bit is automatically cleared after the first write.
+ * (See AMD-8111 HyperTransport I/O Hub Data Sheet,
+ * Publication # 24674)
+ */
hpet_writel((unsigned long) delta, HPET_Tn_CMP(timer));
hpet_start_counter();
hpet_print_config();
next prev parent reply other threads:[~2009-04-22 11:22 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-17 15:15 [BUG] IO-APIC + timer doesn't work! Jeff Mahoney
2009-04-18 8:33 ` Jan Kiszka
2009-04-18 19:52 ` Jeff Mahoney
2009-04-18 20:06 ` Ingo Molnar
2009-04-18 20:25 ` Jan Kiszka
2009-04-18 20:32 ` Ingo Molnar
2009-04-18 20:46 ` Jan Kiszka
2009-04-22 10:19 ` Andreas Herrmann
2009-04-22 10:46 ` Ingo Molnar
2009-04-22 17:13 ` Andreas Herrmann
2009-04-22 13:41 ` Jeff Mahoney
2009-04-20 8:58 ` Andreas Herrmann
2009-04-20 14:23 ` Jeff Mahoney
2009-04-21 18:00 ` Andreas Herrmann
2009-04-22 11:21 ` tip-bot for Andreas Herrmann [this message]
2009-04-22 13:54 ` [tip:x86/urgent] x86: hpet: fix periodic mode programming on AMD 81xx tip-bot for Andreas Herrmann
2009-04-20 9:04 ` [BUG] IO-APIC + timer doesn't work! Andreas Herrmann
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=tip-86d855f62fabe344a4f66f509def6594abef9a91@git.kernel.org \
--to=andreas.herrmann3@amd.com \
--cc=hpa@zytor.com \
--cc=jeffm@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
/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 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.