qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 2/5] mc146818rtc: fix clock lost after scaling c


From: Xiao Guangrong
Subject: Re: [Qemu-devel] [PATCH 2/5] mc146818rtc: fix clock lost after scaling coalesced irq
Date: Thu, 4 May 2017 10:51:18 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0



On 05/03/2017 11:15 PM, Paolo Bonzini wrote:


On 12/04/2017 11:51, address@hidden wrote:
+            int current_irq_coalesced = s->irq_coalesced;
+
+            s->irq_coalesced = (current_irq_coalesced * s->period) / period;
+
+            /*
+             * calculate the lost clock after it is scaled which should be
+             * compensated in the next interrupt.
+             */
+            lost_clock += current_irq_coalesced * s->period -
+                            s->irq_coalesced * period;

This is:

    lost_clock = current_irq_coalesced * s->period -
        (current_irq_coalesced * s->period) / period * period;

i.e.

    /* When switching from a shorter to a longer period, scale down the
     * missing ticks since we expect the OS handler to treat the delayed
     * ticks as longer.  Any leftovers are put back into next_irq_clock.
     *
     * When switching to a shorter period, scale up the missing ticks
     * since we expect the OS handler to treat the delayed ticks as
     * shorter.
     */
    lost_clock = (s->irq_coalesced * s->period) % period;
    s->irq_coalesced = (s->irq_coalesced * s->period) / period;

Is this correct?


Yes, it is correct, it looks smarter, will apply it in the next version.

Thanks!



reply via email to

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