qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] timer question


From: address@hidden
Subject: [Qemu-devel] timer question
Date: Wed, 17 Apr 2013 09:46:59 -0700 (PDT)

Hello everyone. I am writing a device driver on qemu using a PCI card that I modelled bare functionality in so we can test the driver while the board is made. I have a couple of questions that I can't find having been addressed in the past.

The system is x86_64 running Ubuntu. I am using KVM on my gentoo x86_64 machine.

It seems that a dma transfer is instant in qemu as far as reality is concerned. The only way to make the guest see some time passing before some kind of dma interrupt complete fires is to wait to fire the interrupt. I did this using a timer. It seems I should use vm_clock for my timer, but this clock increments even when I should not expect it to. For example, in my MemoryRegion's write ops, if I do printf("time is %lld\n", qemu_get_clock_ns(vm_clock)); twice, I will see a change in the clock. If I put a sleep(1) here the whole simulation will freeze, but time continues.

So when I use a timer based on vm_clock, and I want to have it expire every 20 us (arbitrary selected time) to start the next page in my transfer (the modeled card does scatter/gather DMA) I wind up where 2500 timers that should take 50ms of simulation time actually take many seconds of simulation time because the timer will fire anywhere from ~20-300 microseconds simulation time.

This does not happen if I am not using KVM. It instead seems to increment outside this context. However, this becomes too slow to be usable. (Maybe there are other options for proceeding without KVM that I am not aware of?)

Is there a way I can achieve timing that is synced to actual CPU clock ticks in my devices? I have looked through the code but not found anything.

Here are my start parameters for qemu:

./qemu_bld/x86_64-softmmu/qemu-system-x86_64 -m 1024 -drive file=/home/path/ubuntu.img,if=virtio -net nic,model=virtio -net user -vga std -device pci_test -fsdev local,id=work,path=/home/path/,security_model=mapped -device virtio-9p-pci,fsdev=work,mount_tag=work --enable-kvm

Thanks all.

Steven



reply via email to

[Prev in Thread] Current Thread [Next in Thread]