From patchwork Thu Jan 21 19:03:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 8084401 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 463F9BEEE5 for ; Thu, 21 Jan 2016 19:05:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A141F20364 for ; Thu, 21 Jan 2016 19:05:06 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0B98420390 for ; Thu, 21 Jan 2016 19:05:06 +0000 (UTC) Received: from localhost ([::1]:49343 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMKXZ-0007UQ-Cw for patchwork-qemu-devel@patchwork.kernel.org; Thu, 21 Jan 2016 14:05:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54616) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMKXK-0007RS-0h for qemu-devel@nongnu.org; Thu, 21 Jan 2016 14:04:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aMKXG-0001CS-AX for qemu-devel@nongnu.org; Thu, 21 Jan 2016 14:04:49 -0500 Received: from mail-lb0-x241.google.com ([2a00:1450:4010:c04::241]:34696) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMKXG-0001C0-3I; Thu, 21 Jan 2016 14:04:46 -0500 Received: by mail-lb0-x241.google.com with SMTP id oe3so2465564lbb.1; Thu, 21 Jan 2016 11:04:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=496mFPH1cBgqLJuGgW27lhsFvxpjBxKrP6ooKxBuEfg=; b=S6SvdlXi/G7xDGmWLVUiOKboum+/wqUUzm+imyCUFlvmqYYu9hkFkVtOs38tkVFcl/ zjSzlcMrXF/Ft0dCGE7FpGcJv48saNutD1w7+gSmYpS+pkrBIbtSlvAn94zc2wROl6Xo i01KghFY+Qyc6fcx9sqYmbX2ATgS6sH1Y6A9CnwBLkY1RcmJFjxUCZ+yuEql5lo5hjr6 /urBHquWS4cOldI1fDdxAc8dmISrUimnJJSchnmPXPe2MlilC1BZKkOshfessVCS5M7I iXaUIoUqazsDGhNIcA40RYgM0jt4j6Pbosj/8wKtnB7oZ3/x8+A5Td9CYMfTsOWskPVR 5OSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=496mFPH1cBgqLJuGgW27lhsFvxpjBxKrP6ooKxBuEfg=; b=EWbu5yUI+Eg6LeEM9FvpogQnjo6zNmyZ6DdiiJ0vcCGulmomvRfvvwRqUMyKdUbsJr AUxa6j/w5MNumzFUw8kvy0Cku0kAiKCUCvjyYo5nhC8JnEq13xWpDvHR06h6NzMTbCNu dgKz+OLZs6lIWxFakJLc6/bjDCIu/UHeszPTOZSYTdz+2tATagcIAY0wBC6JdcJerKtA wPvbir0o1zjIcAxQlJjEbs2A3/YgohVkBUVSjPkwVY2ssxTNqJ2Puhqq0IJ9Km8fT6lT BNA1q/167EHX/1xm+Bg66KH+vcq4lv3G+c2WUMrrE/vqmIIDA6IpHDZAvO8Td46ngJG7 t26Q== X-Gm-Message-State: ALoCoQkfO2ozgw7Pz+6EBk9hwaqWLJfZ8dl5h2Z4Y0IgHqKBU1MYoWZtt/EkSll+WGtQv6CyoewKrz73UEz6TCCBczY7Fi2VGQ== X-Received: by 10.112.168.5 with SMTP id zs5mr16797439lbb.56.1453403085416; Thu, 21 Jan 2016 11:04:45 -0800 (PST) Received: from localhost.localdomain (ppp46-138-151-163.pppoe.spdop.ru. [46.138.151.163]) by smtp.gmail.com with ESMTPSA id m21sm382496lfe.29.2016.01.21.11.04.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Jan 2016 11:04:44 -0800 (PST) From: Dmitry Osipenko To: QEMU Developers , qemu-arm@nongnu.org Date: Thu, 21 Jan 2016 22:03:46 +0300 Message-Id: X-Mailer: git-send-email 2.7.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c04::241 Cc: Peter Maydell , Peter Crosthwaite Subject: [Qemu-devel] [PATCH v11 3/7] hw/ptimer: Update .delta on period/freq change X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Delta value must be updated on period/freq change, otherwise running timer would be restarted (counter reloaded with old delta). Only m68k/mcf520x and arm/arm_timer devices are currently doing freq change correctly, i.e. stopping the timer. Perform delta update to fix affected devices and eliminate potential further mistakes. Signed-off-by: Dmitry Osipenko Reviewed-by: Peter Crosthwaite --- hw/core/ptimer.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/core/ptimer.c b/hw/core/ptimer.c index cb50d30..904a77b 100644 --- a/hw/core/ptimer.c +++ b/hw/core/ptimer.c @@ -189,6 +189,7 @@ void ptimer_stop(ptimer_state *s) /* Set counter increment interval in nanoseconds. */ void ptimer_set_period(ptimer_state *s, int64_t period) { + s->delta = ptimer_get_count(s); s->period = period; s->period_frac = 0; if (s->enabled) { @@ -200,6 +201,7 @@ void ptimer_set_period(ptimer_state *s, int64_t period) /* Set counter frequency in Hz. */ void ptimer_set_freq(ptimer_state *s, uint32_t freq) { + s->delta = ptimer_get_count(s); s->period = 1000000000ll / freq; s->period_frac = (1000000000ll << 32) / freq; if (s->enabled) {