timer/hpet: many bug fixes and performance improvements + sdfgen bumped to 0.29.0#653
Open
dreamliner787-9 wants to merge 11 commits intomainfrom
Open
timer/hpet: many bug fixes and performance improvements + sdfgen bumped to 0.29.0#653dreamliner787-9 wants to merge 11 commits intomainfrom
dreamliner787-9 wants to merge 11 commits intomainfrom
Conversation
b0075ed to
f86010f
Compare
terryzbai
reviewed
Mar 4, 2026
midnightveil
reviewed
Mar 4, 2026
drivers/timer/hpet/timer.c
Outdated
Comment on lines
+104
to
+106
| __uint128_t counter_as_fs = (__uint128_t)ticks * (__uint128_t)tick_period_fs; | ||
| uint64_t rem = 0; | ||
| return udiv128by64to64(HIGH_WORD(counter_as_fs), LOW_WORD(counter_as_fs), 1000000, &rem); |
Contributor
There was a problem hiding this comment.
I feel like there's a better way to do this...
Also we have defines for e.g. NS_IN_S, no need to hardcode this constant.
Contributor
There was a problem hiding this comment.
Although I guess we've already had the timer-conversion functions discussion, so maybe I should leave this as is for now.
Contributor
Author
There was a problem hiding this comment.
The number is for converting femtoseconds in nanosecond, I've added a constant as you suggested.
3aa1b03 to
b859521
Compare
f1dbd45 to
e650b0b
Compare
e650b0b to
592acd6
Compare
592acd6 to
0ed54f5
Compare
3 tasks
0ed54f5 to
ca8bd7a
Compare
- Removed unused constants. - Switched from Message Signalled Interrupt (MSI) to legacy I/O APIC based interrupt routing. As not all HPET implementations support MSI, and each individual machine will have different permitted I/O APIC routing for the HPET. While legacy routing guarantees that comparator 0's IRQ is always wired to I/O APIC pin 2. Which keep things simple across different machines. - Made timeout calculation more accurate by doing all math in-terms of ticks rather than nanoseconds. To avoid needless conversions between ticks and nanoseconds. - Fixed potential overflow when converting from large nanosecond timeouts to ticks by using 128-bit wide integer math. - Stop, reset the main counter and don't start it until we have finished initialising the comparator. Rather than leaving it at whatever stale value that was there before. - Made all MMIO accesses volatile. - Leave comparator 0's IRQ masked until the first timeout request to prevent IRQs before the driver go passive. Signed-off-by: Bill Nguyen <bill.nguyen@unsw.edu.au>
Signed-off-by: Bill Nguyen <bill.nguyen@unsw.edu.au>
To reduce perceived timer drift on platform that take a long time to print to console, e.g. x86. Signed-off-by: Bill Nguyen <bill.nguyen@unsw.edu.au>
Signed-off-by: Bill Nguyen <bill.nguyen@unsw.edu.au>
- Added support for "x86_64_generic_vtx" Microkit platform. - Bumped to sdfgen 0.29.0 to fix IRQ trigger rendering in SDF. - Made the timer IRQ the highest priority IRQ and explained how it is derived. - Fixed typos in metaprogram. Signed-off-by: Bill Nguyen <bill.nguyen@unsw.edu.au>
Signed-off-by: Bill Nguyen <bill.nguyen@unsw.edu.au>
Signed-off-by: Bill Nguyen <bill.nguyen@unsw.edu.au>
Signed-off-by: Bill Nguyen <bill.nguyen@unsw.edu.au>
Signed-off-by: Bill Nguyen <bill.nguyen@unsw.edu.au>
Signed-off-by: Bill Nguyen <bill.nguyen@unsw.edu.au>
Signed-off-by: Bill Nguyen <bill.nguyen@unsw.edu.au>
ca8bd7a to
cdbd7bb
Compare
63c7770 to
cdbd7bb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
drivers/timer/hpet:cpuid. Otherwise, it fallback to reading time from the HPET as before.hpettotsc_hpet.CI:
tools:examples/*:examples/timer:examples/echo_server: