On 05/02/2022 10:41, Mark Cave-Ayland wrote:
On 31/01/2022 17:15, Glenn Washburn wrote:
Instead of using a constant frequency for all CPUs, which have varying frequencies, use the time frequency as returned by the processor. This fixes issues where delays from ciface_milliseconds were not corresponding to elapsed time as given by the real time clock on certain platforms, eg. QEMU's mac99 machine.
Signed-off-by: Glenn Washburn development@efficientek.com
Mark, if I missed something in the commit message, feel free to make edits as you see fit.
Glenn
I think just a small change to the first sentence: "Instead of using a constant frequency for all CPUs, use the processor timebase frequency provided by QEMU".
Other than that it looks good to me, so I'm happy to apply it to master if no-one else has any further comments.
arch/ppc/qemu/methods.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/ppc/qemu/methods.c b/arch/ppc/qemu/methods.c index 930b47c..a423b9f 100644 --- a/arch/ppc/qemu/methods.c +++ b/arch/ppc/qemu/methods.c @@ -126,7 +126,8 @@ ciface_quiesce( unsigned long args[], unsigned long ret[] ) } /* ( -- ms ) */ -#define TIMER_FREQUENCY 16600000ULL +/* From drivers/timer.c */ +extern unsigned long timer_freq; static void ciface_milliseconds( unsigned long args[], unsigned long ret[] ) @@ -146,7 +147,7 @@ ciface_milliseconds( unsigned long args[], unsigned long ret[] ) : "cc"); ticks = (((unsigned long long)tbu) << 32) | (unsigned long long)tbl; - msecs = (1000 * ticks) / TIMER_FREQUENCY; + msecs = (1000 * ticks) / timer_freq; PUSH( msecs ); }
Thanks - no further comments, so I've pushed this to git master with the updated commit message.
ATB,
Mark.