* [PATCH] HPET: Fix HPET readout for small deltas
@ 2010-11-29 15:09 Borislav Petkov
2010-11-29 15:27 ` Markus Trippelsdorf
0 siblings, 1 reply; 2+ messages in thread
From: Borislav Petkov @ 2010-11-29 15:09 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Markus Trippelsdorf, Borislav Petkov, john stultz,
linux-kernel@vger.kernel.org, hpa@linux.intel.com, Ingo Molnar,
Herrmann3, Andreas, heiko.carstens@de.ibm.com,
a.p.zijlstra@chello.nl, avi@redhat.com, mtosatti@redhat.com
Some HPET implementations might require longer delay when accessing the
HPET than what 995bd3bb5c78f3ff71339803c0b8337ed36d64fb established (8
cycles). Generally, the proper value should be programmed by BIOS and
written into the ACPI HPET table as the main counter minimum tick in
periodic mode (offset 53).
We assume that value as the minimum value a delta can be in order to
reprogram the HPET successfully. For BIOSen which contain crap, we fall
back to a default value of 128 cycles which should be sensible on all
more or less sane HPET implementations.
LKML-Reference: <20101026112052.GA1672@arch.trippelsdorf.de>
Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
---
As noted before, this patch fixes the sluggishness issue on Markus' and
my machine. And we definitely need some kind of fix for .37.
arch/x86/include/asm/hpet.h | 1 +
arch/x86/kernel/acpi/boot.c | 10 +++++++---
arch/x86/kernel/hpet.c | 3 ++-
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/arch/x86/include/asm/hpet.h b/arch/x86/include/asm/hpet.h
index 2c392d6..01d9480 100644
--- a/arch/x86/include/asm/hpet.h
+++ b/arch/x86/include/asm/hpet.h
@@ -68,6 +68,7 @@ extern unsigned long force_hpet_address;
extern u8 hpet_blockid;
extern int hpet_force_user;
extern u8 hpet_msi_disable;
+extern u16 hpet_min_tick;
extern int is_hpet_enabled(void);
extern int hpet_enable(void);
extern void hpet_disable(void);
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 71232b9..91a46bc 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -772,9 +772,6 @@ static int __init acpi_parse_hpet(struct acpi_table_header *table)
hpet_address >>= 32;
}
#endif
- printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
- hpet_tbl->id, hpet_address);
-
/*
* Allocate and initialize the HPET firmware resource for adding into
* the resource tree during the lateinit timeframe.
@@ -790,6 +787,13 @@ static int __init acpi_parse_hpet(struct acpi_table_header *table)
hpet_res->start = hpet_address;
hpet_res->end = hpet_address + (1 * 1024) - 1;
+ /* Accept only sensible values written by BIOS */
+ if (hpet_tbl->minimum_tick < hpet_min_tick)
+ hpet_min_tick = hpet_tbl->minimum_tick;
+
+ printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx min tick: %d\n",
+ hpet_tbl->id, hpet_address, hpet_min_tick);
+
return 0;
}
diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c
index ae03cab..a0b790a 100644
--- a/arch/x86/kernel/hpet.c
+++ b/arch/x86/kernel/hpet.c
@@ -40,6 +40,7 @@ u8 hpet_msi_disable;
static unsigned long hpet_num_timers;
#endif
static void __iomem *hpet_virt_address;
+u16 hpet_min_tick = 0x80;
struct hpet_dev {
struct clock_event_device evt;
@@ -408,7 +409,7 @@ static int hpet_next_event(unsigned long delta,
*/
res = (s32)(cnt - hpet_readl(HPET_COUNTER));
- return res < 8 ? -ETIME : 0;
+ return res < hpet_min_tick ? -ETIME : 0;
}
static void hpet_legacy_set_mode(enum clock_event_mode mode,
--
1.7.3.1.50.g1e633
--
Regards/Gruss,
Boris.
Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
General Managers: Alberto Bozzo, Andrew Bowd
Registration: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] HPET: Fix HPET readout for small deltas
2010-11-29 15:09 [PATCH] HPET: Fix HPET readout for small deltas Borislav Petkov
@ 2010-11-29 15:27 ` Markus Trippelsdorf
0 siblings, 0 replies; 2+ messages in thread
From: Markus Trippelsdorf @ 2010-11-29 15:27 UTC (permalink / raw)
To: Borislav Petkov
Cc: Thomas Gleixner, Borislav Petkov, john stultz,
linux-kernel@vger.kernel.org, hpa@linux.intel.com, Ingo Molnar,
Herrmann3, Andreas, heiko.carstens@de.ibm.com,
a.p.zijlstra@chello.nl, avi@redhat.com, mtosatti@redhat.com
On 2010.11.29 at 16:09 +0100, Borislav Petkov wrote:
>
> Some HPET implementations might require longer delay when accessing the
> HPET than what 995bd3bb5c78f3ff71339803c0b8337ed36d64fb established (8
> cycles). Generally, the proper value should be programmed by BIOS and
> written into the ACPI HPET table as the main counter minimum tick in
> periodic mode (offset 53).
>
> We assume that value as the minimum value a delta can be in order to
> reprogram the HPET successfully. For BIOSen which contain crap, we fall
> back to a default value of 128 cycles which should be sensible on all
> more or less sane HPET implementations.
>
> LKML-Reference: <20101026112052.GA1672@arch.trippelsdorf.de>
> Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
> ---
>
> As noted before, this patch fixes the sluggishness issue on Markus' and
> my machine. And we definitely need some kind of fix for .37.
Yes. Just a minor note, the comment in hpet.c should also be updated:
diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c
index a0b790a..cfbbc94 100644
--- a/arch/x86/kernel/hpet.c
+++ b/arch/x86/kernel/hpet.c
@@ -403,9 +403,9 @@ static int hpet_next_event(unsigned long delta,
* move us behind that point easily. Now instead of reading
* the compare register back several times, we make the ETIME
* decision based on the following: Return ETIME if the
- * counter value after the write is less than 8 HPET cycles
- * away from the event or if the counter is already ahead of
- * the event.
+ * counter value after the write is less than hpet_min_tick
+ * HPET cycles away from the event or if the counter is already
+ * ahead of the event.
*/
res = (s32)(cnt - hpet_readl(HPET_COUNTER));
--
Markus
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-11-29 15:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-29 15:09 [PATCH] HPET: Fix HPET readout for small deltas Borislav Petkov
2010-11-29 15:27 ` Markus Trippelsdorf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox