Opened 2 years ago

Last modified 2 years ago

#17380 new bug

Haiku under qemu-system-riscv64, system timer issues

Reported by: kallisti5 Owned by: nobody
Priority: normal Milestone: Unscheduled
Component: System/Kernel Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Platform: riscv64

Description

There's some kind of timer issue when booting Haiku riscv64 under qemu. The CPU usage is erratic, and in a few minutes Haiku reports the uptime as 2 hours+.

Test command:

qemu-system-riscv64 -m 2048 -M virt -kernel firmware/u-boot/riscv64/qemu/u-boot.bin -device ati-vga -drive file=haiku-mmc.image,format=raw,if=virtio -usb -device usb-ehci,id=echi -device usb-kbd -device usb-tablet

Attachments (1)

goldfish-rtc.png (70.8 KB ) - added by kallisti5 2 years ago.
goldfish-rtc

Download all attachments as: .zip

Change History (11)

comment:1 by korli, 2 years ago

Version: R1/beta3R1/Development

comment:2 by X512, 2 years ago

Yes, timer resolution is currently hardcoded to 1MHz for now (HiFive Unmatched settings). Calculation from system timer to BeOS time (microseconds) is needed. Timer resolution is already received in kernel args.

comment:3 by kallisti5, 2 years ago

ah. right.

src/system/kernel/arch/riscv64/arch_real_time_clock.cpp

comment:4 by kallisti5, 2 years ago

Commenting out the existing code on qemu gives:

timerFrequency: 10000000
system_time_conversion_factor: 429496729

comment:5 by X512, 2 years ago

Implementing timer calculation may be a bit tricky because resolution can be bigger or less then system_time() and bigtime_t resolution.

comment:6 by X512, 2 years ago

x86 calculation code seems not handle small resolutions.

by kallisti5, 2 years ago

Attachment: goldfish-rtc.png added

goldfish-rtc

comment:7 by kallisti5, 2 years ago

do we potentially need a driver for the individual rtc?

qemu uses google,goldfish-rtc per fdt. not sure how useful that is though since this code is pretty early.

comment:9 by X512, 2 years ago

do we potentially need a driver for the individual rtc?

Yes, we need. I currently implemented only RTC with custom HTIF call that is supported only in my custom TinyEMU patches.

Note that system timer and RTC are independent things and it may have different hardware time sources that cause drifting between them.

comment:10 by X512, 2 years ago

HiFive Unmatched seems used different RTC that is a part of power controller. I currently use network time and WiFi to get time at boot.

Note: See TracTickets for help on using tickets.