[PATCH] x86: Do not try to disable hpet if it hasn't been initializedbefore

From: Jeremy Fitzhardinge
Date: Thu Jul 22 2010 - 19:22:51 EST


[ x86 folk: While this patch is just a generic x86 bugfix, it really only affects
the Xen pv-on-hvm patch series that I'm going to post shortly. Do you want to
commit it separately via tip.git, or are you OK with me sending it to Linus
directly? - J ]

hpet_disable is called unconditionally on machine reboot if hpet support
is compiled in the kernel.
hpet_disable only checks if the machine is hpet capable but doesn't make
sure that hpet has been initialized.

Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Acked-by: Venkatesh Pallipadi <venki@xxxxxxxxxx>

diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c
index a198b7c..9e90dac 100644
--- a/arch/x86/kernel/hpet.c
+++ b/arch/x86/kernel/hpet.c
@@ -964,16 +964,18 @@ fs_initcall(hpet_late_init);

void hpet_disable(void)
{
- if (is_hpet_capable()) {
- unsigned int cfg = hpet_readl(HPET_CFG);
+ unsigned int cfg;

- if (hpet_legacy_int_enabled) {
- cfg &= ~HPET_CFG_LEGACY;
- hpet_legacy_int_enabled = 0;
- }
- cfg &= ~HPET_CFG_ENABLE;
- hpet_writel(cfg, HPET_CFG);
+ if (!is_hpet_capable() || !hpet_address || !hpet_virt_address)
+ return;
+
+ cfg = hpet_readl(HPET_CFG);
+ if (hpet_legacy_int_enabled) {
+ cfg &= ~HPET_CFG_LEGACY;
+ hpet_legacy_int_enabled = 0;
}
+ cfg &= ~HPET_CFG_ENABLE;
+ hpet_writel(cfg, HPET_CFG);
}

#ifdef CONFIG_HPET_EMULATE_RTC


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/