From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59268) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XmhWz-0004kX-9j for qemu-devel@nongnu.org; Fri, 07 Nov 2014 06:16:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XmhWu-00088H-Bp for qemu-devel@nongnu.org; Fri, 07 Nov 2014 06:16:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44630) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XmhWu-00086y-5C for qemu-devel@nongnu.org; Fri, 07 Nov 2014 06:16:36 -0500 Message-ID: <545CAA03.2050906@redhat.com> Date: Fri, 07 Nov 2014 12:16:19 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <20141107103123.6136.18545.stgit@PASHA-ISP> <20141107103133.6136.9367.stgit@PASHA-ISP> In-Reply-To: <20141107103133.6136.9367.stgit@PASHA-ISP> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC PATCH v4 01/25] acpi: accurate overflow check List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Pavel Dovgalyuk , qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, peter.crosthwaite@xilinx.com, alex.bennee@linaro.org, mark.burton@greensocs.com, real@ispras.ru, batuzovk@ispras.ru, maria.klimushenkova@ispras.ru, afaerber@suse.de, fred.konrad@greensocs.com On 07/11/2014 11:31, Pavel Dovgalyuk wrote: > Compare clock in ns, because acpi_pm_tmr_update uses rounded > to ns value instead of ticks. > > Signed-off-by: Pavel Dovgalyuk > --- > hw/acpi/core.c | 7 +++++-- > 1 files changed, 5 insertions(+), 2 deletions(-) > > diff --git a/hw/acpi/core.c b/hw/acpi/core.c > index a7368fb..51913d6 100644 > --- a/hw/acpi/core.c > +++ b/hw/acpi/core.c > @@ -376,8 +376,11 @@ static void acpi_notify_wakeup(Notifier *notifier, void *data) > /* ACPI PM1a EVT */ > uint16_t acpi_pm1_evt_get_sts(ACPIREGS *ar) > { > - int64_t d = acpi_pm_tmr_get_clock(); > - if (d >= ar->tmr.overflow_time) { > + /* Compare ns-clock, not PM timer ticks, because > + acpi_pm_tmr_update function uses ns for setting the timer. */ > + int64_t d = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); > + if (d >= muldiv64(ar->tmr.overflow_time, > + get_ticks_per_sec(), PM_TIMER_FREQUENCY)) { > ar->pm1.evt.sts |= ACPI_BITMASK_TIMER_STATUS; > } > return ar->pm1.evt.sts; > Reviewed-by: Paolo Bonzini The same muldiv64 is in acpi_pm_tmr_update, it could be extracted to a separate function if you so wish. Paolo